Files
zitadel/acceptance/tests/password-screen.ts

58 lines
2.0 KiB
TypeScript
Raw Normal View History

2024-11-15 13:48:42 +01:00
import { expect, Page } from "@playwright/test";
2024-11-13 19:48:25 +01:00
2024-11-15 13:48:42 +01:00
const passwordField = "password-text-input";
const passwordConfirmField = "password-confirm-text-input";
const lengthCheck = "length-check";
const symbolCheck = "symbol-check";
const numberCheck = "number-check";
const uppercaseCheck = "uppercase-check";
const lowercaseCheck = "lowercase-check";
const equalCheck = "equal-check";
2024-11-13 19:48:25 +01:00
2024-11-15 13:48:42 +01:00
const matchText = "Matches";
const noMatchText = "Doesn't match";
2024-11-13 19:48:25 +01:00
export async function changePasswordScreen(page: Page, password1: string, password2: string) {
2024-11-15 13:48:42 +01:00
await page.getByTestId(passwordField).pressSequentially(password1);
await page.getByTestId(passwordConfirmField).pressSequentially(password2);
2024-11-13 19:48:25 +01:00
}
export async function passwordScreen(page: Page, password: string) {
2024-11-15 13:48:42 +01:00
await page.getByTestId(passwordField).pressSequentially(password);
2024-11-13 19:48:25 +01:00
}
export async function passwordScreenExpect(page: Page, password: string) {
2024-11-15 13:48:42 +01:00
await expect(page.getByTestId(passwordField)).toHaveValue(password);
await expect(page.getByTestId("error").locator("div")).toContainText("Could not verify password");
2024-11-13 19:48:25 +01:00
}
2024-11-15 13:48:42 +01:00
export async function changePasswordScreenExpect(
page: Page,
password1: string,
password2: string,
length: boolean,
symbol: boolean,
number: boolean,
uppercase: boolean,
lowercase: boolean,
equals: boolean,
) {
await expect(page.getByTestId(passwordField)).toHaveValue(password1);
await expect(page.getByTestId(passwordConfirmField)).toHaveValue(password2);
await checkContent(page, lengthCheck, length);
await checkContent(page, symbolCheck, symbol);
await checkContent(page, numberCheck, number);
await checkContent(page, uppercaseCheck, uppercase);
await checkContent(page, lowercaseCheck, lowercase);
await checkContent(page, equalCheck, equals);
2024-11-13 19:48:25 +01:00
}
async function checkContent(page: Page, testid: string, match: boolean) {
2024-11-15 13:48:42 +01:00
if (match) {
await expect(page.getByTestId(testid)).toContainText(matchText);
} else {
await expect(page.getByTestId(testid)).toContainText(noMatchText);
}
}