Skip to content

Commit 7c90a63

Browse files
committed
screenshots
1 parent 61c4eba commit 7c90a63

21 files changed

+140
-16
lines changed

special-pages/pages/history/app/components/Item.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ export const Item = memo(
5454
<a href={props.url} data-url={props.url} class={styles.entryLink}>
5555
{title}
5656
</a>
57-
<span class={styles.domain}>{props.domain}</span>
57+
<span class={styles.domain} data-testid="Item.domain">
58+
{props.domain}
59+
</span>
5860
<span class={styles.time}>{dateTimeOfDay}</span>
5961
<button class={styles.dots} data-action={BTN_ACTION_ENTRIES_MENU} data-index={index} value={props.id} tabindex={0}>
6062
<Dots />

special-pages/pages/history/app/components/SearchForm.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export function SearchForm({ term, domain }) {
5252
autoComplete="off"
5353
type="search"
5454
spellcheck={false}
55-
autoFocus
5655
placeholder={t('search')}
5756
value={value}
5857
onInput={input}

special-pages/pages/history/app/components/Sidebar.module.css

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
.stack {
22
display: flex;
33
flex-direction: column;
4-
> * { min-width: 0 }
4+
> * {
5+
min-width: 0
6+
}
57
gap: 24px;
68
}
79
.pageTitle {
@@ -37,7 +39,12 @@
3739
color: var(--history-text-normal);
3840
gap: 6px;
3941
}
40-
42+
.active {
43+
background: var(--color-black-at-12);
44+
[data-theme="dark"] & {
45+
background: var(--color-white-at-9);
46+
}
47+
}
4148
.delete {
4249
height: 40px;
4350
width: 40px;
@@ -60,6 +67,7 @@
6067
background: var(--color-black-at-9);
6168
opacity: 1;
6269
}
70+
6371
&:active {
6472
background: var(--color-black-at-12);
6573
}
@@ -91,13 +99,6 @@
9199
cursor: default;
92100
}
93101

94-
.active {
95-
background: var(--color-black-at-6);
96-
[data-theme="dark"] & {
97-
background: var(--color-white-at-6);
98-
}
99-
}
100-
101102
.icon {
102103
width: 16px;
103104
height: 16px;

special-pages/pages/history/app/global-state/QueryProvider.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ function useURLReflection(queryState, settings) {
173173
let count = 0;
174174
const unsubscribe = queryState.subscribe((nextValue) => {
175175
if (count === 0) return (count += 1);
176-
console.log('ere?', nextValue);
177176
clearTimeout(timer);
178177
if (nextValue.term !== null) {
179178
const term = nextValue.term;

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

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ export class HistoryTestPage {
100100
async darkMode() {
101101
await this.page.emulateMedia({ colorScheme: 'dark' });
102102
}
103+
async lightMode() {
104+
await this.page.emulateMedia({ colorScheme: 'light' });
105+
}
103106

104107
/**
105108
* @param {import('../types/history.ts').QueryKind} query
@@ -313,11 +316,27 @@ export class HistoryTestPage {
313316
const { page } = this;
314317
const rows = page.locator('main').locator('[aria-selected]');
315318
const selected = page.locator('main').locator('[aria-selected="true"]');
316-
await rows.nth(nth).click();
319+
await rows.nth(nth).getByTestId('Item.domain').click();
317320
await expect(rows.nth(nth)).toHaveAttribute('aria-selected', 'true');
318321
await expect(selected).toHaveCount(1);
319322
}
320323

324+
/**
325+
* @param {number} nth
326+
*/
327+
async hoversRowIndex(nth) {
328+
const rows = this.page.locator('main').locator('[aria-selected]');
329+
await rows.nth(nth).hover();
330+
await rows.nth(nth).locator('[data-action="entries_menu"]').waitFor({ state: 'visible' });
331+
}
332+
/**
333+
* @param {number} nth
334+
*/
335+
async hoversRowIndexBtn(nth) {
336+
const rows = this.page.locator('main').locator('[aria-selected]');
337+
await rows.nth(nth).locator('[data-action="entries_menu"]').hover();
338+
}
339+
321340
/**
322341
* @param {number} nth
323342
*/
@@ -342,15 +361,21 @@ export class HistoryTestPage {
342361
async selectsRowWithCtrl(nth) {
343362
const { page } = this;
344363
const rows = page.locator('main').locator('[aria-selected]');
345-
await rows.nth(nth).click({ modifiers: ['Meta'] });
364+
await rows
365+
.nth(nth)
366+
.getByTestId('Item.domain')
367+
.click({ modifiers: ['Meta'] });
346368
}
347369
/**
348370
* @param {number} nth
349371
*/
350372
async selectsRowIndexWithShift(nth) {
351373
const { page } = this;
352374
const rows = page.locator('main').locator('[aria-selected]');
353-
await rows.nth(nth).click({ modifiers: ['Shift'] });
375+
await rows
376+
.nth(nth)
377+
.getByTestId('Item.domain')
378+
.click({ modifiers: ['Shift'] });
354379
}
355380

356381
/**
@@ -452,4 +477,20 @@ export class HistoryTestPage {
452477
const rowCount = await rows.count();
453478
expect(rowCount).toBe(count);
454479
}
480+
481+
sidebar() {
482+
return this.page.locator('aside');
483+
}
484+
485+
main() {
486+
return this.page.locator('main');
487+
}
488+
489+
async hoversRange(range) {
490+
await this.page.getByLabel(`Show history for ${range}`).hover();
491+
}
492+
async hoversRangeDelete(range) {
493+
// await this.page.pause();
494+
await this.page.getByRole('button', { name: `Delete history for ${range}` }).hover();
495+
}
455496
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/* global process */
2+
import { expect, test } from '@playwright/test';
3+
import { HistoryTestPage } from './history.page.js';
4+
5+
const maxDiffPixels = 20;
6+
7+
test.describe('full history screenshots', { tag: ['@screenshots'] }, () => {
8+
test.use({ viewport: { width: 1080, height: 500 } });
9+
test.skip(process.env.CI === 'true');
10+
test('empty state', async ({ page }, workerInfo) => {
11+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(0);
12+
await hp.openPage();
13+
await hp.didMakeInitialQueries({ term: '' });
14+
await expect(page).toHaveScreenshot('full.empty.light.png', { maxDiffPixels });
15+
await hp.darkMode();
16+
await expect(page).toHaveScreenshot('full.empty.dark.png', { maxDiffPixels });
17+
});
18+
test('short list (3 items)', async ({ page }, workerInfo) => {
19+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(3);
20+
await hp.openPage();
21+
await expect(page).toHaveScreenshot('full.short.light.png', { maxDiffPixels });
22+
await hp.darkMode();
23+
await expect(page).toHaveScreenshot('full.short.dark.png', { maxDiffPixels });
24+
});
25+
});
26+
27+
test.describe('history sidebar screenshots', { tag: ['@screenshots'] }, () => {
28+
test.use({ viewport: { width: 1080, height: 400 } });
29+
test.skip(process.env.CI === 'true');
30+
test('sidebar active/hover', async ({ page }, workerInfo) => {
31+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(3);
32+
await hp.openPage();
33+
await hp.selectsToday();
34+
await hp.hoversRange('yesterday');
35+
await expect(hp.sidebar()).toHaveScreenshot('sidebar.light.png', { maxDiffPixels });
36+
await hp.darkMode();
37+
await expect(hp.sidebar()).toHaveScreenshot('sidebar.dark.png', { maxDiffPixels });
38+
39+
await hp.lightMode();
40+
await hp.hoversRangeDelete('yesterday');
41+
await expect(hp.sidebar()).toHaveScreenshot('sidebar.delete.light.png', { maxDiffPixels });
42+
43+
await hp.darkMode();
44+
await expect(hp.sidebar()).toHaveScreenshot('sidebar.delete.dark.png', { maxDiffPixels });
45+
});
46+
});
47+
48+
test.describe('history item selections', { tag: ['@screenshots'] }, () => {
49+
test.use({ viewport: { width: 1080, height: 400 } });
50+
test.skip(process.env.CI === 'true');
51+
test('main selecting', async ({ page }, workerInfo) => {
52+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(12);
53+
await hp.openPage();
54+
await hp.didMakeNthQuery({ nth: 0, query: { term: '' } });
55+
await hp.selectsRowIndex(1);
56+
await hp.selectsRowIndexWithShift(3);
57+
await hp.hoversRowIndex(1);
58+
await expect(hp.main()).toHaveScreenshot('main.select.light.png', { maxDiffPixels });
59+
await hp.darkMode();
60+
await expect(hp.main()).toHaveScreenshot('main.select.dark.png', { maxDiffPixels });
61+
});
62+
test('main hover', async ({ page }, workerInfo) => {
63+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(12);
64+
await hp.openPage();
65+
await hp.didMakeNthQuery({ nth: 0, query: { term: '' } });
66+
await hp.hoversRowIndex(0);
67+
await expect(hp.main()).toHaveScreenshot('main.hover.light.png', { maxDiffPixels });
68+
await hp.darkMode();
69+
await expect(hp.main()).toHaveScreenshot('main.hover.dark.png', { maxDiffPixels });
70+
});
71+
test('main selection + hover', async ({ page }, workerInfo) => {
72+
const hp = HistoryTestPage.create(page, workerInfo).withEntries(12);
73+
await hp.openPage();
74+
await hp.didMakeNthQuery({ nth: 0, query: { term: '' } });
75+
await hp.selectsRowIndex(1);
76+
await hp.hoversRowIndexBtn(1);
77+
await expect(hp.main()).toHaveScreenshot('main.select+hover.light.png', { maxDiffPixels });
78+
await hp.darkMode();
79+
await expect(hp.main()).toHaveScreenshot('main.select+hover.dark.png', { maxDiffPixels });
80+
});
81+
});

special-pages/playwright.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ export default defineConfig({
3232
'customizer.spec.js',
3333
'activity.spec.js',
3434
'history.spec.js',
35-
'history-selections.spec.js'
35+
'history-selections.spec.js',
36+
'history.screenshots.spec.js',
3637
],
3738
use: {
3839
...devices['Desktop Chrome'],

0 commit comments

Comments
 (0)