Enhance E2E Tests and Configuration (#358)

* Enhance E2E Tests and Configuration

- Updated `.gitignore` to exclude `.auth/` directory for cleaner test environment.
- Added `test:fast` script in `package.json` for faster Playwright test execution.
- Configured Playwright to include a setup project for initializing tests.
- Introduced `AUTH_STATES` utility for managing authentication states in tests.
- Created `auth.setup.ts` for user authentication tests, ensuring proper login flows.
- Refactored various test files to utilize the new authentication state management, improving test reliability and maintainability.
- Adjusted team and user billing tests to streamline setup and enhance clarity.
- Refactored some dialogs
This commit is contained in:
Giancarlo Buomprisco
2025-09-21 12:28:42 +08:00
committed by GitHub
parent f157cc7f3e
commit 02e2502dcc
27 changed files with 661 additions and 407 deletions

View File

@@ -1,20 +1,33 @@
import { Page, expect, test } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { AuthPageObject } from '../authentication/auth.po';
import { AccountPageObject } from './account.po';
import {AuthPageObject} from "../authentication/auth.po";
test.describe('Account Settings', () => {
let page: Page;
let account: AccountPageObject;
let email: string;
test.beforeEach(async ({ page }) => {
const auth = new AuthPageObject(page);
email = auth.createRandomEmail();
auth.bootstrapUser({
email,
password: 'testingpassword',
name: 'Test User',
});
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
account = new AccountPageObject(page);
await account.setup();
await auth.loginAsUser({
email,
password: 'testingpassword',
next: '/home/settings',
});
});
test('user can update their profile name', async () => {
test('user can update their profile name', async ({ page }) => {
const name = 'John Doe';
const request = account.updateName(name);
@@ -28,13 +41,13 @@ test.describe('Account Settings', () => {
await expect(account.getProfileName()).toHaveText(name);
});
test('user can update their email', async () => {
test('user can update their email', async ({ page }) => {
const email = account.auth.createRandomEmail();
await account.updateEmail(email);
});
test('user can update their password', async () => {
test('user can update their password', async ({ page }) => {
const password = (Math.random() * 100000).toString();
const request = account.updatePassword(password);
@@ -53,10 +66,19 @@ test.describe('Account Settings', () => {
test.describe('Account Deletion', () => {
test('user can delete their own account', async ({ page }) => {
const account = new AccountPageObject(page);
// Create a fresh user for this test since we'll be deleting it
const auth = new AuthPageObject(page);
const account = new AccountPageObject(page);
const { email } = await account.setup();
const email = auth.createRandomEmail();
await auth.bootstrapUser({
email,
password: 'testingpassword',
name: 'Test User',
});
await auth.loginAsUser({ email, next: '/home/settings' });
await account.deleteAccount(email);
@@ -70,6 +92,8 @@ test.describe('Account Deletion', () => {
password: 'testingpassword',
});
await expect(page.locator('[data-test="auth-error-message"]')).toBeVisible();
await expect(
page.locator('[data-test="auth-error-message"]'),
).toBeVisible();
});
});