Skip to content

Commit

Permalink
Link tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mgurgel committed Dec 2, 2024
1 parent 6c6fe47 commit 1bf9c00
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 27 deletions.
10 changes: 10 additions & 0 deletions integration-tests/DashboardPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ export class DashboardPage {
await page.locator('[data-page="connection"]').getByText(text).waitFor();
}

async clickReportAsSafeLink() {
const { page } = this;
await expect(page.getByRole('link', { name: 'Report a site as safe' })).toBeVisible();
}

async clickHelpPageLink() {
const { page } = this;
await page.getByRole('link', { name: 'About our phishing and malware protection' }).click()
}

async hasPhishingIcon() {
const { page } = this;
await expect(page.locator('#key-insight div').nth(1)).toHaveClass(/hero-icon--phishing/);
Expand Down
20 changes: 14 additions & 6 deletions integration-tests/Mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,14 +347,24 @@ export class Mocks {
}

async calledForAboutLink() {
return this.calledForOpenURLInNewTab('https://help.duckduckgo.com/duckduckgo-help-pages/privacy/web-tracking-protections/');
}

async calledForHelpPagesLink() {
return this.calledForOpenURLInNewTab('https://dub.duckduckgo.com/pages/duckduckgo/mgurgel-help-pages/privacy/phishing-and-malware-protection/');
}

async calledForReportAsSafeLink(urlParam) {
return this.calledForOpenURLInNewTab(`https://use-devtesting12.duckduckgo.com/malicious-site-protection/report-error?url=${encodeURIComponent(urlParam)}`);
}

async calledForOpenURLInNewTab(url) {
if (this.platform.name === 'android') {
const calls = await this.outgoing({ names: ['openInNewTab'] });
expect(calls).toMatchObject([
[
'openInNewTab',
JSON.stringify({
url: 'https://help.duckduckgo.com/duckduckgo-help-pages/privacy/web-tracking-protections/',
}),
JSON.stringify({ url }),
],
]);
return;
Expand All @@ -366,9 +376,7 @@ export class Mocks {
expect(calls).toMatchObject([
[
'privacyDashboardOpenUrlInNewTab',
{
url: 'https://help.duckduckgo.com/duckduckgo-help-pages/privacy/web-tracking-protections/',
},
{ url },
],
]);
return;
Expand Down
59 changes: 38 additions & 21 deletions integration-tests/macos.spec-int.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,45 @@ test('invalid/missing certificate', { tag: '@screenshots' }, async ({ page }) =>
await dash.showsInvalidCertDetail();
});

test('phishing warning', { tag: '@screenshots' }, async ({ page }) => {
/** @type {DashboardPage} */
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
await dash.addState([testDataStates.phishing]);
await dash.screenshot('phishing-warning.png');
await dash.hasPhishingIcon();
await dash.hasPhishingHeadingText();
await dash.hasPhishingWarningText();
await dash.hasPhishingStatusText();
await dash.connectionLinkDoesntShow();
});
test.describe('phishing & malware protection', () => {
test('phishing warning', { tag: '@screenshots' }, async ({ page }) => {
/** @type {DashboardPage} */
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
await dash.addState([testDataStates.phishing]);
await dash.screenshot('phishing-warning.png');
await dash.hasPhishingIcon();
await dash.hasPhishingHeadingText();
await dash.hasPhishingWarningText();
await dash.hasPhishingStatusText();
await dash.connectionLinkDoesntShow();
});

test('malware warning', { tag: '@screenshots' }, async ({ page }) => {
/** @type {DashboardPage} */
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
await dash.addState([testDataStates.malware]);
await dash.screenshot('malware-warning.png');
await dash.hasMalwareIcon();
await dash.hasMalwareHeadingText();
await dash.hasMalwareWarningText();
await dash.hasMalwareStatusText();
await dash.connectionLinkDoesntShow();
});

test('malware warning', { tag: '@screenshots' }, async ({ page }) => {
/** @type {DashboardPage} */
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
await dash.addState([testDataStates.malware]);
await dash.screenshot('malware-warning.png');
await dash.hasMalwareIcon();
await dash.hasMalwareHeadingText();
await dash.hasMalwareWarningText();
await dash.hasMalwareStatusText();
await dash.connectionLinkDoesntShow();
test('shows report as safe link', async ({ page }) => {
/** @type {DashboardPage} */
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
await dash.addState([testDataStates.malware]);
await dash.clickReportAsSafeLink();
});

test('shows help page link', async ({ page }) => {
/** @type {DashboardPage} */
const dash = await DashboardPage.webkit(page, { platform: 'macos' });
await dash.addState([testDataStates.malware]);
await dash.clickHelpPageLink();
await dash.mocks.calledForHelpPagesLink();
});
});

test('insecure certificate', async ({ page }) => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1bf9c00

Please sign in to comment.