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

@@ -4,8 +4,6 @@ import { AuthPageObject } from '../authentication/auth.po';
import { InvitationsPageObject } from '../invitations/invitations.po';
import { TeamAccountsPageObject } from './team-accounts.po';
const MFA_KEY = 'NHOHJVGPO3R3LKVPRMNIYLCDMBHUM2SE';
test.describe('Team Invitation with MFA Flow', () => {
test('complete flow: test@makerkit.dev creates team, invites super-admin@makerkit.dev who accepts after MFA', async ({
page,
@@ -14,18 +12,12 @@ test.describe('Team Invitation with MFA Flow', () => {
const teamAccounts = new TeamAccountsPageObject(page);
const invitations = new InvitationsPageObject(page);
const teamName = `test-team-${Math.random().toString(36).substring(2, 15)}`;
const teamSlug = teamName.toLowerCase().replace(/ /g, '-');
// Step 1: test@makerkit.dev creates a team and sends invitation
await page.goto('/auth/sign-in');
await auth.signIn({
await auth.loginAsUser({
email: 'test@makerkit.dev',
password: 'testingpassword',
});
await page.waitForURL('/home');
const teamName = `test-team-${Math.random().toString(36).substring(2, 15)}`;
const teamSlug = teamName.toLowerCase().replace(/ /g, '-');
// Create a new team
await teamAccounts.createTeam({
@@ -46,19 +38,24 @@ test.describe('Team Invitation with MFA Flow', () => {
// Verify invitation was sent
await expect(invitations.getInvitations()).toHaveCount(1);
const invitationRow = invitations.getInvitationRow(
'super-admin@makerkit.dev',
);
await expect(invitationRow).toBeVisible();
// Sign out test@makerkit.dev
await auth.signOut();
await page.waitForURL('/');
await expect(async () => {
// Sign out test@makerkit.dev
await auth.signOut();
// Step 2: super-admin@makerkit.dev signs in with MFA
await page.context().clearCookies();
await page.waitForURL('/', {
timeout: 5_000,
});
}).toPass();
await auth.visitConfirmEmailLink('super-admin@makerkit.dev');
await page
.locator('[data-test="existing-account-hint"]')
.getByRole('link', { name: 'Already have an account?' })
@@ -71,7 +68,7 @@ test.describe('Team Invitation with MFA Flow', () => {
// Complete MFA verification
await expect(async () => {
await auth.submitMFAVerification(MFA_KEY);
await auth.submitMFAVerification(AuthPageObject.MFA_KEY);
}).toPass({
intervals: [
500, 2500, 5000, 7500, 10_000, 15_000, 20_000, 25_000, 30_000, 35_000,
@@ -91,6 +88,7 @@ test.describe('Team Invitation with MFA Flow', () => {
// Step 4: Verify membership was successful
// Open account selector to verify team is available
await teamAccounts.openAccountsSelector();
const team = teamAccounts.getTeamFromSelector(teamName);
await expect(team).toBeVisible();