feat: add UAT helper utilities and test data
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user