71 行
1.8 KiB
TypeScript
71 行
1.8 KiB
TypeScript
import { expect, type Page } from "@playwright/test";
|
|
|
|
import { TEST_IDS } from "../testIds";
|
|
|
|
export class ReimbursementDetailPageObject {
|
|
readonly page: Page;
|
|
|
|
constructor(page: Page) {
|
|
this.page = page;
|
|
}
|
|
|
|
get overview() {
|
|
return this.page.getByTestId(TEST_IDS.reimbursement.overview);
|
|
}
|
|
|
|
get summary() {
|
|
return this.page.getByTestId(TEST_IDS.reimbursement.summary);
|
|
}
|
|
|
|
get itemsTable() {
|
|
return this.page.getByTestId(TEST_IDS.reimbursement.items);
|
|
}
|
|
|
|
get addItemBtn() {
|
|
return this.page.getByTestId(TEST_IDS.reimbursement.itemAdd);
|
|
}
|
|
|
|
get budgetHint() {
|
|
return this.page.getByTestId(TEST_IDS.reimbursement.budgetHint);
|
|
}
|
|
|
|
get workflowProgress() {
|
|
return this.page.getByTestId(TEST_IDS.reimbursement.workflowProgress);
|
|
}
|
|
|
|
get erpExport() {
|
|
return this.page.getByTestId(TEST_IDS.reimbursement.erpExport);
|
|
}
|
|
|
|
get submitBtn() {
|
|
return this.page.getByTestId(TEST_IDS.reimbursement.submit);
|
|
}
|
|
|
|
get withdrawBtn() {
|
|
return this.page.getByTestId(TEST_IDS.reimbursement.withdraw);
|
|
}
|
|
|
|
get payBtn() {
|
|
return this.page.getByTestId(TEST_IDS.reimbursement.pay);
|
|
}
|
|
|
|
async assertLoaded() {
|
|
await expect(this.overview).toBeVisible({ timeout: 15_000 });
|
|
await expect(this.summary).toBeVisible({ timeout: 15_000 });
|
|
}
|
|
|
|
async assertStatus(statusText: string) {
|
|
await expect(this.summary).toContainText(statusText);
|
|
}
|
|
|
|
// 当前 seed 保证 precheck 不触发 warn/manual_review;若 seed 变更,此处需相应调整。
|
|
async submitReimbursement(acceptConfirm = true) {
|
|
const dialogPromise = acceptConfirm
|
|
? this.page.waitForEvent("dialog", { timeout: 2_000 }).then((dialog) => dialog.accept()).catch(() => undefined)
|
|
: Promise.resolve();
|
|
|
|
await this.submitBtn.click();
|
|
await dialogPromise;
|
|
}
|
|
}
|