Skip to content

Commit 3b7af15

Browse files
committed
Screenshot tests for Special Error Page
1 parent f7c8123 commit 3b7af15

File tree

57 files changed

+168
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+168
-13
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/* global process */
2+
import { expect, test } from '@playwright/test';
3+
import { SpecialErrorPage } from './special-error';
4+
5+
const maxDiffPixels = 20;
6+
7+
test.describe('screenshots @screenshots', () => {
8+
test.skip(process.env.CI === 'true');
9+
10+
test('SSL expired cert error', async ({ page }, workerInfo) => {
11+
const special = SpecialErrorPage.create(page, workerInfo);
12+
await special.openPage({ errorId: 'ssl.expired' });
13+
await expect(page).toHaveScreenshot('ssl-expired-cert.png', { maxDiffPixels });
14+
});
15+
16+
test('SSL expired cert error with advanced info', async ({ page }, workerInfo) => {
17+
const special = SpecialErrorPage.create(page, workerInfo);
18+
await special.openPage({ errorId: 'ssl.expired' });
19+
await special.showsAdvancedInfo();
20+
await expect(page).toHaveScreenshot('ssl-expired-cert-advanced.png', { maxDiffPixels });
21+
});
22+
23+
test('SSL expired cert error in Polish', async ({ page }, workerInfo) => {
24+
const special = SpecialErrorPage.create(page, workerInfo);
25+
await special.openPage({ errorId: 'ssl.expired', locale: 'pl' });
26+
await expect(page).toHaveScreenshot('ssl-expired-cert-pl.png', { maxDiffPixels });
27+
});
28+
29+
test('SSL expired cert error with reduced motion', async ({ page }, workerInfo) => {
30+
const special = SpecialErrorPage.create(page, workerInfo);
31+
await special.reducedMotion();
32+
await special.openPage({ errorId: 'ssl.expired' });
33+
await special.showsAdvancedInfo();
34+
await expect(page).toHaveScreenshot('ssl-expired-cert-reduced-motion.png', { maxDiffPixels });
35+
});
36+
37+
test('SSL invalid cert error', async ({ page }, workerInfo) => {
38+
const special = SpecialErrorPage.create(page, workerInfo);
39+
await special.openPage({ errorId: 'ssl.invalid' });
40+
await expect(page).toHaveScreenshot('ssl-invalid-cert.png', { maxDiffPixels });
41+
});
42+
43+
test('SSL invalid cert error in Dutch', async ({ page }, workerInfo) => {
44+
const special = SpecialErrorPage.create(page, workerInfo);
45+
await special.openPage({ errorId: 'ssl.invalid', locale: 'nl' });
46+
await expect(page).toHaveScreenshot('ssl-invalid-cert-nl.png', { maxDiffPixels });
47+
});
48+
49+
test('SSL self signed cert error', async ({ page }, workerInfo) => {
50+
const special = SpecialErrorPage.create(page, workerInfo);
51+
await special.openPage({ errorId: 'ssl.selfSigned' });
52+
await expect(page).toHaveScreenshot('ssl-self-signed-cert.png', { maxDiffPixels });
53+
});
54+
55+
test('SSL self signed cert error in Spanish', async ({ page }, workerInfo) => {
56+
const special = SpecialErrorPage.create(page, workerInfo);
57+
await special.openPage({ errorId: 'ssl.selfSigned', locale: 'es' });
58+
await expect(page).toHaveScreenshot('ssl-self-signed-cert-es.png', { maxDiffPixels });
59+
});
60+
61+
test('SSL wrong host error', async ({ page }, workerInfo) => {
62+
const special = SpecialErrorPage.create(page, workerInfo);
63+
await special.openPage({ errorId: 'ssl.wrongHost' });
64+
await expect(page).toHaveScreenshot('ssl-wrong-host.png', { maxDiffPixels });
65+
});
66+
67+
test('SSL wrong host error in Romanian', async ({ page }, workerInfo) => {
68+
const special = SpecialErrorPage.create(page, workerInfo);
69+
await special.openPage({ errorId: 'ssl.wrongHost', locale: 'ro' });
70+
await expect(page).toHaveScreenshot('ssl-wrong-host-ro.png', { maxDiffPixels });
71+
});
72+
73+
test('Phishing warning', async ({ page }, workerInfo) => {
74+
const special = SpecialErrorPage.create(page, workerInfo);
75+
await special.openPage({ errorId: 'phishing' });
76+
await expect(page).toHaveScreenshot('phishing-warning.png', { maxDiffPixels });
77+
});
78+
79+
test('Phishing warning with advanced info', async ({ page }, workerInfo) => {
80+
const special = SpecialErrorPage.create(page, workerInfo);
81+
await special.openPage({ errorId: 'phishing' });
82+
await special.showsAdvancedInfo();
83+
await expect(page).toHaveScreenshot('phishing-warning-advanced.png', { maxDiffPixels });
84+
});
85+
86+
test('Phishing warning with reduced motion', async ({ page }, workerInfo) => {
87+
const special = SpecialErrorPage.create(page, workerInfo);
88+
await special.reducedMotion();
89+
await special.openPage({ errorId: 'phishing' });
90+
await special.showsAdvancedInfo();
91+
await expect(page).toHaveScreenshot('phishing-warning-advanced.png', { maxDiffPixels });
92+
});
93+
94+
test('Phishing warning in Portuguese', async ({ page }, workerInfo) => {
95+
const special = SpecialErrorPage.create(page, workerInfo);
96+
await special.openPage({ errorId: 'phishing', locale: 'pt' });
97+
await expect(page).toHaveScreenshot('phishing-warning-pt.png', { maxDiffPixels });
98+
});
99+
100+
test('Phishing warning with advanced info in Bulgarian', async ({ page }, workerInfo) => {
101+
const special = SpecialErrorPage.create(page, workerInfo);
102+
await special.openPage({ errorId: 'phishing', locale: 'bg' });
103+
await special.showsAdvancedInfo('Разширени');
104+
await expect(page).toHaveScreenshot('phishing-warning-advanced-bg.png', { maxDiffPixels });
105+
});
106+
107+
test('Malware warning', async ({ page }, workerInfo) => {
108+
const special = SpecialErrorPage.create(page, workerInfo);
109+
await special.openPage({ errorId: 'malware' });
110+
await expect(page).toHaveScreenshot('malware-warning.png', { maxDiffPixels });
111+
});
112+
113+
test('Malware warning with advanced info', async ({ page }, workerInfo) => {
114+
const special = SpecialErrorPage.create(page, workerInfo);
115+
await special.openPage({ errorId: 'malware' });
116+
await special.showsAdvancedInfo();
117+
await expect(page).toHaveScreenshot('malware-warning-advanced.png', { maxDiffPixels });
118+
});
119+
120+
test('Malware warning in Russian', async ({ page }, workerInfo) => {
121+
const special = SpecialErrorPage.create(page, workerInfo);
122+
await special.openPage({ errorId: 'malware', locale: 'ru' });
123+
await expect(page).toHaveScreenshot('malware-warning-ru.png', { maxDiffPixels });
124+
});
125+
126+
test('Malware warning with advanced info in German', async ({ page }, workerInfo) => {
127+
const special = SpecialErrorPage.create(page, workerInfo);
128+
await special.openPage({ errorId: 'malware', locale: 'de' });
129+
await special.showsAdvancedInfo('Erweitert');
130+
await expect(page).toHaveScreenshot('malware-warning-advanced-de.png', { maxDiffPixels });
131+
});
132+
});

special-pages/pages/special-error/integration-tests/special-error.js

+22-10
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export class SpecialErrorPage {
9494
*/
9595
get basePath() {
9696
return this.build.switch({
97+
windows: () => '../build/windows/pages/special-error',
9798
apple: () => '../Sources/ContentScopeScripts/dist/pages/special-error',
9899
});
99100
}
@@ -151,8 +152,7 @@ export class SpecialErrorPage {
151152
async showsExpiredPage() {
152153
const { page } = this;
153154

154-
const title = await page.locator('title').textContent();
155-
expect(title).toBe('Warning: This site may be insecure');
155+
this.showsPageTitle('Warning: This site may be insecure');
156156

157157
await expect(page.getByText('Warning: This site may be insecure', { exact: true })).toBeVisible();
158158
await expect(
@@ -161,6 +161,7 @@ export class SpecialErrorPage {
161161
{ exact: true },
162162
),
163163
).toBeVisible();
164+
164165
await this.showsAdvancedInfo();
165166
await expect(page.getByText('DuckDuckGo warns you when a website has an invalid certificate.', { exact: true })).toBeVisible();
166167
await expect(
@@ -171,6 +172,17 @@ export class SpecialErrorPage {
171172
).toBeVisible();
172173
}
173174

175+
/**
176+
*
177+
* @param {string} pageTitle
178+
*/
179+
async showsPageTitle(pageTitle) {
180+
const { page } = this;
181+
182+
const title = await page.locator('title').textContent();
183+
expect(title).toBe(pageTitle);
184+
}
185+
174186
async showsExpiredPageInPolish() {
175187
const { page } = this;
176188
await expect(page.getByRole('heading')).toContainText('Ostrzeżenie: ta witryna może być niebezpieczna');
@@ -179,8 +191,7 @@ export class SpecialErrorPage {
179191
async showsInvalidPage() {
180192
const { page } = this;
181193

182-
const title = await page.locator('title').textContent();
183-
expect(title).toBe('Warning: This site may be insecure');
194+
this.showsPageTitle('Warning: This site may be insecure');
184195

185196
await expect(page.getByText('Warning: This site may be insecure', { exact: true })).toBeVisible();
186197
await expect(
@@ -202,8 +213,7 @@ export class SpecialErrorPage {
202213
async showsSelfSignedPage() {
203214
const { page } = this;
204215

205-
const title = await page.locator('title').textContent();
206-
expect(title).toBe('Warning: This site may be insecure');
216+
this.showsPageTitle('Warning: This site may be insecure');
207217

208218
await expect(page.getByText('Warning: This site may be insecure', { exact: true })).toBeVisible();
209219
await expect(
@@ -225,8 +235,7 @@ export class SpecialErrorPage {
225235
async showsWrongHostPage() {
226236
const { page } = this;
227237

228-
const title = await page.locator('title').textContent();
229-
expect(title).toBe('Warning: This site may be insecure');
238+
this.showsPageTitle('Warning: This site may be insecure');
230239

231240
await expect(page.getByText('Warning: This site may be insecure', { exact: true })).toBeVisible();
232241
await expect(
@@ -291,10 +300,13 @@ export class SpecialErrorPage {
291300

292301
/**
293302
* Clicks on advanced link to show expanded info
303+
*
304+
* @param {string} [buttonTitle] Localized title of Advanced button
294305
*/
295-
async showsAdvancedInfo() {
306+
async showsAdvancedInfo(buttonTitle = 'Advanced') {
296307
const { page } = this;
297-
await page.getByRole('button', { name: 'Advanced...' }).click();
308+
await page.getByRole('button', { name: buttonTitle }).click();
309+
298310
const calls = await this.mocks.waitForCallCount({ method: 'advancedInfo', count: 1 });
299311
expect(calls).toMatchObject([
300312
{

special-pages/playwright.config.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ export default defineConfig({
55
projects: [
66
{
77
name: 'windows',
8-
testMatch: ['duckplayer.spec.js', 'duckplayer-screenshots.spec.js', 'onboarding.spec.js'],
8+
testMatch: [
9+
'duckplayer.spec.js',
10+
'duckplayer-screenshots.spec.js',
11+
'onboarding.spec.js',
12+
'special-error.spec.js',
13+
'special-error-screenshots.spec.js',
14+
],
915
use: {
1016
...devices['Desktop Edge'],
1117
injectName: 'windows',
@@ -40,9 +46,9 @@ export default defineConfig({
4046
'duckplayer.spec.js',
4147
'duckplayer-screenshots.spec.js',
4248
'onboarding.spec.js',
43-
'sslerror.spec.js',
4449
'release-notes.spec.js',
4550
'special-error.spec.js',
51+
'special-error-screenshots.spec.js',
4652
],
4753
use: {
4854
...devices['Desktop Safari'],
@@ -70,7 +76,12 @@ export default defineConfig({
7076
},
7177
{
7278
name: 'ios',
73-
testMatch: ['duckplayer.spec.js', 'duckplayer-screenshots.spec.js'],
79+
testMatch: [
80+
'duckplayer.spec.js',
81+
'duckplayer-screenshots.spec.js',
82+
'special-error.spec.js',
83+
'special-error-screenshots.spec.js',
84+
],
7485
use: {
7586
...devices['iPhone 14'],
7687
injectName: 'apple',

0 commit comments

Comments
 (0)