Skip to content

Commit 1ccdb82

Browse files
committed
Add Moscary-exercising functional tests
These tests create a new scan (for US users, for whom scans are available).
1 parent 4d43c4a commit 1ccdb82

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
import { test, expect } from "../fixtures/baseTest";
6+
import { test as authenticatedTest } from "../fixtures/authenticatedTest";
7+
import { getBaseTestEnvUrl } from "../utils/environment";
8+
9+
test.describe(`Verify authentication [${process.env.E2E_TEST_ENV}]`, () => {
10+
test.beforeEach(async ({ page }) => {
11+
// speed up test by ignoring non necessary requests
12+
await page.route(/(analytics)/, async (route) => {
13+
await route.abort();
14+
});
15+
await page.goto(`${getBaseTestEnvUrl()}/`);
16+
});
17+
18+
authenticatedTest(
19+
"non-US users are sent to the dashboard on first loding",
20+
async ({ page }, testInfo) => {
21+
if (testInfo.project.use.countryCode === "us") {
22+
return;
23+
}
24+
25+
const heading = page.getByRole("heading", {
26+
name: "Alle websites waarop uw gegevens zijn gelekt bekijken",
27+
});
28+
expect(heading).toBeVisible();
29+
},
30+
);
31+
32+
authenticatedTest(
33+
"US users go through an onboarding flow in which they enter details that we'll scan for at data brokers",
34+
async ({ page }, testInfo) => {
35+
if (testInfo.project.use.countryCode !== "us") {
36+
return;
37+
}
38+
if (process.env.CI && process.env.E2E_TEST_ENV === "local") {
39+
console.log(
40+
"Skipping onboarding test; backend is not set up in CI when running against a local server.",
41+
);
42+
return;
43+
}
44+
45+
await page.getByRole("button", { name: "Start my free scan" }).click();
46+
await page.getByLabel("First name").fill("John");
47+
await page.getByLabel("Last name").fill("Doe");
48+
await page.getByLabel("Date of birth").fill("1990-01-01");
49+
await page
50+
.getByRole("combobox", { name: "City and state" })
51+
.fill("New York");
52+
await page.getByRole("option", { name: "New YorkNY, USA" }).click();
53+
await page.getByRole("button", { name: "Find exposures" }).click();
54+
await page.getByRole("button", { name: "Confirm" }).press("Enter");
55+
56+
const progressBarRuntime = 60 * 1000;
57+
test.setTimeout(progressBarRuntime + 30 * 1000);
58+
// A scan takes 60 seconds, plus 5 seconds for the navigation back to the dashboard:
59+
await page.waitForURL("**/user/dashboard*", {
60+
timeout: progressBarRuntime + 5 * 1000,
61+
});
62+
await expect(
63+
page.getByRole("heading", {
64+
name: "View all sites where your",
65+
exact: false,
66+
}),
67+
).toBeVisible();
68+
},
69+
);
70+
});

0 commit comments

Comments
 (0)