-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add(test): add tests for account deletion and support
- Loading branch information
Showing
3 changed files
with
186 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import MainPage from "../MainPage"; | ||
import { expect, type Locator, type Page } from "@playwright/test"; | ||
|
||
export class DeleteAccountModal extends MainPage { | ||
readonly buttonClearInput: Locator; | ||
readonly pinButton0: Locator; | ||
readonly pinButton1: Locator; | ||
readonly pinButton2: Locator; | ||
readonly pinButton3: Locator; | ||
readonly pinButton4: Locator; | ||
readonly pinButton5: Locator; | ||
readonly pinButton6: Locator; | ||
readonly pinButton7: Locator; | ||
readonly pinButton8: Locator; | ||
readonly pinButton9: Locator; | ||
readonly pinButtonConfirm: Locator; | ||
readonly pinDisplay: Locator; | ||
readonly pinDot: Locator; | ||
readonly pinDotFilled: Locator; | ||
readonly pinKeypad: Locator; | ||
readonly textDeleteAccount: Locator; | ||
readonly textEnterYourPin: Locator; | ||
|
||
constructor( | ||
public readonly page: Page, | ||
public readonly viewport: string, | ||
) { | ||
super(page, viewport); | ||
this.buttonClearInput = this.page.getByTestId("button-clear-input"); | ||
this.pinButton0 = this.page.getByTestId("button-pin-0"); | ||
this.pinButton1 = this.page.getByTestId("button-pin-1"); | ||
this.pinButton2 = this.page.getByTestId("button-pin-2"); | ||
this.pinButton3 = this.page.getByTestId("button-pin-3"); | ||
this.pinButton4 = this.page.getByTestId("button-pin-4"); | ||
this.pinButton5 = this.page.getByTestId("button-pin-5"); | ||
this.pinButton6 = this.page.getByTestId("button-pin-6"); | ||
this.pinButton7 = this.page.getByTestId("button-pin-7"); | ||
this.pinButton8 = this.page.getByTestId("button-pin-8"); | ||
this.pinButton9 = this.page.getByTestId("button-pin-9"); | ||
this.pinButtonConfirm = this.page.getByTestId("button-confirm-pin"); | ||
this.pinDisplay = this.page.getByTestId("pin-display"); | ||
this.pinDot = this.page.getByTestId("pin-dot"); | ||
this.pinDotFilled = this.page.getByTestId("pin-dot-filled"); | ||
this.pinKeypad = this.page.getByTestId("pin-keypad"); | ||
this.textDeleteAccount = this.page.getByTestId( | ||
"text-delete-account-pin-first-message", | ||
); | ||
this.textEnterYourPin = this.page.getByText("Enter your pin to confirm"); | ||
} | ||
|
||
async clickConfirmButton() { | ||
await this.pinButtonConfirm.click(); | ||
} | ||
|
||
async enterPin(pin: string) { | ||
await this.page.keyboard.type(pin, { delay: 100 }); | ||
} | ||
|
||
async enterDefaultPin() { | ||
await this.page.keyboard.type("123456", { delay: 100 }); | ||
await this.pinButtonConfirm.click(); | ||
} | ||
|
||
async enterWrongPin() { | ||
await this.pinButton9.click(); | ||
await this.pinButton8.click(); | ||
await this.pinButton7.click(); | ||
await this.pinButton6.click(); | ||
} | ||
|
||
async navigateTo() { | ||
await this.page.goto("/"); | ||
} | ||
|
||
async validateConfirmButtonIsDisabled() { | ||
await expect(this.pinButtonConfirm).toBeDisabled(); | ||
} | ||
async validateToastPinIsWrong() { | ||
await this.toastNotificationText.waitFor({ state: "attached" }); | ||
await expect(this.toastNotificationText).toHaveText( | ||
"Incorrect PIN. Please try again to delete your account.", | ||
); | ||
} | ||
|
||
async waitUntilPageIsLoaded() { | ||
await expect(this.pinKeypad).toBeVisible(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,10 @@ export class SettingsProfile extends SettingsBase { | |
readonly contextMenuOptionCopyID: Locator; | ||
readonly contextMenuOptionDeleteBannerPicture: Locator; | ||
readonly contextMenuOptionDeleteProfilePicture: Locator; | ||
readonly deleteAccountSection: Locator; | ||
readonly deleteAccountSectionButton: Locator; | ||
readonly deleteAccountSectionLabel: Locator; | ||
readonly deleteAccountSectionText: Locator; | ||
readonly identiconSettingsProfile: Locator; | ||
readonly inputSettingsProfileShortID: Locator; | ||
readonly inputSettingsProfileShortIDGroup: Locator; | ||
|
@@ -80,6 +84,10 @@ export class SettingsProfile extends SettingsBase { | |
readonly storeRecoverySeedSection: Locator; | ||
readonly storeRecoverySeedCheckbox: Locator; | ||
readonly storeRecoverySeedText: Locator; | ||
readonly supportSection: Locator; | ||
readonly supportSectionButton: Locator; | ||
readonly supportSectionLabel: Locator; | ||
readonly supportSectionText: Locator; | ||
readonly warningMessageFieldRequired: Locator; | ||
readonly warningMessageInvalidFormat: Locator; | ||
readonly warningMessageMaxLengthIs128: Locator; | ||
|
@@ -183,6 +191,16 @@ export class SettingsProfile extends SettingsBase { | |
this.contextMenuOptionDeleteProfilePicture = this.page.getByTestId( | ||
"context-menu-option-Delete Profile Picture", | ||
); | ||
this.deleteAccountSection = this.page.getByTestId("section-delete-account"); | ||
this.deleteAccountSectionButton = this.deleteAccountSection.getByTestId( | ||
"button-delete-account", | ||
); | ||
this.deleteAccountSectionLabel = this.deleteAccountSection.getByTestId( | ||
"setting-section-label", | ||
); | ||
this.deleteAccountSectionText = this.deleteAccountSection.getByTestId( | ||
"setting-section-text", | ||
); | ||
this.identiconSettingsProfile = this.page | ||
.locator(".identicon") | ||
.locator("img"); | ||
|
@@ -285,6 +303,17 @@ export class SettingsProfile extends SettingsBase { | |
this.storeRecoverySeedText = this.storeRecoverySeedSection.getByTestId( | ||
"text-store-recovery-seed", | ||
); | ||
|
||
this.supportSection = this.page.getByTestId("section-support"); | ||
this.supportSectionButton = | ||
this.supportSection.getByTestId("button-support"); | ||
this.supportSectionLabel = this.supportSection.getByTestId( | ||
"setting-section-label", | ||
); | ||
this.supportSectionText = this.supportSection.getByTestId( | ||
"setting-section-text", | ||
); | ||
|
||
this.warningMessageFieldRequired = this.page.getByText( | ||
"This field is required.", | ||
); | ||
|
@@ -511,4 +540,9 @@ export class SettingsProfile extends SettingsBase { | |
mask: [this.inputSettingsProfileShortID], | ||
}); | ||
} | ||
|
||
async validateSupportButton() { | ||
const href = await this.supportSection.locator("a").getAttribute("href"); | ||
expect(href).toBe("mailto:[email protected]"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import { ChatsMainPage } from "playwright/PageObjects/ChatsElements/ChatsMain"; | ||
import { test, expect } from "../fixtures/setup"; | ||
import { SettingsProfile } from "playwright/PageObjects/Settings/SettingsProfile"; | ||
import { DeleteAccountModal } from "playwright/PageObjects/Settings/DeleteAccountModal"; | ||
import { CreateOrImportPage } from "playwright/PageObjects/CreateOrImport"; | ||
|
||
test.describe("Settings Profile Tests", () => { | ||
const username = "test123"; | ||
|
@@ -554,4 +556,66 @@ test.describe("Settings Profile Tests", () => { | |
await settingsProfile.logOutSectionButton.click(); | ||
await page.waitForURL("/auth"); | ||
}); | ||
|
||
test("I25 - Support section tests", async ({ singleUserContext }) => { | ||
const page = singleUserContext.page; | ||
const viewport = singleUserContext.viewport; | ||
const settingsProfile = new SettingsProfile(page, viewport); | ||
|
||
await test.step("Validate Support Section contents", async () => { | ||
await expect(settingsProfile.supportSectionLabel).toHaveText("Support"); | ||
await expect(settingsProfile.supportSectionText).toHaveText( | ||
"Contact us for support.", | ||
); | ||
}); | ||
|
||
await test.step("Validate support button redirects to send email to [email protected]", async () => { | ||
await settingsProfile.validateSupportButton(); | ||
}); | ||
}); | ||
|
||
test("I26 - Delete Account section tests", async ({ singleUserContext }) => { | ||
const page = singleUserContext.page; | ||
const viewport = singleUserContext.viewport; | ||
const settingsProfile = new SettingsProfile(page, viewport); | ||
const deleteAccount = new DeleteAccountModal(page, viewport); | ||
const createOrImport = new CreateOrImportPage(page, viewport); | ||
|
||
await test.step("Validate Delete Account Section contents", async () => { | ||
await expect(settingsProfile.deleteAccountSectionLabel).toHaveText( | ||
"Delete Account", | ||
); | ||
await expect(settingsProfile.deleteAccountSectionText).toHaveText( | ||
"Click here to delete your account", | ||
); | ||
}); | ||
|
||
await test.step("Click on Delete Account button and validate contents from modal prompt", async () => { | ||
await settingsProfile.deleteAccountSectionButton.click(); | ||
await expect(deleteAccount.textDeleteAccount).toHaveText( | ||
"This action will delete your account permanently", | ||
); | ||
await expect(deleteAccount.textEnterYourPin).toHaveText( | ||
"Enter your pin to confirm", | ||
); | ||
}); | ||
|
||
await test.step("Enter wrong pin and validate toast notification", async () => { | ||
await deleteAccount.enterWrongPin(); | ||
await deleteAccount.clickConfirmButton(); | ||
await deleteAccount.validateToastPinIsWrong(); | ||
await deleteAccount.waitForToastNotificationToDisappear(); | ||
}); | ||
|
||
await test.step("Enter correct pin and validate account is deleted", async () => { | ||
await deleteAccount.enterDefaultPin(); | ||
await createOrImport.labelCreateTitle.waitFor({ state: "attached" }); | ||
await expect(createOrImport.labelCreateTitle).toHaveText( | ||
"Account Creation", | ||
); | ||
await expect(createOrImport.textCreateDescription).toHaveText( | ||
"Let's get started! Begin by either creating a new account, or if you already have one we can import your existing account instead.", | ||
); | ||
}); | ||
}); | ||
}); |