Skip to content

Commit c86cc1d

Browse files
authored
history screenshots (#1511)
1 parent e78b829 commit c86cc1d

23 files changed

+140
-2
lines changed

special-pages/pages/history/integration-tests/history.page.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,28 @@ export class HistoryTestPage {
353353
await expect(selected).toHaveCount(1);
354354
}
355355

356+
/**
357+
* @param {number} nth
358+
*/
359+
async hoversRowIndex(nth) {
360+
const rows = this.page.locator('main').locator('[aria-selected]');
361+
await rows.nth(nth).hover();
362+
await rows.nth(nth).locator('[data-action="entries_menu"]').waitFor({ state: 'visible' });
363+
}
364+
/**
365+
* @param {number} nth
366+
*/
367+
async hoversRowIndexBtn(nth) {
368+
const rows = this.page.locator('main').locator('[aria-selected]');
369+
await rows.nth(nth).locator('[data-action="entries_menu"]').hover();
370+
}
371+
/**
372+
*
373+
*/
374+
async hoversDeleteAllBtn() {
375+
await this.page.getByRole('button', { name: 'Delete All', exact: true }).hover();
376+
}
377+
356378
/**
357379
* @param {number} nth
358380
*/
@@ -532,6 +554,14 @@ export class HistoryTestPage {
532554
return this.page.locator('header');
533555
}
534556

557+
async hoversRange(range) {
558+
await this.page.getByLabel(`Show history for ${range}`).hover();
559+
}
560+
async hoversRangeDelete(range) {
561+
// await this.page.pause();
562+
await this.page.getByRole('button', { name: `Delete history for ${range}` }).hover();
563+
}
564+
535565
/**
536566
* @param {number[]} indexes
537567
*/
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import { expect, test } from '@playwright/test';
2+
import { HistoryTestPage } from './history.page.js';
3+
4+
const maxDiffPixels = 20;
5+
6+
test.describe('full history screenshots', { tag: ['@screenshots'] }, () => {
7+
test.use({ viewport: { width: 1080, height: 500 } });
8+
test('empty state', async ({ page }, workerInfo) => {
9+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(0);
10+
await hp.openPage();
11+
await hp.didMakeInitialQueries({ term: '' });
12+
await expect(page).toHaveScreenshot('full.empty.light.png', { maxDiffPixels });
13+
await hp.darkMode();
14+
await expect(page).toHaveScreenshot('full.empty.dark.png', { maxDiffPixels });
15+
});
16+
test('short list (3 items)', async ({ page }, workerInfo) => {
17+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(3);
18+
await hp.openPage();
19+
await expect(page).toHaveScreenshot('full.short.light.png', { maxDiffPixels });
20+
await hp.darkMode();
21+
await expect(page).toHaveScreenshot('full.short.dark.png', { maxDiffPixels });
22+
});
23+
});
24+
25+
test.describe('history sidebar screenshots', { tag: ['@screenshots'] }, () => {
26+
test.use({ viewport: { width: 1080, height: 400 } });
27+
test('sidebar active/hover', async ({ page }, workerInfo) => {
28+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(3);
29+
await hp.openPage();
30+
await hp.selectsToday();
31+
await hp.hoversRange('yesterday');
32+
await expect(hp.sidebar()).toHaveScreenshot('sidebar.light.png', { maxDiffPixels });
33+
await hp.darkMode();
34+
await expect(hp.sidebar()).toHaveScreenshot('sidebar.dark.png', { maxDiffPixels });
35+
36+
await hp.lightMode();
37+
await hp.hoversRangeDelete('yesterday');
38+
await expect(hp.sidebar()).toHaveScreenshot('sidebar.delete.light.png', { maxDiffPixels });
39+
40+
await hp.darkMode();
41+
await expect(hp.sidebar()).toHaveScreenshot('sidebar.delete.dark.png', { maxDiffPixels });
42+
});
43+
});
44+
45+
test.describe('history item selections', { tag: ['@screenshots'] }, () => {
46+
test.use({ viewport: { width: 1080, height: 400 } });
47+
test('main selecting', async ({ page }, workerInfo) => {
48+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(12);
49+
await hp.openPage();
50+
await hp.didMakeNthQuery({ nth: 0, query: { term: '' }, source: 'initial' });
51+
await hp.selectsRowIndex(1);
52+
await hp.selectsRowIndexWithShift(3);
53+
await hp.hoversRowIndex(1);
54+
await expect(hp.main()).toHaveScreenshot('main.select.light.png', { maxDiffPixels });
55+
await hp.darkMode();
56+
await expect(hp.main()).toHaveScreenshot('main.select.dark.png', { maxDiffPixels });
57+
});
58+
test('main hover', async ({ page }, workerInfo) => {
59+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(12);
60+
await hp.openPage();
61+
await hp.didMakeNthQuery({ nth: 0, query: { term: '' }, source: 'initial' });
62+
await hp.hoversRowIndex(0);
63+
await expect(hp.main()).toHaveScreenshot('main.hover.light.png', { maxDiffPixels });
64+
await hp.darkMode();
65+
await expect(hp.main()).toHaveScreenshot('main.hover.dark.png', { maxDiffPixels });
66+
});
67+
test('main selection + hover', async ({ page }, workerInfo) => {
68+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(12);
69+
await hp.openPage();
70+
await hp.didMakeNthQuery({ nth: 0, query: { term: '' }, source: 'initial' });
71+
await hp.selectsRowIndex(1);
72+
await hp.hoversRowIndexBtn(1);
73+
await expect(hp.main()).toHaveScreenshot('main.select+hover.light.png', { maxDiffPixels });
74+
await hp.darkMode();
75+
await expect(hp.main()).toHaveScreenshot('main.select+hover.dark.png', { maxDiffPixels });
76+
});
77+
});
78+
79+
test.describe('history header', { tag: ['@screenshots'] }, () => {
80+
test.use({ viewport: { width: 1080, height: 400 } });
81+
test('idle header', async ({ page }, workerInfo) => {
82+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(12);
83+
await hp.openPage();
84+
await hp.didMakeNthQuery({ nth: 0, query: { term: '' }, source: 'initial' });
85+
await expect(hp.header()).toHaveScreenshot('header.idle.light.png', { maxDiffPixels });
86+
await hp.darkMode();
87+
await expect(hp.header()).toHaveScreenshot('header.idle.dark.png', { maxDiffPixels });
88+
});
89+
test('search', async ({ page }, workerInfo) => {
90+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(12);
91+
await hp.openPage();
92+
await hp.didMakeNthQuery({ nth: 0, query: { term: '' }, source: 'initial' });
93+
await hp.types('example.com');
94+
await expect(hp.header()).toHaveScreenshot('header.search.light.png', { maxDiffPixels });
95+
await hp.darkMode();
96+
await expect(hp.header()).toHaveScreenshot('header.search.dark.png', { maxDiffPixels });
97+
});
98+
test('delete button', async ({ page }, workerInfo) => {
99+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(12);
100+
await hp.openPage();
101+
await hp.didMakeNthQuery({ nth: 0, query: { term: '' }, source: 'initial' });
102+
await hp.hoversDeleteAllBtn();
103+
await expect(hp.header()).toHaveScreenshot('header.delete.light.png', { maxDiffPixels });
104+
await hp.darkMode();
105+
await expect(hp.header()).toHaveScreenshot('header.delete.dark.png', { maxDiffPixels });
106+
});
107+
});
27.2 KB
Loading
27.5 KB
Loading
44.9 KB
Loading
45.6 KB
Loading
3 KB
Loading
3.22 KB
Loading
2.96 KB
Loading
3.1 KB
Loading

0 commit comments

Comments
 (0)