Refactor account settings and e2e tests
Renamed several components related to account settings and updated corresponding data-test selectors for more clarity. Adjusted e2e tests to reflect these changes and added tests for new functionalities, like changing password and deleting account. In addition, generator description in monorepo configuration was simplified. Minor changes were also made to e2e test utilities for better error handling.
This commit is contained in:
@@ -14,15 +14,27 @@ export class AccountPageObject {
|
||||
return this.auth.signUpFlow('/home/settings');
|
||||
}
|
||||
|
||||
async updateProfileName(name: string) {
|
||||
await this.page.locator('[data-test="update-account-name-form"] input').fill(name);
|
||||
await this.page.locator('[data-test="update-account-name-form"] button').click();
|
||||
async updateName(name: string) {
|
||||
await this.page.fill('[data-test="update-account-name-form"] input', name);
|
||||
await this.page.click('[data-test="update-account-name-form"] button');
|
||||
}
|
||||
|
||||
async updateProfileEmail(email: string) {
|
||||
await this.page.locator('[data-test="account-email-form-email-input"]').fill(email);
|
||||
await this.page.locator('[data-test="account-email-form-repeat-email-input"]').fill(email);
|
||||
await this.page.locator('[data-test="account-email-form"] button').click();
|
||||
async updateEmail(email: string) {
|
||||
await this.page.fill('[data-test="account-email-form-email-input"]', email);
|
||||
await this.page.fill('[data-test="account-email-form-repeat-email-input"]', email);
|
||||
await this.page.click('[data-test="account-email-form"] button');
|
||||
}
|
||||
|
||||
async updatePassword(password: string) {
|
||||
await this.page.fill('[data-test="account-password-form-password-input"]', password);
|
||||
await this.page.fill('[data-test="account-password-form-repeat-password-input"]', password);
|
||||
await this.page.click('[data-test="account-password-form"] button');
|
||||
}
|
||||
|
||||
async deleteAccount() {
|
||||
await this.page.click('[data-test="delete-account-button"]');
|
||||
await this.page.fill('[data-test="delete-account-input-field"]', 'DELETE');
|
||||
await this.page.click('[data-test="confirm-delete-account-button"]');
|
||||
}
|
||||
|
||||
getProfileName() {
|
||||
|
||||
@@ -10,12 +10,12 @@ test.describe('Account Settings', () => {
|
||||
account = new AccountPageObject(page);
|
||||
|
||||
await account.setup();
|
||||
})
|
||||
});
|
||||
|
||||
test('user can update their profile name', async () => {
|
||||
const name = 'John Doe';
|
||||
|
||||
await account.updateProfileName(name);
|
||||
await account.updateName(name);
|
||||
|
||||
await page.waitForResponse((resp) => {
|
||||
return resp.url().includes('accounts');
|
||||
@@ -27,7 +27,7 @@ test.describe('Account Settings', () => {
|
||||
test('user can update their email', async () => {
|
||||
const email = account.auth.createRandomEmail();
|
||||
|
||||
await account.updateProfileEmail(email);
|
||||
await account.updateEmail(email);
|
||||
|
||||
const req = await page.waitForResponse((resp) => {
|
||||
return resp.url().includes('auth/v1/user');
|
||||
@@ -35,4 +35,36 @@ test.describe('Account Settings', () => {
|
||||
|
||||
expect(req.status()).toBe(200);
|
||||
});
|
||||
|
||||
test('user can update their password', async () => {
|
||||
const password = (Math.random() * 1000).toString();
|
||||
|
||||
await account.updatePassword(password);
|
||||
|
||||
await page.waitForResponse((resp) => {
|
||||
return resp.url().includes('auth/v1/user');
|
||||
});
|
||||
|
||||
await account.auth.signOut();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Account Deletion', () => {
|
||||
let page: Page;
|
||||
let account: AccountPageObject;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
account = new AccountPageObject(page);
|
||||
|
||||
await account.setup();
|
||||
});
|
||||
|
||||
test('user can delete their own account', async () => {
|
||||
await account.deleteAccount();
|
||||
|
||||
await page.waitForURL('http://localhost:3000');
|
||||
|
||||
expect(page.url()).toEqual('http://localhost:3000/');
|
||||
});
|
||||
});
|
||||
@@ -22,6 +22,11 @@ export class AuthPageObject {
|
||||
});
|
||||
}
|
||||
|
||||
async signOut() {
|
||||
await this.page.click('[data-test="account-dropdown-trigger"]');
|
||||
await this.page.click('[data-test="account-dropdown-sign-out"]');
|
||||
}
|
||||
|
||||
async signIn(params: {
|
||||
email: string,
|
||||
password: string
|
||||
|
||||
@@ -26,6 +26,8 @@ test.describe('Auth flow', () => {
|
||||
|
||||
await auth.visitConfirmEmailLink(email);
|
||||
|
||||
await page.waitForURL('http://localhost:3000/home');
|
||||
|
||||
expect(page.url()).toContain('http://localhost:3000/home');
|
||||
});
|
||||
|
||||
@@ -40,9 +42,13 @@ test.describe('Auth flow', () => {
|
||||
password: 'password',
|
||||
});
|
||||
|
||||
await page.waitForTimeout(500);
|
||||
await page.waitForURL('http://localhost:3000/home');
|
||||
|
||||
expect(page.url()).toContain('/home');
|
||||
|
||||
await auth.signOut();
|
||||
|
||||
expect(page.url()).toContain('/');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -47,6 +47,11 @@ export class Mailbox {
|
||||
const url = `http://localhost:54324/api/v1/mailbox/${mailbox}`;
|
||||
|
||||
const response = await fetch(url);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch emails: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const json = (await response.json()) as Array<{ id: string }>;
|
||||
|
||||
if (!json || !json.length) {
|
||||
|
||||
Reference in New Issue
Block a user