* 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
100 lines
2.4 KiB
TypeScript
100 lines
2.4 KiB
TypeScript
import { expect, test } from '@playwright/test';
|
|
|
|
import { AuthPageObject } from '../authentication/auth.po';
|
|
import { AccountPageObject } from './account.po';
|
|
|
|
test.describe('Account Settings', () => {
|
|
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',
|
|
});
|
|
|
|
account = new AccountPageObject(page);
|
|
|
|
await auth.loginAsUser({
|
|
email,
|
|
password: 'testingpassword',
|
|
next: '/home/settings',
|
|
});
|
|
});
|
|
|
|
test('user can update their profile name', async ({ page }) => {
|
|
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 ({ page }) => {
|
|
const email = account.auth.createRandomEmail();
|
|
|
|
await account.updateEmail(email);
|
|
});
|
|
|
|
test('user can update their password', async ({ page }) => {
|
|
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 page.context().clearCookies();
|
|
|
|
await page.reload();
|
|
});
|
|
});
|
|
|
|
test.describe('Account Deletion', () => {
|
|
test('user can delete their own account', async ({ 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 = auth.createRandomEmail();
|
|
|
|
await auth.bootstrapUser({
|
|
email,
|
|
password: 'testingpassword',
|
|
name: 'Test User',
|
|
});
|
|
|
|
await auth.loginAsUser({ email, next: '/home/settings' });
|
|
|
|
await account.deleteAccount(email);
|
|
|
|
await page.waitForURL('/');
|
|
|
|
await page.goto('/auth/sign-in');
|
|
|
|
// sign in will now fail
|
|
await auth.signIn({
|
|
email,
|
|
password: 'testingpassword',
|
|
});
|
|
|
|
await expect(
|
|
page.locator('[data-test="auth-error-message"]'),
|
|
).toBeVisible();
|
|
});
|
|
});
|