perf(test): parallelize browser control validation requests

This commit is contained in:
Peter Steinberger
2026-02-14 01:37:26 +00:00
parent 2c849ea4c2
commit 0c00dd92a4

View File

@@ -355,74 +355,78 @@ describe("browser control server", () => {
}); });
expect(focusMissing.status).toBe(404); expect(focusMissing.status).toBe(404);
const navMissing = await realFetch(`${base}/navigate`, { const [
navMissing,
actMissing,
clickMissingRef,
scrollMissingRef,
scrollSelectorUnsupported,
clickBadButton,
clickBadModifiers,
typeBadText,
uploadMissingPaths,
dialogMissingAccept,
] = await Promise.all([
realFetch(`${base}/navigate`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({}), body: JSON.stringify({}),
}); }),
expect(navMissing.status).toBe(400); realFetch(`${base}/act`, {
const actMissing = await realFetch(`${base}/act`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({}), body: JSON.stringify({}),
}); }),
expect(actMissing.status).toBe(400); realFetch(`${base}/act`, {
const clickMissingRef = await realFetch(`${base}/act`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ kind: "click" }), body: JSON.stringify({ kind: "click" }),
}); }),
expect(clickMissingRef.status).toBe(400); realFetch(`${base}/act`, {
const scrollMissingRef = await realFetch(`${base}/act`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ kind: "scrollIntoView" }), body: JSON.stringify({ kind: "scrollIntoView" }),
}); }),
expect(scrollMissingRef.status).toBe(400); realFetch(`${base}/act`, {
const scrollSelectorUnsupported = await realFetch(`${base}/act`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ kind: "scrollIntoView", selector: "button.save" }), body: JSON.stringify({ kind: "scrollIntoView", selector: "button.save" }),
}); }),
expect(scrollSelectorUnsupported.status).toBe(400); realFetch(`${base}/act`, {
const clickBadButton = await realFetch(`${base}/act`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ kind: "click", ref: "1", button: "nope" }), body: JSON.stringify({ kind: "click", ref: "1", button: "nope" }),
}); }),
expect(clickBadButton.status).toBe(400); realFetch(`${base}/act`, {
const clickBadModifiers = await realFetch(`${base}/act`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ kind: "click", ref: "1", modifiers: ["Nope"] }), body: JSON.stringify({ kind: "click", ref: "1", modifiers: ["Nope"] }),
}); }),
expect(clickBadModifiers.status).toBe(400); realFetch(`${base}/act`, {
const typeBadText = await realFetch(`${base}/act`, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ kind: "type", ref: "1", text: 123 }), body: JSON.stringify({ kind: "type", ref: "1", text: 123 }),
}); }),
realFetch(`${base}/hooks/file-chooser`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({}),
}),
realFetch(`${base}/hooks/dialog`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({}),
}),
]);
expect(navMissing.status).toBe(400);
expect(actMissing.status).toBe(400);
expect(clickMissingRef.status).toBe(400);
expect(scrollMissingRef.status).toBe(400);
expect(scrollSelectorUnsupported.status).toBe(400);
expect(clickBadButton.status).toBe(400);
expect(clickBadModifiers.status).toBe(400);
expect(typeBadText.status).toBe(400); expect(typeBadText.status).toBe(400);
const uploadMissingPaths = await realFetch(`${base}/hooks/file-chooser`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({}),
});
expect(uploadMissingPaths.status).toBe(400); expect(uploadMissingPaths.status).toBe(400);
const dialogMissingAccept = await realFetch(`${base}/hooks/dialog`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({}),
});
expect(dialogMissingAccept.status).toBe(400); expect(dialogMissingAccept.status).toBe(400);
const snapDefault = (await realFetch(`${base}/snapshot?format=wat`).then((r) => r.json())) as { const snapDefault = (await realFetch(`${base}/snapshot?format=wat`).then((r) => r.json())) as {