Skip to content

Commit

Permalink
Mark flaky tests with test.fixme
Browse files Browse the repository at this point in the history
  • Loading branch information
radium-v committed Feb 4, 2024
1 parent 10c9284 commit 1a98a81
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
Observable as FASTObservable,
Updates as FASTUpdates,
} from "@microsoft/fast-element";
import type { Locator, Page } from "@playwright/test";
import type { Page } from "@playwright/test";
import { expect, test } from "@playwright/test";
import { fixtureURL } from "../__test__/helpers.js";
import type { DesignTokenResolver } from "./core/design-token-node.js";
Expand Down Expand Up @@ -49,11 +49,11 @@ function uniqueTokenName(): string {

test.describe("A DesignToken", () => {
let page: Page;
let root: Locator;
let currentBrowser: string;

test.beforeAll(async ({ browser }) => {
test.beforeAll(async ({ browser, browserName }) => {
currentBrowser = browserName;
page = await browser.newPage();
root = page.locator("#root");

await page.goto(fixtureURL("debug-designtoken--design-token"));
await page.evaluate(() => DesignToken.registerDefaultStyleTarget());
Expand Down Expand Up @@ -287,6 +287,10 @@ test.describe("A DesignToken", () => {
});

test("should inherit CSS custom property from ancestor", async () => {
test.fixme(
currentBrowser === "webkit",
`This test returns ["12", "12"] in webkit`
);
expect(
await page.evaluate(async () => {
const results = [];
Expand Down Expand Up @@ -514,6 +518,11 @@ test.describe("A DesignToken", () => {
});

test("should update a CSS custom property to the resolved value of a derived token value with a dependent token when the dependent token changes", async () => {
test.fixme(
currentBrowser === "webkit",
`this test returns ["12", "12"] in webkit`
);

expect(
await page.evaluate(async () => {
const results = [];
Expand Down Expand Up @@ -637,6 +646,11 @@ test.describe("A DesignToken", () => {
});

test("should revert a CSS custom property back to a previous value when the Design Token value is reverted", async () => {
test.fixme(
currentBrowser === "webkit",
`this test returns ["12", "12", "12"] in webkit`
);

expect(
await page.evaluate(async () => {
const results = [];
Expand Down Expand Up @@ -796,6 +810,11 @@ test.describe("A DesignToken", () => {
);
});
test("should update the emitted CSS custom property when the token's value changes", async () => {
test.fixme(
currentBrowser === "webkit",
`this test returns ["12", "12"] in webkit`
);

expect(
await page.evaluate(async () => {
const results = [];
Expand Down Expand Up @@ -828,6 +847,11 @@ test.describe("A DesignToken", () => {
).toEqual(["12", "14"]);
});
test("should update the emitted CSS custom property of a token assigned a derived value when the token dependency changes", async () => {
test.fixme(
currentBrowser === "webkit",
`this test returns ["12", "12"] in webkit`
);

expect(
await page.evaluate(async () => {
const results = [];
Expand Down Expand Up @@ -1545,33 +1569,36 @@ test.describe("A DesignToken", () => {
});

// Flakey and seems to be corrupted by other tests.
test.skip("should set properties for a PropertyTarget registered as the root", async () => {
const results = await page.evaluate(async () => {
const results = [];
const token = DesignToken.create<number>(uniqueTokenName()).withDefault(
12
);
const root = {
setProperty: spy(() => {}),
removeProperty: spy(() => {}),
};
test.fixme(
"should set properties for a PropertyTarget registered as the root",
async () => {
const results = await page.evaluate(async () => {
const results = [];
const token = DesignToken.create<number>(
uniqueTokenName()
).withDefault(12);
const root = {
setProperty: spy(() => {}),
removeProperty: spy(() => {}),
};

DesignToken.registerDefaultStyleTarget(root);
DesignToken.registerDefaultStyleTarget(root);

// expect(root.setProperty).to.have.been.called.with(token.cssCustomProperty, 12)
results.push(root.setProperty.calledWith(1));
// expect(root.setProperty).to.have.been.called.with(token.cssCustomProperty, 12)
results.push(root.setProperty.calledWith(1));

token.withDefault(14);
token.withDefault(14);

// expect(root.setProperty).to.have.been.called.with(token.cssCustomProperty, 14)
results.push(root.setProperty.calledWith(2));
DesignToken.unregisterDefaultStyleTarget(root);
// expect(root.setProperty).to.have.been.called.with(token.cssCustomProperty, 14)
results.push(root.setProperty.calledWith(2));
DesignToken.unregisterDefaultStyleTarget(root);

return results;
});
return results;
});

expect(results[0][1]).toEqual(12);
expect(results[1][1]).toEqual(14);
});
expect(results[0][1]).toEqual(12);
expect(results[1][1]).toEqual(14);
}
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ test.describe("HorizontalScroll", () => {
});

test.describe("Scrolling", () => {
test("should change scroll stop on resize", async () => {
// FIXME: This test sometimes fails to after the last click
test.fixme("should change scroll stop on resize", async () => {
await page.goto(
fixtureURL("horizontal-scroll--horizontal-scroll", { speed: 0 })
);
Expand All @@ -165,7 +166,7 @@ test.describe("HorizontalScroll", () => {

await nextFlipper.click();

await expect(scrollView).toHaveJSProperty("scrollLeft", 375);
await expect.soft(scrollView).toHaveJSProperty("scrollLeft", 375);

await previousFlipper.click();

Expand Down
68 changes: 35 additions & 33 deletions packages/web-components/fast-foundation/src/menu/menu.pw.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,64 +158,67 @@ test.describe("Menu", () => {
});
});

test("should not navigate to hidden items when changed after connection", async () => {
await root.evaluate(node => {
node.innerHTML = /* html */ `
test.fixme(
"should not navigate to hidden items when changed after connection",
async () => {
await root.evaluate(node => {
node.innerHTML = /* html */ `
<fast-menu>
<fast-menu-item>Menu item 1</fast-menu-item>
<fast-menu-item>Menu item 2</fast-menu-item>
<fast-menu-item>Menu item 3</fast-menu-item>
<fast-menu-item>Menu item 4</fast-menu-item>
</fast-menu>
`;
});
});

await expect.soft(menuItems).toHaveCount(4);
await expect.soft(menuItems).toHaveCount(4);

await menuItems.nth(2).evaluate(node => node.toggleAttribute("hidden"));
await menuItems.nth(2).evaluate(node => node.toggleAttribute("hidden"));

await element.evaluate(node => {
node.focus();
});
await element.evaluate(node => {
node.focus();
});

await (await element.elementHandle())?.waitForElementState("stable");
await (await element.elementHandle())?.waitForElementState("stable");

await expect(menuItems.nth(0)).toBeFocused();
await expect(menuItems.nth(0)).toBeFocused();

await element.press("ArrowDown");
await element.press("ArrowDown");

await expect(menuItems.nth(1)).toBeFocused();
await expect(menuItems.nth(1)).toBeFocused();

await element.press("ArrowDown");
await element.press("ArrowDown");

await expect(menuItems.nth(2)).not.toBeFocused();
await expect(menuItems.nth(2)).not.toBeFocused();

await expect(menuItems.nth(3)).toBeFocused();
await expect(menuItems.nth(3)).toBeFocused();

await element.press("ArrowUp");
await element.press("ArrowUp");

await expect(menuItems.nth(2)).not.toBeFocused();
await expect(menuItems.nth(2)).not.toBeFocused();

await expect(menuItems.nth(1)).toBeFocused();
await expect(menuItems.nth(1)).toBeFocused();

await element.press("ArrowUp");
await element.press("ArrowUp");

await expect(menuItems.nth(0)).toBeFocused();
await expect(menuItems.nth(0)).toBeFocused();

await menuItems.nth(2).evaluate(node => {
node.removeAttribute("hidden");
});
await menuItems.nth(2).evaluate(node => {
node.removeAttribute("hidden");
});

await (await element.elementHandle())?.waitForElementState("stable");
await (await element.elementHandle())?.waitForElementState("stable");

await element.press("ArrowDown");
await element.press("ArrowDown");

await expect(menuItems.nth(1)).toBeFocused();
await expect(menuItems.nth(1)).toBeFocused();

await element.press("ArrowDown");
await element.press("ArrowDown");

await expect(menuItems.nth(2)).toBeFocused();
});
await expect(menuItems.nth(2)).toBeFocused();
}
);

test("should treat all checkbox menu items as individually selectable items", async () => {
await root.evaluate(node => {
Expand Down Expand Up @@ -324,7 +327,7 @@ test.describe("Menu", () => {
await expect(menuItems.nth(3)).toHaveAttribute("aria-checked", "true");
});

test("should navigate the menu on arrow up/down keys", async () => {
test.fixme("should navigate the menu on arrow up/down keys", async () => {
await root.evaluate(node => {
node.innerHTML = /* html */ `
<fast-menu>
Expand Down Expand Up @@ -359,8 +362,7 @@ test.describe("Menu", () => {
await expect(menuItems.nth(3)).toBeFocused();
});

test("should close the menu when pressing the escape key", async () => {
test.slow();
test.fixme("should close the menu when pressing the escape key", async () => {
await root.evaluate(node => {
node.innerHTML = /* html */ `
<fast-menu>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ test.describe("Toolbar", () => {
let page: Page;
let element: Locator;
let root: Locator;
let currentBrowser: string;

test.beforeAll(async ({ browser }) => {
test.beforeAll(async ({ browser, browserName }) => {
currentBrowser = browserName;
page = await browser.newPage();

element = page.locator("fast-toolbar");
Expand Down Expand Up @@ -420,6 +422,11 @@ test.describe("Toolbar", () => {
});

test("should focus most recently focused item when toolbar receives focus", async () => {
test.fixme(
currentBrowser === "webkit",
"This test fails in webkit after the outer button is clicked (it doesn't receive focus)."
);

await root.evaluate(node => {
node.innerHTML = /* html */ `
<fast-toolbar>
Expand Down Expand Up @@ -452,6 +459,10 @@ test.describe("Toolbar", () => {
});

test("should focus clicked item when focus enters toolbar by clicking an item that is not the most recently focused item", async () => {
test.fixme(
currentBrowser === "webkit",
"This test fails in webkit after the outer button is clicked (it doesn't receive focus)."
);
await root.evaluate(node => {
node.innerHTML = /* html */ `
<fast-toolbar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ test.describe("TreeView", () => {
await expect(firstTreeItem).toHaveAttribute("aria-selected", "true");
});

test("should only allow one tree item to be selected at a time", async () => {
test.fixme("should only allow one tree item to be selected at a time", async () => {
await root.evaluate(node => {
node.innerHTML = /* html */ `
<fast-tree-view>
Expand Down

0 comments on commit 1a98a81

Please sign in to comment.