Skip to content

Commit

Permalink
more control in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Elijbet committed Jan 23, 2025
1 parent a82272d commit aa64339
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/calcite-components/src/components/dialog/dialog.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1164,37 +1164,54 @@ describe("calcite-dialog", () => {
describe("focusTrap", () => {
it("can tab out of non-modal dialog when focusTrapDisabled=true", async () => {
const page = await newE2EPage();
await page.setContent(html` <calcite-dialog focus-trap-disabled open closable></calcite-dialog> `);
await page.setContent(html`
<calcite-dialog width-scale="s" focus-trap-disabled open closable><button>inside</button></calcite-dialog>
<button>outside</button>
`);
await skipAnimations(page);
await page.waitForChanges();

const dialog = await page.find("calcite-dialog");
expect(await dialog.isVisible()).toBe(true);

await page.keyboard.press("Tab");
await page.waitForChanges();
await page.keyboard.press("Tab");
await page.waitForChanges();
await page.keyboard.press("Tab");
await page.waitForChanges();

await page.keyboard.press("Escape");
await page.waitForTimeout(200);
await page.waitForChanges();

expect(await dialog.isVisible()).toBe(true);
});

it("cannot tab out of dialog when modal=true and focusTrapDisabled=true", async () => {
const page = await newE2EPage();
await page.setContent(html` <calcite-dialog modal focus-trap-disabled open closable></calcite-dialog> `);
await page.setContent(html`
<calcite-dialog width-scale="s" modal focus-trap-disabled open closable><button>inside</button></calcite-dialog>
<button>outside</button>
`);
await skipAnimations(page);
await page.waitForChanges();

const dialog = await page.find("calcite-dialog");
expect(await dialog.isVisible()).toBe(true);

await page.keyboard.press("Tab");
await page.waitForChanges();
await page.keyboard.press("Tab");
await page.waitForChanges();
await page.keyboard.press("Tab");
await page.waitForChanges();

await page.keyboard.press("Escape");
await page.waitForTimeout(200);
await page.waitForChanges();

// expect(await dialog.getAttribute("open")).toBe(false);
expect(await dialog.isVisible()).toBe(false);
});
});
Expand Down

0 comments on commit aa64339

Please sign in to comment.