Skip to content

Commit 6389a7e

Browse files
authored
Add screenshot tests for omnibar widget states (#1868)
1 parent 7e1d052 commit 6389a7e

9 files changed

+91
-0
lines changed

special-pages/pages/new-tab/integration-tests/new-tab.screenshots.spec.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { NewtabPage } from './new-tab.page.js';
33
import { ActivityPage } from '../app/activity/integration-tests/activity.page.js';
44
import { CustomizerPage } from '../app/customizer/integration-tests/customizer.page.js';
55
import { PrivacyStatsPage } from '../app/privacy-stats/integration-tests/privacy-stats.page.js';
6+
import { OmnibarPage } from '../app/omnibar/integration-tests/omnibar.page.js';
67

78
const maxDiffPixels = 20;
89

@@ -85,4 +86,94 @@ test.describe('NTP screenshots', { tag: ['@screenshots'] }, () => {
8586
await expect(page).toHaveScreenshot('wide-default-drawer.png', { maxDiffPixels });
8687
});
8788
});
89+
90+
test.describe('omnibar widget screenshots', () => {
91+
// Extra tall viewport so that all of the suggestions list is visible
92+
test.use({ viewport: { width: 1000, height: 1000 } });
93+
94+
test.describe('search tab', () => {
95+
test('rest', async ({ page }, workerInfo) => {
96+
const ntp = NewtabPage.create(page, workerInfo);
97+
const omnibar = new OmnibarPage(ntp);
98+
await ntp.reducedMotion();
99+
await ntp.openPage({ additional: { omnibar: 'true' } });
100+
await omnibar.ready();
101+
await expect(page).toHaveScreenshot('omnibar-search-rest.png', { maxDiffPixels });
102+
});
103+
104+
test('focused', async ({ page }, workerInfo) => {
105+
const ntp = NewtabPage.create(page, workerInfo);
106+
const omnibar = new OmnibarPage(ntp);
107+
await ntp.reducedMotion();
108+
await ntp.openPage({ additional: { omnibar: 'true' } });
109+
await omnibar.ready();
110+
await omnibar.searchInput().click();
111+
await expect(page).toHaveScreenshot('omnibar-search-focused.png', { maxDiffPixels });
112+
});
113+
114+
test('suggestions', async ({ page }, workerInfo) => {
115+
const ntp = NewtabPage.create(page, workerInfo);
116+
const omnibar = new OmnibarPage(ntp);
117+
await ntp.reducedMotion();
118+
await ntp.openPage({ additional: { omnibar: 'true' } });
119+
await omnibar.ready();
120+
await omnibar.searchInput().fill('pizza');
121+
await omnibar.waitForSuggestions();
122+
await page.keyboard.press('ArrowDown');
123+
await expect(page).toHaveScreenshot('omnibar-search-suggestions.png', { maxDiffPixels });
124+
});
125+
});
126+
127+
test.describe('ai tab', () => {
128+
test('rest', async ({ page }, workerInfo) => {
129+
const ntp = NewtabPage.create(page, workerInfo);
130+
const omnibar = new OmnibarPage(ntp);
131+
await ntp.reducedMotion();
132+
await ntp.openPage({ additional: { omnibar: 'true', 'omnibar.mode': 'ai' } });
133+
await omnibar.ready();
134+
await expect(page).toHaveScreenshot('omnibar-ai-rest.png', { maxDiffPixels });
135+
});
136+
137+
test('focused', async ({ page }, workerInfo) => {
138+
const ntp = NewtabPage.create(page, workerInfo);
139+
const omnibar = new OmnibarPage(ntp);
140+
await ntp.reducedMotion();
141+
await ntp.openPage({ additional: { omnibar: 'true', 'omnibar.mode': 'ai' } });
142+
await omnibar.ready();
143+
await omnibar.chatInput().click();
144+
await expect(page).toHaveScreenshot('omnibar-ai-focused.png', { maxDiffPixels });
145+
});
146+
147+
test('expanded', async ({ page }, workerInfo) => {
148+
const ntp = NewtabPage.create(page, workerInfo);
149+
const omnibar = new OmnibarPage(ntp);
150+
await ntp.reducedMotion();
151+
await ntp.openPage({ additional: { omnibar: 'true', 'omnibar.mode': 'ai' } });
152+
await omnibar.ready();
153+
const multilineText = 'Line 1\nLine 2\nLine 3\nLine 4\nLine 5';
154+
await omnibar.chatInput().fill(multilineText);
155+
await expect(page).toHaveScreenshot('omnibar-ai-expanded.png', { maxDiffPixels });
156+
});
157+
158+
test('overflow', async ({ page }, workerInfo) => {
159+
const ntp = NewtabPage.create(page, workerInfo);
160+
const omnibar = new OmnibarPage(ntp);
161+
await ntp.reducedMotion();
162+
await ntp.openPage({ additional: { omnibar: 'true', 'omnibar.mode': 'ai' } });
163+
await omnibar.ready();
164+
const longText = Array.from({ length: 15 }, (_, i) => `Line ${i + 1}`).join('\n');
165+
await omnibar.chatInput().fill(longText);
166+
await expect(page).toHaveScreenshot('omnibar-ai-overflow.png', { maxDiffPixels });
167+
});
168+
});
169+
170+
test('ai disabled', async ({ page }, workerInfo) => {
171+
const ntp = NewtabPage.create(page, workerInfo);
172+
const omnibar = new OmnibarPage(ntp);
173+
await ntp.reducedMotion();
174+
await ntp.openPage({ additional: { omnibar: 'true', 'omnibar.enableAi': 'false' } });
175+
await omnibar.ready();
176+
await expect(page).toHaveScreenshot('omnibar-ai-disabled.png', { maxDiffPixels });
177+
});
178+
});
88179
});
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)