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