Files
myeasycms-v2/apps/e2e/tests/account/account.spec.ts
giancarlo 7c447c8848 Refactored e2e tests to use Promise.all for parallel execution
In this update, several end-to-end (e2e) tests were refactored to use Promise.all for parallel execution of operations. This was done to improve the efficiency and stability of the tests, as waiting for each operation one by one could cause bottlenecks and potential failures in the test execution. Receives and click actions were grouped together to allow them to be executed concurrently where possible. The changes were applied across different test scenarios.
2024-05-07 17:29:54 +07:00

73 lines
1.8 KiB
TypeScript

import { Page, expect, 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';
const request = account.updateName(name);
const response = page.waitForResponse((resp) => {
return resp.url().includes('accounts');
});
await Promise.all([request, response]);
await expect(account.getProfileName()).toHaveText(name);
});
test('user can update their email', async () => {
const email = account.auth.createRandomEmail();
await account.updateEmail(email);
});
test('user can update their password', async () => {
const password = (Math.random() * 100000).toString();
const request = account.updatePassword(password);
const response = page.waitForResponse((resp) => {
return resp.url().includes('auth/v1/user');
});
await Promise.all([request, response]);
await account.auth.signOut();
});
});
test.describe('Account Deletion', () => {
test('user can delete their own account', async ({ page }) => {
const account = new AccountPageObject(page);
await account.setup();
const request = account.deleteAccount();
const response = page
.waitForResponse((resp) => {
return (
resp.url().includes('home/settings') &&
resp.request().method() === 'POST'
);
})
.then((response) => {
expect(response.status()).toBe(303);
});
await Promise.all([request, response]);
});
});