Skip to content

Commit

Permalink
E2E test selector updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rafeerahman committed May 6, 2024
1 parent bfb4023 commit b5c7dc9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 42 deletions.
40 changes: 17 additions & 23 deletions e2e-tests/pages/authPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,20 @@ export class AuthPage {
this.page = page;
this.emailInputField = page.locator('input[name="email"]');
this.passwordInputField = page.locator("#password");
this.passwordSignupInputField =
process.env["E2E_TEST_ENV"] === "prod"
? page.locator("#password")
: page.getByTestId("new-password-input-field");
this.passwordSignupConfirmInputField =
process.env["E2E_TEST_ENV"] === "prod"
? page.locator("#vpassword")
: page.getByTestId("verify-password-input-field");
this.ageInputField =
process.env["E2E_TEST_ENV"] === "prod"
? page.locator("#age")
: page.getByTestId("age-input-field");
this.passwordSignupInputField = page.getByTestId(
"new-password-input-field",
);
this.passwordSignupConfirmInputField = page.getByTestId(
"verify-password-input-field",
);
this.ageInputField = page.getByTestId("age-input-field");
this.continueButton = page.locator("#submit-btn");
this.createAccountButton = page.getByRole("button", {
name: "Create account",
});
this.verifyCodeInputField =
process.env["E2E_TEST_ENV"] === "prod"
? page.locator("div.card input")
: page.getByTestId("confirm-signup-code-input-field");
this.verifyCodeInputField = page.getByTestId(
"confirm-signup-code-input-field",
);
this.confirmCodeButton = page.getByRole("button", { name: "Confirm" });
this.newPasswordInputFieldSignIn = page.locator(
"input[data-testid='input-field'][name='password'][type='password']",
Expand Down Expand Up @@ -84,16 +78,16 @@ export class AuthPage {
await this.enterPassword();
}

async signUp(email: string) {
await this.page
.getByText("Enter your email")
.waitFor({ state: "attached", timeout: 3000 });
await forceNonReactLink(this.page);
await this.enterEmail(email);
async signUp(email: string, emailEntered: boolean = false) {
if (!emailEntered) {
await this.page
.getByText("Enter your email")
.waitFor({ state: "attached", timeout: 3000 });
await this.enterEmail(email);
}
await this.page
.getByText("Set your password")
.waitFor({ state: "attached", timeout: 3000 });
await forceNonReactLink(this.page);
await this.passwordSignupInputField.fill(
process.env.E2E_TEST_ACCOUNT_PASSWORD as string,
);
Expand Down
22 changes: 3 additions & 19 deletions e2e-tests/pages/mozillaMonitorPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
forceNonReactLink,
getVerificationCode,
} from "../e2eTestUtils/helpers";
import { AuthPage } from "./authPage";

export class MozillaMonitorPage {
readonly page: Page;
Expand All @@ -23,30 +24,13 @@ export class MozillaMonitorPage {
if (randomMask === null) {
return new Error("Mask could not be created.");
}

await this.page.goto("https://monitor.mozilla.org/", {
waitUntil: "networkidle",
});
await this.monitorSignUpInput.fill(randomMask as string);
await this.monitorSignUpButton.click();
await this.page.waitForURL("**/oauth/signup**");
await this.page
.getByText("Set your password")
.waitFor({ state: "attached", timeout: 3000 });
await forceNonReactLink(this.page);
await this.page
.locator("#password")
.fill(process.env.E2E_TEST_ACCOUNT_PASSWORD as string);
await this.page
.locator("#vpassword")
.fill(process.env.E2E_TEST_ACCOUNT_PASSWORD as string);
await this.page.locator("#age").fill("31");
await this.page.locator("#submit-btn").click();
await this.page.waitForURL("**/confirm_signup_code**");
// verification email from fxa to generatedMaskEmail should be forwarded to E2E_TEST_ACCOUNT_FREE
await getVerificationCode(
process.env.E2E_TEST_ACCOUNT_FREE as string,
this.page,
);
const authPage = new AuthPage(this.page);
await authPage.signUp(randomMask, true);
}
}

0 comments on commit b5c7dc9

Please sign in to comment.