Files
myeasycms-v2/apps/e2e/tests/account/account.spec.ts
giancarlo 9ac0707bef 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.
2024-04-11 20:11:49 +08:00

70 lines
1.7 KiB
TypeScript

import { expect, Page, test } from '@playwright/test';
import { AccountPageObject } from './account.po';
test.describe('Account Settings', () => {
let page: Page;
let account: AccountPageObject;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
account = new AccountPageObject(page);
await account.setup();
});
test('user can update their profile name', async () => {
const name = 'John Doe';
await account.updateName(name);
await page.waitForResponse((resp) => {
return resp.url().includes('accounts');
});
await expect(account.getProfileName()).toHaveText(name);
});
test('user can update their email', async () => {
const email = account.auth.createRandomEmail();
await account.updateEmail(email);
const req = await page.waitForResponse((resp) => {
return resp.url().includes('auth/v1/user');
});
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/');
});
});