-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82f4225
commit 7227f96
Showing
7 changed files
with
185 additions
and
8 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
packages/sit-onyx/src/components/OnyxAccordion/OnyxAccordion.ct.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { DENSITIES } from "../../composables/density"; | ||
import { expect, test } from "../../playwright/a11y"; | ||
import { executeMatrixScreenshotTest } from "../../playwright/screenshots"; | ||
import OnyxAccordionItem from "../OnyxAccordionItem/OnyxAccordionItem.vue"; | ||
import OnyxAccordion from "./OnyxAccordion.vue"; | ||
|
||
test.describe("ScreenshotTest", () => { | ||
executeMatrixScreenshotTest({ | ||
name: "Accordion", | ||
columns: DENSITIES, | ||
rows: ["default", "open", "hover", "focus-visible", "disabled", "skeleton"], | ||
component: (column, row) => ( | ||
<OnyxAccordion | ||
style="width: 200px;" | ||
density={column} | ||
skeleton={row === "skeleton"} | ||
disabled={row === "disabled"} | ||
> | ||
<OnyxAccordionItem> | ||
<template v-slot:header>Accordion Header 1</template> | ||
<template v-slot:panel>Accordion Panel 1</template> | ||
</OnyxAccordionItem> | ||
<OnyxAccordionItem> | ||
<template v-slot:header>Accordion Header 2</template> | ||
<template v-slot:panel>Accordion Panel 2</template> | ||
</OnyxAccordionItem> | ||
</OnyxAccordion> | ||
), | ||
hooks: { | ||
beforeEach: async (component, page, _column, row) => { | ||
if (row == "open") await component.locator(".onyx-accordion-item__header").click(); | ||
if (row === "hover") await component.hover(); | ||
if (row === "focus-visible") await page.keyboard.press("Tab"); | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
// Test for exclusive mode | ||
test("should open only one item at a time in exclusive mode", async ({ mount, makeAxeBuilder }) => { | ||
const component = await mount( | ||
<OnyxAccordion exclusive> | ||
<OnyxAccordionItem> | ||
<template v-slot:header>Accordion Header 1</template> | ||
<template v-slot:panel>Accordion Panel 1</template> | ||
</OnyxAccordionItem> | ||
<OnyxAccordionItem> | ||
<template v-slot:header>Accordion Header 2</template> | ||
<template v-slot:panel>Accordion Panel 2</template> | ||
</OnyxAccordionItem> | ||
</OnyxAccordion>, | ||
); | ||
|
||
const firstHeader = component.locator(".onyx-accordion-item__header").first(); | ||
const secondHeader = component.locator(".onyx-accordion-item__header").nth(1); | ||
|
||
await firstHeader.click(); | ||
await expect(component.locator(".onyx-accordion-item__panel").first()).toBeVisible(); | ||
await expect(component.locator(".onyx-accordion-item__panel").nth(1)).toBeHidden(); | ||
|
||
await secondHeader.click(); | ||
await expect(component.locator(".onyx-accordion-item__panel").first()).toBeHidden(); | ||
await expect(component.locator(".onyx-accordion-item__panel").nth(1)).toBeVisible(); | ||
|
||
const accessibilityScanResults = await makeAxeBuilder().analyze(); | ||
|
||
expect(accessibilityScanResults.violations).toEqual([]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/sit-onyx/src/components/OnyxAccordionItem/OnyxAccordionItem.ct.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { DENSITIES } from "../../composables/density"; | ||
import { expect, test } from "../../playwright/a11y"; | ||
import { executeMatrixScreenshotTest } from "../../playwright/screenshots"; | ||
import OnyxAccordionItem from "./OnyxAccordionItem.vue"; | ||
|
||
test.describe("ScreenshotTest", () => { | ||
executeMatrixScreenshotTest({ | ||
name: "AccordionItem", | ||
columns: DENSITIES, | ||
rows: ["default", "open", "hover", "focus-visible", "disabled", "skeleton"], | ||
component: (column, row) => ( | ||
<OnyxAccordionItem | ||
style="width: 200px;" | ||
density={column} | ||
skeleton={row === "skeleton"} | ||
disabled={row === "disabled"} | ||
> | ||
<template v-slot:header>Accordion Header</template> | ||
<template v-slot:panel>Accordion Panel</template> | ||
</OnyxAccordionItem> | ||
), | ||
hooks: { | ||
beforeEach: async (component, page, _column, row) => { | ||
if (row == "open") await component.locator(".onyx-accordion-item__header").click(); | ||
if (row === "hover") await component.hover(); | ||
if (row === "focus-visible") await page.keyboard.press("Tab"); | ||
}, | ||
}, | ||
}); | ||
}); | ||
|
||
test("should toggle open state on click", async ({ mount, makeAxeBuilder }) => { | ||
// ARRANGE | ||
const component = await mount( | ||
<OnyxAccordionItem> | ||
<template v-slot:header>Accordion Header</template> | ||
<template v-slot:panel>Accordion Panel</template> | ||
</OnyxAccordionItem>, | ||
); | ||
|
||
// Locators | ||
const header = component.locator(".onyx-accordion-item__header"); | ||
const panel = component.locator(".onyx-accordion-item__panel"); | ||
|
||
await expect(panel).toBeHidden(); | ||
await header.click(); | ||
await expect(panel).toBeVisible(); | ||
await header.click(); | ||
await expect(panel).toBeHidden(); | ||
|
||
// ACT | ||
const accessibilityScanResults = await makeAxeBuilder().analyze(); | ||
|
||
// ASSERT | ||
expect(accessibilityScanResults.violations).toEqual([]); | ||
}); | ||
test("should apply the disabled state", async ({ mount, makeAxeBuilder }) => { | ||
const component = await mount( | ||
<OnyxAccordionItem disabled> | ||
<template v-slot:header>Accordion Header</template> | ||
<template v-slot:panel>Accordion Panel</template> | ||
</OnyxAccordionItem>, | ||
); | ||
|
||
// Locators | ||
const header = component.locator(".onyx-accordion-item__header"); | ||
await expect(header).toHaveAttribute("tabindex", "-1"); | ||
|
||
const accessibilityScanResults = await makeAxeBuilder().analyze(); | ||
|
||
expect(accessibilityScanResults.violations).toEqual([]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters