test(P22PROD1-5): 差旅支付与对账E2E补齐及稳态修复
这个提交包含在:
@@ -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]);
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户