test: reduce test suite runtime

This commit is contained in:
N0zoM1z0
2026-07-14 21:08:27 +00:00
parent 528c05e2fa
commit 2223da1916
14 changed files with 582 additions and 207 deletions
+102 -94
View File
@@ -34,10 +34,30 @@ describe("browser CLI parity", () => {
browser.allowedOrigin,
]),
};
const listed = await runCli(
["list-browser-targets", browser.endpoint, "--approved", "--json"],
environment,
);
const [listed, inspected] = await Promise.all([
runCli(
["list-browser-targets", browser.endpoint, "--approved", "--json"],
environment,
),
runCli(
[
"inspect-web-page",
browser.endpoint,
"allowed-page",
"--approved",
"--observation-ms",
"0",
"--include-console-text",
"--console-text-approved",
"--include-json-body-shapes",
"--json-body-schema-approved",
"--include-websocket-shapes",
"--websocket-shape-approved",
"--json",
],
environment,
),
]);
expect(listed).toMatchObject({
operation: "list_browser_targets",
provider: { id: "rea-cdp-browser" },
@@ -45,24 +65,6 @@ describe("browser CLI parity", () => {
targets: { items: [{ target_id: "allowed-page" }] },
},
});
const inspected = await runCli(
[
"inspect-web-page",
browser.endpoint,
"allowed-page",
"--approved",
"--observation-ms",
"0",
"--include-console-text",
"--console-text-approved",
"--include-json-body-shapes",
"--json-body-schema-approved",
"--include-websocket-shapes",
"--websocket-shape-approved",
"--json",
],
environment,
);
expect(inspected).toMatchObject({
operation: "inspect_web_page",
provider: { id: "rea-cdp-browser" },
@@ -79,15 +81,30 @@ describe("browser CLI parity", () => {
},
});
const inspection = normalizedResult(inspected);
const compared = await runCli(
[
"compare-web-captures",
JSON.stringify({ inspection }),
JSON.stringify({ inspection }),
"--json",
],
environment,
);
const [compared, analyzed] = await Promise.all([
runCli(
[
"compare-web-captures",
JSON.stringify({ inspection }),
JSON.stringify({ inspection }),
"--json",
],
environment,
),
runCli(
[
"analyze-web-bundle",
browser.endpoint,
"allowed-page",
"--approved",
"--source-capture-approved",
"--observation-ms",
"0",
"--json",
],
environment,
),
]);
expect(compared).toMatchObject({
operation: "compare_web_captures",
normalized_result: {
@@ -97,19 +114,6 @@ describe("browser CLI parity", () => {
},
},
});
const analyzed = await runCli(
[
"analyze-web-bundle",
browser.endpoint,
"allowed-page",
"--approved",
"--source-capture-approved",
"--observation-ms",
"0",
"--json",
],
environment,
);
expect(analyzed).toMatchObject({
operation: "analyze_web_bundle",
normalized_result: {
@@ -117,18 +121,32 @@ describe("browser CLI parity", () => {
observations: { source_maps: { status: "not_requested" } },
},
});
const observedSession = await runCli(
[
"observe-web-session",
browser.endpoint,
"allowed-page",
"--approved",
"--observation-ms",
"5",
"--json",
],
environment,
);
const [observedSession, webMcp] = await Promise.all([
runCli(
[
"observe-web-session",
browser.endpoint,
"allowed-page",
"--approved",
"--observation-ms",
"5",
"--json",
],
environment,
),
runCli(
[
"discover-webmcp-tools",
browser.endpoint,
"allowed-page",
"--approved",
"--observation-ms",
"0",
"--json",
],
environment,
),
]);
expect(observedSession).toMatchObject({
operation: "observe_web_session",
normalized_result: {
@@ -138,18 +156,6 @@ describe("browser CLI parity", () => {
]),
},
});
const webMcp = await runCli(
[
"discover-webmcp-tools",
browser.endpoint,
"allowed-page",
"--approved",
"--observation-ms",
"0",
"--json",
],
environment,
);
expect(webMcp).toMatchObject({
operation: "discover_webmcp_tools",
normalized_result: {
@@ -158,17 +164,34 @@ describe("browser CLI parity", () => {
},
},
});
const screenshot = await runCli(
[
"capture-web-screenshot",
browser.endpoint,
"allowed-page",
"--approved",
"--screenshot-approved",
"--json",
],
environment,
);
const [screenshot, policy] = await Promise.all([
runCli(
[
"capture-web-screenshot",
browser.endpoint,
"allowed-page",
"--approved",
"--screenshot-approved",
"--json",
],
environment,
),
runCli(
[
"policy",
"explain",
"browser_observe",
"--origins",
browser.endpoint,
"--origins",
browser.allowedOrigin,
"--network",
"loopback",
"--json",
],
environment,
),
]);
const artifact = screenshotArtifact(screenshot);
expect(artifact).toMatchObject({ media_type: "image/png", bytes: 70 });
const visual = await runCli(
@@ -184,21 +207,6 @@ describe("browser CLI parity", () => {
operation: "compare_web_screenshots",
normalized_result: { status: "identical", changed_pixels: 0 },
});
const policy = await runCli(
[
"policy",
"explain",
"browser_observe",
"--origins",
browser.endpoint,
"--origins",
browser.allowedOrigin,
"--network",
"loopback",
"--json",
],
environment,
);
expect(policy).toEqual({
allowed: true,
grant_id: "administrator:browser_observe",