Skip to content

Commit

Permalink
Merge branch 'master' into Sage/DSY-1746-Button-Toggle-Minor-Child
Browse files Browse the repository at this point in the history
  • Loading branch information
edleeks87 authored Nov 28, 2023
2 parents 08d3bc8 + 5990bf2 commit 0e253b6
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 64 deletions.
17 changes: 12 additions & 5 deletions playwright/support/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ export const getStyle = async (
);
};

export const waitForAnimationEnd = (locator: Locator) =>
locator.evaluate((element) =>
Promise.all(element.getAnimations().map((animation) => animation.finished))
);

/**
* Check the accessibility rules for an element.
* @param {Page} page
Expand All @@ -34,13 +39,20 @@ export const getStyle = async (
*/
export const checkAccessibility = async (
page: Page,
locator?: Locator,
...disableRules: string[]
) => {
const preDisabledRules = [
"landmark-one-main",
"page-has-heading-one",
"region",
];

if (locator) {
await locator.waitFor();
await waitForAnimationEnd(locator);
}

const accessibilityScanResults = await new AxeBuilder({ page })
.withTags([
"wcag2a", // WCAG 2.0 & WCAG 2.1 Level A
Expand Down Expand Up @@ -350,8 +362,3 @@ export const continuePressingSHIFTTAB = async (page: Page, count: number) => {

await Promise.all(promises);
};

export const waitForAnimationEnd = (locator: Locator) =>
locator.evaluate((element) =>
Promise.all(element.getAnimations().map((animation) => animation.finished))
);
3 changes: 2 additions & 1 deletion src/components/alert/alert.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ test.describe("should render Alert component", () => {
expect(callbackCount).toBe(1);
});

test("setting the topModalOverride prop should ensure the Alert is rendered on top of any others", async ({
// test skipped until we can investigate and fix issue with focus in Modals FE-6245
test.skip("setting the topModalOverride prop should ensure the Alert is rendered on top of any others", async ({
mount,
page,
}) => {
Expand Down
4 changes: 3 additions & 1 deletion src/components/anchor-navigation/anchor-navigation.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ test.describe("Accessibility tests for Anchor Navigation component", () => {
await mount(<InFullScreenDialog />);
await page.getByText("open AnchorNavigation").click();
await page.locator(DIALOG_FULL_SCREEN).waitFor();
await checkAccessibility(page);

// color-contrast ignored until we can investigate and fix FE-6245
await checkAccessibility(page, undefined, "color-contrast");
});
});
18 changes: 12 additions & 6 deletions src/components/checkbox/checkbox.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ test.describe("should check accessibility for Checkbox component", () => {

const checkboxIconElement = checkboxIcon(page);
await checkboxIconElement.hover();
await checkAccessibility(page);
await checkAccessibility(page, tooltipPreview(page));
});

test("should pass accessibility tests with disabled prop", async ({
Expand Down Expand Up @@ -932,7 +932,7 @@ test.describe("should check accessibility for Checkbox component", () => {

const checkboxIconElement = checkboxIcon(page);
await checkboxIconElement.hover();
await checkAccessibility(page);
await checkAccessibility(page, tooltipPreview(page));
});
});

Expand All @@ -942,7 +942,9 @@ test.describe("should check accessibility for Checkbox component", () => {
}) => {
await mount(<CheckboxComponent error="Error has occurred" />);

await checkAccessibility(page);
const checkboxIconElement = checkboxIcon(page);
await checkboxIconElement.hover();
await checkAccessibility(page, tooltipPreview(page));
});

test("should pass accessibility tests with warning message", async ({
Expand All @@ -951,7 +953,9 @@ test.describe("should check accessibility for Checkbox component", () => {
}) => {
await mount(<CheckboxComponent warning="Warning has occurred" />);

await checkAccessibility(page);
const checkboxIconElement = checkboxIcon(page);
await checkboxIconElement.hover();
await checkAccessibility(page, tooltipPreview(page));
});

test("should pass accessibility tests with info message", async ({
Expand All @@ -960,7 +964,9 @@ test.describe("should check accessibility for Checkbox component", () => {
}) => {
await mount(<CheckboxComponent info="Info has occurred" />);

await checkAccessibility(page);
const checkboxIconElement = checkboxIcon(page);
await checkboxIconElement.hover();
await checkAccessibility(page, tooltipPreview(page));
});
});

Expand Down Expand Up @@ -1062,7 +1068,7 @@ test.describe("should check accessibility for Checkbox Group component", () => {

const checkboxIconElement = checkboxGroupIcon(page);
await checkboxIconElement.hover();
await checkAccessibility(page);
await checkAccessibility(page, tooltipPreview(page));
});
});
});
3 changes: 2 additions & 1 deletion src/components/confirm/confirm.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,8 @@ test.describe("should render Confirm component for event tests", () => {
expect(callbackCount).toBe(1);
});

test("setting the topModalOverride prop should ensure the Confirm is rendered on top of any others", async ({
// test skipped until we can investigate and fix issue with focus in Modals FE-6245
test.skip("setting the topModalOverride prop should ensure the Confirm is rendered on top of any others", async ({
mount,
page,
}) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/decimal/decimal.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ test.describe("Accessibility tests for Decimal component", () => {
"question"
);
await getDataElementByValueElementQuestion.hover();
await checkAccessibility(page);
await checkAccessibility(page, tooltipPreview(page));
});

test("should pass accessibility tests for Decimal required", async ({
Expand Down
38 changes: 27 additions & 11 deletions src/components/dialog-full-screen/dialog-full-screen.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ test.describe("render DialogFullScreen component and check properties", () => {
);
});

test("setting the topModalOverride prop should ensure the DialogFullScreen is rendered on top of any others", async ({
// test skipped until we can investigate and fix issue with focus in Modals FE-6245
test.skip("setting the topModalOverride prop should ensure the DialogFullScreen is rendered on top of any others", async ({
mount,
page,
}) => {
Expand Down Expand Up @@ -445,7 +446,7 @@ test.describe("render DialogFullScreen component and check properties", () => {
await expect(dialogClose).toBeFocused();
});

test("should loop focus when a Select component is passed as children and the user presses shift + tab", async ({
test.skip("should loop focus when a Select component is passed as children and the user presses shift + tab", async ({
mount,
page,
}) => {
Expand All @@ -469,7 +470,8 @@ test.describe("Accessibility for DialogFullScreen", () => {
}) => {
await mount(<DialogFullScreenComponent />);

await checkAccessibility(page);
// color-contrast ignored until we can investigate and fix FE-6245
await checkAccessibility(page, undefined, "color-contrast");
});

test("should check accessibility with disabled content padding", async ({
Expand All @@ -478,7 +480,8 @@ test.describe("Accessibility for DialogFullScreen", () => {
}) => {
await mount(<DialogFullScreenComponent disableContentPadding />);

await checkAccessibility(page);
// color-contrast ignored until we can investigate and fix
await checkAccessibility(page, undefined, "color-contrast");
});

test("should check accessibility with header children", async ({
Expand All @@ -487,7 +490,8 @@ test.describe("Accessibility for DialogFullScreen", () => {
}) => {
await mount(<DialogFullScreenWithHeaderChildren />);

await checkAccessibility(page);
// color-contrast ignored until we can investigate and fix FE-6245
await checkAccessibility(page, page.getByRole("dialog"), "color-contrast");
});

test("should check accessibility with help", async ({ mount, page }) => {
Expand All @@ -497,7 +501,9 @@ test.describe("Accessibility for DialogFullScreen", () => {
.getByRole("button")
.filter({ hasText: "Open DialogFullScreen" });
await openButton.click();
await checkAccessibility(page);

// color-contrast ignored until we can investigate and fix
await checkAccessibility(page, undefined, "color-contrast");
});

test("should check accessibility with hideable header children", async ({
Expand All @@ -510,7 +516,9 @@ test.describe("Accessibility for DialogFullScreen", () => {
.getByRole("button")
.filter({ hasText: "Open DialogFullScreen" });
await openButton.click();
await checkAccessibility(page);

// color-contrast ignored until we can investigate and fix FE-6245
await checkAccessibility(page, page.getByRole("dialog"), "color-contrast");
});

test("should check accessibility with box", async ({ mount, page }) => {
Expand All @@ -533,7 +541,9 @@ test.describe("Accessibility for DialogFullScreen", () => {
.getByRole("button")
.filter({ hasText: "Open Demo using focusFirstElement" });
await focusFirstButton.click();
await checkAccessibility(page);

// color-contrast ignored until we can investigate and fix FE-6245
await checkAccessibility(page, page.getByRole("dialog"), "color-contrast");

const closeIcon = getDataElementByValue(page, "close").first();
await closeIcon.click();
Expand All @@ -542,7 +552,9 @@ test.describe("Accessibility for DialogFullScreen", () => {
.getByRole("button")
.filter({ hasText: "Open Demo using autoFocus" });
await autoFocusButton.click();
await checkAccessibility(page);

// color-contrast ignored until we can investigate and fix FE-6245
await checkAccessibility(page, page.getByRole("dialog"), "color-contrast");
});

test("should check accessibility with other focusable containers", async ({
Expand All @@ -555,7 +567,9 @@ test.describe("Accessibility for DialogFullScreen", () => {
.getByRole("button")
.filter({ hasText: "Open DialogFullScreen" });
await openButton.click();
await checkAccessibility(page);

// color-contrast ignored until we can investigate and fix
await checkAccessibility(page, undefined, "color-contrast");
});

test("should check accessibility with complex example", async ({
Expand All @@ -571,7 +585,9 @@ test.describe("Accessibility for DialogFullScreen", () => {
await expect(getDataElementByValue(page, "title")).toHaveText(
"Dialog Title"
);
await checkAccessibility(page);

// color-contrast ignored until we can investigate and fix
await checkAccessibility(page, undefined, "color-contrast");
});
});

Expand Down
18 changes: 12 additions & 6 deletions src/components/dialog/dialog.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ test.describe("Testing Dialog component properties", () => {
).not.toBeFocused();
});

test("when tabbing through Dialog content, focus should remain trapped inside the Dialog", async ({
// test skipped until we can investigate and fix issue with focus in Modals FE-6245
test.skip("when tabbing through Dialog content, focus should remain trapped inside the Dialog", async ({
mount,
page,
}) => {
Expand Down Expand Up @@ -291,7 +292,8 @@ test.describe("Testing Dialog component properties", () => {
await expect(closeButton).toBeFocused();
});

test("when shift tabbing through Dialog content, focus should remain trapped inside the Dialog", async ({
// test skipped until we can investigate and fix issue with focus in Modals FE-6245
test.skip("when shift tabbing through Dialog content, focus should remain trapped inside the Dialog", async ({
mount,
page,
}) => {
Expand Down Expand Up @@ -320,7 +322,8 @@ test.describe("Testing Dialog component properties", () => {
await expect(thirdTextbox).toBeFocused();
});

test("when tabbing through Dialog content, background should not scroll to the bottom of the page", async ({
// test skipped until we can investigate and fix issue with focus in Modals FE-6245
test.skip("when tabbing through Dialog content, background should not scroll to the bottom of the page", async ({
mount,
page,
}) => {
Expand All @@ -341,7 +344,8 @@ test.describe("Testing Dialog component properties", () => {
).not.toBeInViewport();
});

test("when shift tabbing through Dialog content, background should not scroll to the bottom of the page", async ({
// test skipped until we can investigate and fix issue with focus in Modals FE-6245
test.skip("when shift tabbing through Dialog content, background should not scroll to the bottom of the page", async ({
mount,
page,
}) => {
Expand All @@ -361,7 +365,8 @@ test.describe("Testing Dialog component properties", () => {
).not.toBeInViewport();
});

test("should loop focus when a Select component is passed as children and the user presses shift + tab", async ({
// test skipped until we can investigate and fix issue with focus in Modals FE-6245
test.skip("should loop focus when a Select component is passed as children and the user presses shift + tab", async ({
mount,
page,
}) => {
Expand Down Expand Up @@ -485,7 +490,8 @@ test("Dialog should have rounded corners", async ({ mount, page }) => {
await expect(page.getByRole("dialog")).toHaveCSS("border-radius", "16px");
});

test("setting the topModalOverride prop should ensure the Dialog is rendered on top of any others", async ({
// test skipped until we can investigate and fix issue with focus in Modals FE-6245
test.skip("setting the topModalOverride prop should ensure the Dialog is rendered on top of any others", async ({
mount,
page,
}) => {
Expand Down
3 changes: 3 additions & 0 deletions src/components/drawer/drawer.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ test.describe("check props for Drawer component", () => {
<DrawerCustom showControls animationDuration={animationDuration} />
);

await waitForAnimationEnd(
page.locator('[data-element="drawer-content"]')
);
const drawerToggleButton = drawerToggle(page);
await drawerToggleButton.click();
const sidebar = drawerSidebar(page);
Expand Down
2 changes: 1 addition & 1 deletion src/components/duelling-picklist/duelling-picklist.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ test.describe(`Accessibility tests for Duelling-Picklist component`, () => {
const lockedItem = getDataElementByValue(page, "locked").first();
await lockedItem.hover({ force: true });
await expect(tooltipPreview(page)).toBeVisible();
await checkAccessibility(page);
await checkAccessibility(page, tooltipPreview(page));
});

test.skip(`should pass accessibility tests when disabled`, async ({
Expand Down
4 changes: 3 additions & 1 deletion src/components/form/form.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ test.describe("Accessibility tests for Form component", () => {

const dialogButton = dataComponentButtonByText(page, "Open Preview");
await dialogButton.click();
await checkAccessibility(page);

// color-contrast ignored until we can investigate and fix FE-6245
await checkAccessibility(page, undefined, "color-contrast");
});

test(`should pass tests for InDialogFullScreenWithStickyFooter example`, async ({
Expand Down
Loading

0 comments on commit 0e253b6

Please sign in to comment.