Skip to content

Commit ea96abe

Browse files
added tests for keyboard navigation through lightbox images and rows; check for temp modals, too
1 parent cb2c321 commit ea96abe

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

screenshot-tests/report.test.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,86 @@ test('each image click', async ({ page, browserName }) => {
4444
});
4545
}
4646
});
47+
48+
test('cycle images in row on left/right keyboard input', async ({ page }) => {
49+
await page.goto(reportUrl);
50+
51+
await page.locator('.diff-images button').first().click();
52+
await expect(page.locator('dialog#lightbox')).toBeVisible();
53+
54+
const firstImageCounter = page.locator('.lightbox-image-counter').first();
55+
56+
await expect(firstImageCounter).toHaveText('Image 1 / 3');
57+
58+
await page.keyboard.press('ArrowRight');
59+
await expect(firstImageCounter).toHaveText('Image 2 / 3');
60+
61+
await page.keyboard.press('ArrowRight');
62+
await expect(firstImageCounter).toHaveText('Image 3 / 3');
63+
64+
await page.keyboard.press('ArrowRight');
65+
await expect(firstImageCounter).toHaveText('Image 1 / 3');
66+
67+
await page.keyboard.press('ArrowLeft');
68+
await expect(firstImageCounter).toHaveText('Image 3 / 3');
69+
70+
await page.keyboard.press('ArrowLeft');
71+
await expect(firstImageCounter).toHaveText('Image 2 / 3');
72+
73+
await page.keyboard.press('ArrowLeft');
74+
await expect(firstImageCounter).toHaveText('Image 1 / 3');
75+
});
76+
77+
test('cycle rows on up/down keyboard input', async ({ page }) => {
78+
await page.goto(reportUrl);
79+
80+
await page.locator('.diff-images button').first().click();
81+
await expect(page.locator('dialog#lightbox')).toBeVisible();
82+
83+
const firstRowCounter = page.locator('.lightbox-row-counter').first();
84+
85+
await expect(firstRowCounter).toHaveText('Row 1 / 4');
86+
87+
await page.keyboard.press('ArrowDown');
88+
await expect(firstRowCounter).toHaveText('Row 2 / 4');
89+
90+
await page.keyboard.press('ArrowDown');
91+
await expect(firstRowCounter).toHaveText('Row 3 / 4');
92+
93+
await page.keyboard.press('ArrowDown');
94+
await expect(firstRowCounter).toHaveText('Row 4 / 4');
95+
96+
await page.keyboard.press('ArrowDown');
97+
await expect(firstRowCounter).toHaveText('Row 1 / 4');
98+
99+
await page.keyboard.press('ArrowUp');
100+
await expect(firstRowCounter).toHaveText('Row 4 / 4');
101+
102+
await page.keyboard.press('ArrowUp');
103+
await expect(firstRowCounter).toHaveText('Row 3 / 4');
104+
105+
await page.keyboard.press('ArrowUp');
106+
await expect(firstRowCounter).toHaveText('Row 2 / 4');
107+
108+
await page.keyboard.press('ArrowUp');
109+
await expect(firstRowCounter).toHaveText('Row 1 / 4');
110+
});
111+
112+
test('show temporary modals when wrapping top <-> bottom', async ({ page }) => {
113+
await page.goto(reportUrl);
114+
115+
await page.locator('.diff-images button').first().click();
116+
await expect(page.locator('dialog#lightbox')).toBeVisible();
117+
118+
const firstRowCounter = page.locator('.lightbox-row-counter').first();
119+
120+
await expect(firstRowCounter).toHaveText('Row 1 / 4');
121+
122+
await page.keyboard.press('ArrowUp');
123+
await expect(firstRowCounter).toHaveText('Row 4 / 4');
124+
await expect(page.getByRole('dialog').filter({ hasText: /^Wrapped to bottom$/ })).toBeVisible();
125+
126+
await page.keyboard.press('ArrowDown');
127+
await expect(firstRowCounter).toHaveText('Row 1 / 4');
128+
await expect(page.getByRole('dialog').filter({ hasText: /^Wrapped to top$/ })).toBeVisible();
129+
});

0 commit comments

Comments
 (0)