test(P22PROD1-5): 差旅支付与对账E2E补齐及稳态修复

这个提交包含在:
2026-03-12 21:48:47 +08:00
父节点 c069bd5ad8
当前提交 956f77f8d4
共修改 8 个文件,包含 926 行新增和 6 行删除
+62
查看文件
@@ -0,0 +1,62 @@
import { expect, type Locator } from "@playwright/test";
export async function selectOptionByText(locator: Locator, pattern: RegExp) {
await expect
.poll(async () => {
return locator.locator("option").evaluateAll((options, rawPattern) => {
const regexp = new RegExp(rawPattern as string);
return options
.map((option) => ({
value: (option as HTMLOptionElement).value,
label: (option as HTMLOptionElement).label,
disabled: (option as HTMLOptionElement).disabled,
}))
.filter((option) => option.value && !option.disabled && regexp.test(option.label))
.map((option) => option.value)[0] ?? "";
}, pattern.source);
})
.not.toBe("");
const optionValue = await locator.locator("option").evaluateAll((options, rawPattern) => {
const regexp = new RegExp(rawPattern as string);
return options
.map((option) => ({
value: (option as HTMLOptionElement).value,
label: (option as HTMLOptionElement).label,
disabled: (option as HTMLOptionElement).disabled,
}))
.filter((option) => option.value && !option.disabled && regexp.test(option.label))
.map((option) => option.value)[0] ?? "";
}, pattern.source);
await locator.selectOption(optionValue);
}
export async function selectFirstBusinessOption(locator: Locator) {
await expect
.poll(async () => {
const values = await locator.locator("option").evaluateAll((options) =>
options
.map((option) => ({
value: (option as HTMLOptionElement).value,
disabled: (option as HTMLOptionElement).disabled,
}))
.filter((option) => option.value && !option.disabled)
.map((option) => option.value),
);
return values[0] ?? "";
})
.not.toBe("");
const values = await locator.locator("option").evaluateAll((options) =>
options
.map((option) => ({
value: (option as HTMLOptionElement).value,
disabled: (option as HTMLOptionElement).disabled,
}))
.filter((option) => option.value && !option.disabled)
.map((option) => option.value),
);
await locator.selectOption(values[0]);
}