Skip to content

Commit

Permalink
Add test for pressing ESC twice
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardHelm committed Aug 12, 2024
1 parent d096946 commit cd0e936
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions libs/components/src/lib/dialog/ui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,43 @@ test('should show the the dialog as a modal when calling .showModal()', async ({
'./snapshots/dialog-modal.png'
);
});

test('should leave the dialog open on pressing ESC twice when cancel event is cancelled', async ({
page,
}: {
page: Page;
}) => {
const template = `
<div style="height: 800px">
<vwc-dialog
icon="info"
headline="Headline"
open
modal
></vwc-dialog>
</div>
`;

await loadComponents({
page,
components,
});
await loadTemplate({
page,
template,
});

await page.waitForLoadState('networkidle');

await page.evaluate(() => {
const dialog = document.querySelector('vwc-dialog');
dialog.addEventListener('cancel', (event) => {
event.preventDefault();
});
});

await page.keyboard.press('Escape');
await page.keyboard.press('Escape');

await expect(page.locator('dialog')).toHaveAttribute('open', '');
});

0 comments on commit cd0e936

Please sign in to comment.