import { test as base, expect, Page } from '@playwright/test'; export type TenantCredentials = { email: string; password: string; }; export type TenantAdminFixtures = { tenantAdminCredentials: TenantCredentials | null; signInTenantAdmin: () => Promise; }; const tenantAdminEmail = process.env.E2E_TENANT_EMAIL; const tenantAdminPassword = process.env.E2E_TENANT_PASSWORD; export const test = base.extend({ tenantAdminCredentials: async ({}, use) => { if (!tenantAdminEmail || !tenantAdminPassword) { await use(null); return; } await use({ email: tenantAdminEmail, password: tenantAdminPassword, }); }, signInTenantAdmin: async ({ page, tenantAdminCredentials }, use) => { if (!tenantAdminCredentials) { await use(async () => { throw new Error('Tenant admin credentials missing. Provide E2E_TENANT_EMAIL and E2E_TENANT_PASSWORD.'); }); return; } await use(async () => { await performTenantSignIn(page, tenantAdminCredentials); }); }, }); export const expectFixture = expect; async function performTenantSignIn(page: Page, credentials: TenantCredentials) { await page.goto('/event-admin/login'); await page.fill('input[name="email"]', credentials.email); await page.fill('input[name="password"]', credentials.password); await page.click('button[type="submit"]'); await page.waitForURL(/\/event-admin(\/welcome)?/); }