feat: add UAT helper utilities and test data

This commit is contained in:
张翔
2026-03-25 09:44:57 +08:00
parent a02c64169a
commit 9cfa3e68f6
6 changed files with 179 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
import { test, Page } from '@playwright/test';
import { UATHelper } from './uat-helper';
export interface ScenarioConfig {
name: string;
description: string;
priority: 'P0' | 'P1' | 'P2';
setup?: (page: Page) => Promise<void>;
execute: (page: Page, helper: UATHelper) => Promise<void>;
verify?: (page: Page, helper: UATHelper) => Promise<void>;
cleanup?: (page: Page) => Promise<void>;
}
export class ScenarioRunner {
static async runScenario(config: ScenarioConfig) {
test.describe(`${config.name} (${config.priority})`, () => {
test.beforeEach(async ({ page }) => {
if (config.setup) {
await config.setup(page);
}
});
test(config.description, async ({ page }) => {
const helper = new UATHelper(page);
await config.execute(page, helper);
if (config.verify) {
await config.verify(page, helper);
}
});
test.afterEach(async ({ page }) => {
if (config.cleanup) {
await config.cleanup(page);
}
});
});
}
static async runMultipleScenarios(scenarios: ScenarioConfig[]) {
for (const scenario of scenarios) {
await this.runScenario(scenario);
}
}
}