测试:隔离无效规则场景并只等待本轮错误提示
This commit is contained in:
1 parent
695bc9192f
commit
c1c8bf2696
1 file changed
+26
-21
@@ -129,26 +129,31 @@ test(
|
||||
}),
|
||||
);
|
||||
|
||||
test(
|
||||
"security group batches reject unknown enums without submitting partial rules",
|
||||
{ timeout: 25000 },
|
||||
(t) =>
|
||||
scenario(t, { loginMode: "password-only" }, async (page) => {
|
||||
const writes = await securityGroupBoundary(page);
|
||||
await login(page, "/security/groups/group?id=1");
|
||||
const dialog = await openBatchEditor(page);
|
||||
const invalidInputs = [
|
||||
"ot tcp 22 0.0.0.0/0 misspelled-direction",
|
||||
"in tcq 22 0.0.0.0/0 misspelled-protocol",
|
||||
"out tcp 443 0.0.0.0/0 valid-first\not tcp 22 0.0.0.0/0 invalid-second",
|
||||
];
|
||||
for (const input of invalidInputs) {
|
||||
// 每种拒绝输入使用全新的浏览器上下文;上一轮的错误提示不能冒充本轮已处理完成。
|
||||
for (const [name, input] of [
|
||||
["unknown direction", "ot tcp 22 0.0.0.0/0 misspelled-direction"],
|
||||
["unknown protocol", "in tcq 22 0.0.0.0/0 misspelled-protocol"],
|
||||
[
|
||||
"a valid rule followed by an unknown direction",
|
||||
"out tcp 443 0.0.0.0/0 valid-first\not tcp 22 0.0.0.0/0 invalid-second",
|
||||
],
|
||||
]) {
|
||||
test(
|
||||
`security group batches reject ${name} without partial writes`,
|
||||
{ timeout: 25000 },
|
||||
(t) =>
|
||||
scenario(t, { loginMode: "password-only" }, async (page) => {
|
||||
const writes = await securityGroupBoundary(page);
|
||||
await login(page, "/security/groups/group?id=1");
|
||||
const dialog = await openBatchEditor(page);
|
||||
// 弹窗本来就有 info 级使用说明;只有错误级别的可见提示才表示本次校验失败。
|
||||
const errorAlert = dialog.locator('[role="alert"].p-message-error');
|
||||
assert.equal(await errorAlert.count(), 0);
|
||||
await dialog.locator("textarea").fill(input);
|
||||
await dialog.getByRole("button", { name: "添加", exact: true }).click();
|
||||
// 等到可观察的拒绝或错误下发,不用休眠长度推断“没有发请求”。
|
||||
await eventually(
|
||||
async () =>
|
||||
writes.length > 0 || (await dialog.getByRole("alert").count()) > 0,
|
||||
async () => writes.length > 0 || (await errorAlert.isVisible()),
|
||||
Boolean,
|
||||
"Invalid rules must produce a form error or expose an unexpected write",
|
||||
);
|
||||
@@ -158,11 +163,11 @@ test(
|
||||
"Unknown enums must never reach the API",
|
||||
);
|
||||
assert.equal(await dialog.isVisible(), true);
|
||||
assert.ok((await dialog.getByRole("alert").count()) > 0);
|
||||
}
|
||||
return { rejectedInputs: invalidInputs.length, submittedBatches: 0 };
|
||||
}),
|
||||
);
|
||||
assert.equal(await errorAlert.isVisible(), true);
|
||||
return { rejectedInput: name, submittedBatches: 0 };
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
test(
|
||||
"legacy ticket menu query navigation resets drafts and writes only the selected ticket",
|
||||
|
||||
Reference in new issue
Block a user