import { test, expect, Page } from '@playwright/test'; import { BasePage } from './pages/BasePage'; // ────────────────────────────────────────────── // Test plan: // Generated from: openspec/changes//specs/playwright/test-plan.md // ────────────────────────────────────────────── const BASE_URL = process.env.BASE_URL || 'http://localhost:3000'; /** * Page Object Pattern * * Extend BasePage to add page-specific selectors and actions. * Each route gets its own file: pages/LoginPage.ts, pages/DashboardPage.ts * * Example LoginPage (create at tests/playwright/pages/LoginPage.ts): * * import { BasePage } from './BasePage'; * import type { Page } from '@playwright/test'; * * export class LoginPage extends BasePage { * get usernameInput() { return this.byLabel('用户名'); } * get passwordInput() { return this.byLabel('密码'); } * get submitBtn() { return this.byRole('button', { name: '登录' }); } * * constructor(page: Page) { super(page); } * * async login(user: string, pass: string) { * await this.goto('/login'); * await this.fillAndVerify(this.usernameInput, user); * await this.fillAndVerify(this.passwordInput, pass); * await this.click(this.submitBtn); * } * } * * Usage in spec: * import { LoginPage } from '../pages/LoginPage'; * const loginPage = new LoginPage(page); * await loginPage.login('user@example.com', 'password'); */ class AppPage extends BasePage { // Add page-specific selectors here // Example: get heading() { return this.byRole('heading'); } } function createPage(page: Page): AppPage { return new AppPage(page); } // ────────────────────────────────────────────── // Tests - generated from test-plan.md // Customize selectors and assertions to match your app // ────────────────────────────────────────────── test.describe(': E2E verification', () => { test.beforeEach(async ({ page }) => { const app = createPage(page); await app.goto('/'); }); // TODO: Add test cases from specs/playwright/test-plan.md // Example: // test('shows expected content on page load', async ({ page }) => { // const app = createPage(page); // await app.goto('/'); // await expect(app.getByTestId('main-heading')).toBeVisible(); // }); });