Skip to content

Commit

Permalink
Merge pull request #7127 from Sage/playwright-pipeline-investigation
Browse files Browse the repository at this point in the history
perf(pipeline): flaky Playwright investigations
  • Loading branch information
damienrobson-sage authored Dec 17, 2024
2 parents 4b63924 + 00c12d5 commit 4359844
Show file tree
Hide file tree
Showing 8 changed files with 481 additions and 294 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
timeout-minutes: 30
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.47.0-jammy
image: mcr.microsoft.com/playwright:v1.49.1-noble
strategy:
fail-fast: false
matrix:
Expand Down
3 changes: 2 additions & 1 deletion playwright-ct.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig, devices } from "@playwright/experimental-ct-react17";

import { resolve } from "path";

const playwrightDir = resolve(__dirname, "./playwright");
Expand Down Expand Up @@ -30,7 +31,7 @@ export default defineConfig({
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
trace: "retain-on-failure",
/* Port to use for Playwright component endpoint. */
ctPort: 3100,
/* Custom config for internal bundler Playwright uses for component tests. See https://playwright.dev/docs/test-components#under-the-hood */
Expand Down
47 changes: 35 additions & 12 deletions src/components/split-button/split-button.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ test.describe("Functional tests in a custom component", () => {
await mount(<WithWrapper />);

await splitToggleButton(page).nth(0).click();
const buttonList = page.getByRole("list");
await buttonList.waitFor();
await expect(additionalButton(page, 0)).toBeVisible();
await expect(additionalButton(page, 1)).toBeVisible();
await expect(additionalButton(page, 2)).toBeVisible();
Expand All @@ -592,14 +594,20 @@ test.describe("Functional tests in a custom component", () => {
await mount(<TwoButtonsWithWrapper />);

await splitToggleButton(page).nth(0).click();
await expect(additionalButton(page, 0)).toBeFocused();
await page.keyboard.press("Tab");
await expect(additionalButton(page, 1)).toBeFocused();
await page.keyboard.press("Tab");
await expect(additionalButton(page, 2)).toBeFocused();
await page.keyboard.press("Tab");
const buttonList = page.getByRole("list");
await buttonList.waitFor();

await expect(additionalButton(page, 0)).not.toBeVisible();
const firstButton = buttonList.getByRole("button").first();
const secondButton = buttonList.getByRole("button").nth(1);
const thirdButton = buttonList.getByRole("button").last();

await expect(firstButton).toBeFocused();
await firstButton.press("Tab");
await expect(secondButton).toBeFocused();
await secondButton.press("Tab");
await expect(thirdButton).toBeFocused();
await thirdButton.press("Tab");
await expect(buttonList).toBeHidden();
await expect(mainButton(page).nth(1)).toBeFocused();
});

Expand All @@ -610,7 +618,9 @@ test.describe("Functional tests in a custom component", () => {
await mount(<TwoButtonsWithWrapper />);

await splitToggleButton(page).nth(0).click();
await page.waitForTimeout(1000);
const buttonList = page.getByRole("list");
await buttonList.waitFor();

await page.keyboard.press("ArrowDown");
await page.keyboard.press("ArrowDown");
await page.keyboard.press("ArrowDown");
Expand All @@ -625,10 +635,13 @@ test.describe("Functional tests in a custom component", () => {
await mount(<TwoButtonsWithWrapper />);

await splitToggleButton(page).nth(0).click();
const buttonList = page.getByRole("list");
await buttonList.waitFor();

await additionalButton(page, 1).focus();
await page.keyboard.press("Shift+Tab");
await page.keyboard.press("Shift+Tab", { delay: 1000 });
await expect(additionalButton(page, 0)).toBeFocused();
await page.keyboard.press("Shift+Tab");
await page.keyboard.press("Shift+Tab", { delay: 1000 });

await expect(additionalButton(page, 0)).not.toBeVisible();
await expect(splitToggleButton(page).nth(0)).toBeFocused();
Expand All @@ -641,12 +654,14 @@ test.describe("Functional tests in a custom component", () => {
await mount(<TwoButtonsWithWrapper />);

await splitToggleButton(page).nth(0).click();
const buttonList = page.getByRole("list");
await buttonList.waitFor();
await additionalButton(page, 2).focus();
await page.waitForTimeout(1000);

await page.keyboard.press("ArrowUp");
await page.keyboard.press("ArrowUp");
await page.keyboard.press("ArrowUp");
await page.waitForTimeout(1000);

await expect(additionalButton(page, 0)).toBeFocused();
});

Expand All @@ -657,6 +672,8 @@ test.describe("Functional tests in a custom component", () => {
await mount(<TwoButtonsWithWrapper />);

await splitToggleButton(page).nth(0).click();
const buttonList = page.getByRole("list");
await buttonList.waitFor();
await additionalButton(page, 2).focus();
await page.keyboard.down("Meta");
await page.keyboard.press("ArrowUp");
Expand All @@ -670,6 +687,8 @@ test.describe("Functional tests in a custom component", () => {
await mount(<TwoButtonsWithWrapper />);

await splitToggleButton(page).nth(0).click();
const buttonList = page.getByRole("list");
await buttonList.waitFor();
await additionalButton(page, 2).focus();
await page.keyboard.down("Control");
await page.keyboard.press("ArrowUp");
Expand All @@ -695,6 +714,7 @@ test.describe("Functional tests in a custom component", () => {
await mount(<TwoButtonsWithWrapper />);

await splitToggleButton(page).nth(0).click();

await page.keyboard.down("Meta");
await page.keyboard.press("ArrowDown");
await expect(additionalButton(page, 2)).toBeFocused();
Expand Down Expand Up @@ -730,6 +750,7 @@ test.describe("Functional tests in a custom component", () => {
await mount(<WithWrapper />);

await splitToggleButton(page).nth(0).click();

await additionalButton(page, 0).click();
await expect(additionalButtonsContainer(page)).toHaveCount(0);
});
Expand All @@ -741,6 +762,8 @@ test.describe("Functional tests in a custom component", () => {
await mount(<WithWrapper />);

await splitToggleButton(page).nth(0).click();
const buttonList = page.getByRole("list");
await buttonList.waitFor();
await additionalButton(page, 1).focus();
await page.keyboard.press("Escape");
await expect(additionalButtonsContainer(page)).toHaveCount(0);
Expand Down
115 changes: 0 additions & 115 deletions src/components/tabs/tabs.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -454,121 +454,6 @@ test.describe("Tabs component", () => {
});
});

test.describe("check events for Tabs component", () => {
test.describe("when position is top", () => {
// TODO: Skipped due to flaky focus behaviour. To review in FE-6428
test.skip("should call onTabChange callback when click event is triggered", async ({
mount,
page,
}) => {
let callbackCount = 0;
await mount(
<TabsComponent
onTabChange={() => {
callbackCount += 1;
}}
/>,
);

await tabById(page, 2).click();
expect(callbackCount).toBe(1);
});

test("should call onTabChange callback when enter key event is triggered", async ({
mount,
page,
}) => {
let callbackCount = 0;
await mount(
<TabsComponent
onTabChange={() => {
callbackCount += 1;
}}
/>,
);

await tabById(page, 2).press("Enter");
expect(callbackCount).toBe(1);
});
});

test.describe("when position is left", () => {
// TODO: Skipped due to flaky focus behaviour. To review in FE-6428
test.skip("should call onTabChange callback when click event is triggered", async ({
mount,
page,
}) => {
let callbackCount = 0;
await mount(
<TabsComponent
position="left"
onTabChange={() => {
callbackCount += 1;
}}
/>,
);

await tabById(page, 2).click();
expect(callbackCount).toBe(1);
});

test("should call onTabChange callback when enter key event is triggered", async ({
mount,
page,
}) => {
let callbackCount = 0;
await mount(
<TabsComponent
position="left"
onTabChange={() => {
callbackCount += 1;
}}
/>,
);

await tabById(page, 2).press("Enter");
expect(callbackCount).toBe(1);
});
});

test.describe("when in Sidebar", () => {
// TODO: Skipped due to flaky focus behaviour. To review in FE-6428
test.skip("should call onTabChange callback when click event is triggered", async ({
mount,
page,
}) => {
let callbackCount = 0;
await mount(
<TabsInSidebar
onTabChange={() => {
callbackCount += 1;
}}
/>,
);

await tabById(page, 2).click();
expect(callbackCount).toBe(1);
});

test("should call onTabChange callback when enter key event is triggered", async ({
mount,
page,
}) => {
let callbackCount = 0;
await mount(
<TabsInSidebar
onTabChange={() => {
callbackCount += 1;
}}
/>,
);

await tabById(page, 2).press("Enter");
expect(callbackCount).toBe(1);
});
});
});

test.describe("Accessibility tests for Tabs component", () => {
test("should pass accessibility tests for Tabs component", async ({
mount,
Expand Down
Loading

0 comments on commit 4359844

Please sign in to comment.