Skip to content

Commit

Permalink
Merge pull request #5387 from mozilla/fix-e2e-settings
Browse files Browse the repository at this point in the history
Fix E2E test for settings redesign
  • Loading branch information
flozia authored Dec 9, 2024
2 parents 7d0bf27 + becef34 commit 861953d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/e2e/pages/settingsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class SettingsPage {
readonly settingsHeader: Locator;
readonly emailPrefHeader: Locator;
readonly emailHeader: Locator;
readonly tabNotifications: Locator;
readonly deleteHeader: Locator;
readonly deactivateHeader: Locator;
readonly addEmailButton: Locator;
Expand All @@ -25,6 +26,9 @@ export class SettingsPage {
this.settingsHeader = page.locator("h2").first();
this.emailPrefHeader = page.getByText(/Email preferences/);
this.emailHeader = page.getByText(/Monitored email addresses/);
this.tabNotifications = page.getByRole("tab", {
name: "Set notifications",
});
this.deleteHeader = page.getByText(/Delete ⁨Monitor⁩ account/);
this.deactivateHeader = page.getByText(/Deactivate account/);
this.addEmailButton = page.getByText(/Add email address/);
Expand Down
30 changes: 25 additions & 5 deletions src/e2e/specs/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,40 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { test, expect } from "../fixtures/basePage.js";
import { getEnabledFeatureFlags } from "../../db/tables/featureFlags.js";

// bypass login
test.use({ storageState: "./e2e/storageState.json" });
test.describe(`${process.env.E2E_TEST_ENV} Settings Page`, () => {
test("Verify settings page loads", async ({ settingsPage }) => {
const enabledFeatureFlags = await getEnabledFeatureFlags({
email: process.env.E2E_TEST_ACCOUNT_EMAIL as string,
isSignedOut: false,
});

// should go directly to data breach page
await settingsPage.open();
await expect(settingsPage.emailPrefHeader).toBeVisible();
await expect(settingsPage.emailHeader).toBeVisible();
(await settingsPage.deleteHeader.isVisible())
? await expect(settingsPage.deleteHeader).toBeVisible()
: await expect(settingsPage.deactivateHeader).toBeVisible();

await expect(settingsPage.settingsHeader).toBeVisible();
await expect(settingsPage.addEmailButton).toBeVisible();
await expect(settingsPage.emailHeader).toBeVisible();

if (!enabledFeatureFlags.includes("SettingsPageRedesign")) {
await expect(settingsPage.emailPrefHeader).toBeVisible();
(await settingsPage.deleteHeader.isVisible())
? await expect(settingsPage.deleteHeader).toBeVisible()
: await expect(settingsPage.deactivateHeader).toBeVisible();
}
});

test("Verify that a user can select between the Breach alert preferences", async ({
settingsPage,
}) => {
const enabledFeatureFlags = await getEnabledFeatureFlags({
email: process.env.E2E_TEST_ACCOUNT_EMAIL as string,
isSignedOut: false,
});

test.info().annotations.push({
type: "issue",
description:
Expand All @@ -30,6 +46,10 @@ test.describe(`${process.env.E2E_TEST_ENV} Settings Page`, () => {
// go to monitor settings page
await settingsPage.open();

if (enabledFeatureFlags.includes("SettingsPageRedesign")) {
await settingsPage.tabNotifications.click();
}

await expect(async () => {
// select "send breach alerts to the affected email address" option
// force is needed when another element intercepts pointer events
Expand Down

0 comments on commit 861953d

Please sign in to comment.