Skip to content

Commit a3dec18

Browse files
authored
Malware status support and design updates - macOS (#250)
1 parent 7a987ae commit a3dec18

33 files changed

+339
-143
lines changed

Package.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,5 @@ let package = Package(
3030
.copy("app/img"),
3131
.copy ("app/public"),
3232
.copy ("app/index.html")]),
33-
34-
.testTarget(
35-
name: "PrivacyDashboardTests",
36-
dependencies: ["PrivacyDashboardResources"],
37-
path: "swift-package/Tests"),
3833
]
3934
)

integration-tests/DashboardPage.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ export class DashboardPage {
167167
await page.locator('[data-page="connection"]').getByText(text).waitFor();
168168
}
169169

170+
async clickReportAsSafeLink() {
171+
const { page } = this;
172+
await page.getByRole('link', { name: 'Report site as safe' }).click();
173+
}
174+
175+
async clickHelpPageLink() {
176+
const { page } = this;
177+
await page.getByRole('link', { name: 'About our phishing and malware protection' }).click();
178+
}
179+
170180
async hasPhishingIcon() {
171181
const { page } = this;
172182
await expect(page.locator('#key-insight div').nth(1)).toHaveClass(/hero-icon--phishing/);
@@ -189,6 +199,28 @@ export class DashboardPage {
189199
await expect(page.locator('#main-nav div')).toContainText('Site May Be Deceptive');
190200
}
191201

202+
async hasMalwareIcon() {
203+
const { page } = this;
204+
await expect(page.locator('#key-insight div').nth(1)).toHaveClass(/hero-icon--phishing/);
205+
}
206+
207+
async hasMalwareHeadingText() {
208+
const { page } = this;
209+
await expect(page.getByRole('heading', { name: 'privacy-test-pages.site' })).toBeVisible();
210+
}
211+
212+
async hasMalwareWarningText() {
213+
const { page } = this;
214+
await expect(page.locator('#popup-container')).toContainText(
215+
'This site has been flagged for distributing malware designed to compromise your device or steal your personal information.'
216+
);
217+
}
218+
219+
async hasMalwareStatusText() {
220+
const { page } = this;
221+
await expect(page.locator('#main-nav div')).toContainText('Site May Be Deceptive');
222+
}
223+
192224
async connectionLinkDoesntShow() {
193225
await expect(this.connectInfoLink()).not.toBeVisible();
194226
}

integration-tests/Mocks.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -347,30 +347,31 @@ export class Mocks {
347347
}
348348

349349
async calledForAboutLink() {
350+
return this.calledForOpenURLInNewTab('https://help.duckduckgo.com/duckduckgo-help-pages/privacy/web-tracking-protections/');
351+
}
352+
353+
async calledForHelpPagesLink() {
354+
return this.calledForOpenURLInNewTab('https://duckduckgo.com/duckduckgo-help-pages/privacy/phishing-and-malware-protection/');
355+
}
356+
357+
async calledForReportAsSafeLink(urlParam) {
358+
const url = new URL('https://duckduckgo.com/malicious-site-protection/report-error');
359+
url.searchParams.set('url', urlParam);
360+
361+
return this.calledForOpenURLInNewTab(url.toString());
362+
}
363+
364+
async calledForOpenURLInNewTab(url) {
350365
if (this.platform.name === 'android') {
351366
const calls = await this.outgoing({ names: ['openInNewTab'] });
352-
expect(calls).toMatchObject([
353-
[
354-
'openInNewTab',
355-
JSON.stringify({
356-
url: 'https://help.duckduckgo.com/duckduckgo-help-pages/privacy/web-tracking-protections/',
357-
}),
358-
],
359-
]);
367+
expect(calls).toMatchObject([['openInNewTab', JSON.stringify({ url })]]);
360368
return;
361369
}
362370
if (this.platform.name === 'macos' || this.platform.name === 'ios') {
363371
const calls = await this.outgoing({
364372
names: ['privacyDashboardOpenUrlInNewTab'],
365373
});
366-
expect(calls).toMatchObject([
367-
[
368-
'privacyDashboardOpenUrlInNewTab',
369-
{
370-
url: 'https://help.duckduckgo.com/duckduckgo-help-pages/privacy/web-tracking-protections/',
371-
},
372-
],
373-
]);
374+
expect(calls).toMatchObject([['privacyDashboardOpenUrlInNewTab', { url }]]);
374375
return;
375376
}
376377
throw new Error('unreachable. mockCalledForAboutLink must be handled');

integration-tests/macos.spec-int.js

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,46 @@ test('invalid/missing certificate', { tag: '@screenshots' }, async ({ page }) =>
3434
await dash.showsInvalidCertDetail();
3535
});
3636

37-
test('phishing warning', { tag: '@screenshots' }, async ({ page }) => {
38-
/** @type {DashboardPage} */
39-
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
40-
await dash.addState([testDataStates.phishing]);
41-
await dash.screenshot('phishing-warning.png');
42-
await dash.hasPhishingIcon();
43-
await dash.hasPhishingHeadingText();
44-
await dash.hasPhishingWarningText();
45-
await dash.hasPhishingStatusText();
46-
await dash.connectionLinkDoesntShow();
37+
test.describe('phishing & malware protection', () => {
38+
test('phishing warning', { tag: '@screenshots' }, async ({ page }) => {
39+
/** @type {DashboardPage} */
40+
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
41+
await dash.addState([testDataStates.phishing]);
42+
await dash.screenshot('phishing-warning.png');
43+
await dash.hasPhishingIcon();
44+
await dash.hasPhishingHeadingText();
45+
await dash.hasPhishingWarningText();
46+
await dash.hasPhishingStatusText();
47+
await dash.connectionLinkDoesntShow();
48+
});
49+
50+
test('malware warning', { tag: '@screenshots' }, async ({ page }) => {
51+
/** @type {DashboardPage} */
52+
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
53+
await dash.addState([testDataStates.malware]);
54+
await dash.screenshot('malware-warning.png');
55+
await dash.hasMalwareIcon();
56+
await dash.hasMalwareHeadingText();
57+
await dash.hasMalwareWarningText();
58+
await dash.hasMalwareStatusText();
59+
await dash.connectionLinkDoesntShow();
60+
});
61+
62+
test('shows report as safe link', async ({ page }) => {
63+
/** @type {DashboardPage} */
64+
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
65+
await dash.addState([testDataStates.malware]);
66+
await dash.clickReportAsSafeLink();
67+
await dash.mocks.calledForReportAsSafeLink('https://privacy-test-pages.site/security/badware/malware.html');
68+
});
69+
70+
test('shows help page link', async ({ page }) => {
71+
/** @type {DashboardPage} */
72+
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
73+
await dash.addState([testDataStates.malware]);
74+
await dash.clickHelpPageLink();
75+
await dash.mocks.calledForHelpPagesLink();
76+
});
4777
});
4878

4979
test('insecure certificate', async ({ page }) => {
Loading
Loading

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema/__generated__/schema.parsers.mjs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema/__generated__/schema.types.ts

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema/get-privacy-dashboard-data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
"localeSettings": {
5252
"$ref": "./locale.json"
5353
},
54-
"phishingStatus": {
55-
"$ref": "./phishing.json"
54+
"maliciousSiteStatus": {
55+
"$ref": "./malicious-site.json"
5656
},
5757
"parentEntity": { "$ref": "./parent-entity.json" },
5858
"specialDomainName": {

0 commit comments

Comments
 (0)