Skip to content

Commit 369c4d1

Browse files
committed
More thorough testing of new behavior
1 parent fee8558 commit 369c4d1

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

test/puppeteer/demo.test.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ it('focuses on the first menu item when the enter key is pressed', async () => {
3131
it('focuses on the menu button after pressing escape', async () => {
3232
await page.click('#menu-button');
3333
await menuOpen();
34+
3435
await keyboard.down('Escape');
3536
await menuClosed();
3637

@@ -40,6 +41,7 @@ it('focuses on the menu button after pressing escape', async () => {
4041
it('focuses on the next item in the tab order after pressing tab', async () => {
4142
await page.click('#menu-button');
4243
await menuOpen();
44+
4345
await keyboard.down('Tab');
4446
await menuClosed();
4547

@@ -49,6 +51,7 @@ it('focuses on the next item in the tab order after pressing tab', async () => {
4951
it('focuses on the previous item in the tab order after pressing shift-tab', async () => {
5052
await page.click('#menu-button');
5153
await menuOpen();
54+
5255
await keyboard.down('Shift');
5356
await keyboard.down('Tab');
5457
await menuClosed();
@@ -59,10 +62,24 @@ it('focuses on the previous item in the tab order after pressing shift-tab', asy
5962
it('closes the menu if you click outside of it', async () => {
6063
await page.click('#menu-button');
6164
await menuOpen();
65+
6266
await page.click('body');
63-
await menuClosed();
67+
await menuClosed(); // times out if menu doesn't close
68+
69+
expect(true).toBe(true);
70+
});
71+
72+
it('leaves the menu open if you click inside of it', async () => {
73+
await page.click('#menu-button');
74+
await menuOpen();
75+
76+
await page.click('#menu-item-1');
77+
await new Promise(resolve => setTimeout(resolve, 1000)); // visibility: hidden is delayed via CSS
78+
await menuOpen(); // times out if menu closes
6479

65-
// menuClosed() will time out if it doesn't actually close
80+
await page.click('#menu');
81+
await new Promise(resolve => setTimeout(resolve, 1000)); // visibility: hidden is delayed via CSS
82+
await menuOpen(); // times out if menu closes
6683

6784
expect(true).toBe(true);
6885
});

0 commit comments

Comments
 (0)