first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
import type { Locator } from '@playwright/test';
|
||||
|
||||
import { BasePage } from './BasePage';
|
||||
|
||||
/**
|
||||
* Page object for Settings including Personal Settings where users can update their profile and manage MFA.
|
||||
*/
|
||||
export class SettingsPersonalPage extends BasePage {
|
||||
getMenuItems() {
|
||||
return this.page.getByTestId('menu-item');
|
||||
}
|
||||
|
||||
async gotoSettings() {
|
||||
await this.page.goto('/settings');
|
||||
}
|
||||
|
||||
getUserRole(): Locator {
|
||||
return this.page.getByTestId('current-user-role');
|
||||
}
|
||||
|
||||
async goto(): Promise<void> {
|
||||
await this.page.goto('/settings/personal');
|
||||
}
|
||||
|
||||
getPersonalDataForm(): Locator {
|
||||
return this.page.getByTestId('personal-data-form');
|
||||
}
|
||||
|
||||
getFirstNameField(): Locator {
|
||||
return this.getPersonalDataForm().locator('input[name="firstName"]');
|
||||
}
|
||||
|
||||
getLastNameField(): Locator {
|
||||
return this.getPersonalDataForm().locator('input[name="lastName"]');
|
||||
}
|
||||
|
||||
getEmailField(): Locator {
|
||||
return this.getPersonalDataForm().locator('input[name="email"]');
|
||||
}
|
||||
|
||||
getSaveSettingsButton(): Locator {
|
||||
return this.page.getByTestId('save-settings-button');
|
||||
}
|
||||
|
||||
async fillPersonalData(firstName: string, lastName: string): Promise<void> {
|
||||
await this.getFirstNameField().fill(firstName);
|
||||
await this.getLastNameField().fill(lastName);
|
||||
}
|
||||
|
||||
async fillEmail(email: string): Promise<void> {
|
||||
await this.getEmailField().fill(email);
|
||||
}
|
||||
|
||||
async pressEnterOnEmail(): Promise<void> {
|
||||
await this.getEmailField().press('Enter');
|
||||
}
|
||||
|
||||
async saveSettings(): Promise<void> {
|
||||
await this.getSaveSettingsButton().click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete workflow to update user's first and last name
|
||||
* @param firstName - The new first name
|
||||
* @param lastName - The new last name
|
||||
*/
|
||||
async updateFirstAndLastName(firstName: string, lastName: string): Promise<void> {
|
||||
await this.goto();
|
||||
await this.fillPersonalData(firstName, lastName);
|
||||
await this.saveSettings();
|
||||
}
|
||||
|
||||
getEnableMfaButton(): Locator {
|
||||
return this.page.getByTestId('enable-mfa-button');
|
||||
}
|
||||
|
||||
getDisableMfaButton(): Locator {
|
||||
return this.page.getByTestId('disable-mfa-button');
|
||||
}
|
||||
|
||||
getMfaCodeOrRecoveryCodeInput(): Locator {
|
||||
return this.page.locator('input[name="mfaCodeOrMfaRecoveryCode"]');
|
||||
}
|
||||
|
||||
getMfaSaveButton(): Locator {
|
||||
return this.page.getByTestId('mfa-save-button');
|
||||
}
|
||||
|
||||
async clickEnableMfa(): Promise<void> {
|
||||
await this.clickByTestId('enable-mfa-button');
|
||||
}
|
||||
|
||||
async clickDisableMfa(): Promise<void> {
|
||||
await this.getDisableMfaButton().click();
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to personal settings and initiate MFA disable workflow
|
||||
*/
|
||||
async triggerDisableMfa(): Promise<void> {
|
||||
await this.goto();
|
||||
await this.clickDisableMfa();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill in MFA code or recovery code and save the form
|
||||
* @param code - MFA token or recovery code
|
||||
*/
|
||||
async fillMfaCodeAndSave(code: string): Promise<void> {
|
||||
await this.getMfaCodeOrRecoveryCodeInput().fill(code);
|
||||
await this.getMfaSaveButton().click();
|
||||
}
|
||||
|
||||
getUpgradeCta(): Locator {
|
||||
return this.page.getByTestId('public-api-upgrade-cta');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user