import { Page, expect } from '@playwright/test'; export interface UserData { email: string; password: string; name?: string; role?: 'admin' | 'editor' | 'viewer'; } export class AdminUserPage { constructor(private page: Page) {} async goto() { await this.page.goto('/admin/users'); await this.page.waitForLoadState('networkidle'); } async createUser(data: UserData) { await this.page.click('button:has-text("新建用户")'); await this.page.fill('input[name="email"]', data.email); await this.page.fill('input[name="password"]', data.password); if (data.name) { await this.page.fill('input[name="name"]', data.name); } if (data.role) { await this.page.selectOption('select[name="role"]', data.role); } await this.page.click('button[type="submit"]'); } async expectUserInList(email: string) { await this.goto(); const row = this.page.locator(`tr:has-text("${email}")`); await expect(row).toBeVisible(); } }