mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
test: combine web provider boundary checks
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
collectWebFetchProviderBoundaryViolations,
|
||||
main,
|
||||
} from "../scripts/check-web-fetch-provider-boundaries.mjs";
|
||||
import { createCapturedIo } from "./helpers/captured-io.js";
|
||||
|
||||
const violationsPromise = collectWebFetchProviderBoundaryViolations();
|
||||
const jsonOutputPromise = getJsonOutput();
|
||||
|
||||
async function getJsonOutput() {
|
||||
const captured = createCapturedIo();
|
||||
const exitCode = await main(["--json"], captured.io);
|
||||
return {
|
||||
exitCode,
|
||||
stderr: captured.readStderr(),
|
||||
json: JSON.parse(captured.readStdout()),
|
||||
};
|
||||
}
|
||||
|
||||
describe("web fetch provider boundary inventory", () => {
|
||||
it("keeps Firecrawl-specific fetch logic out of core runtime/tooling", async () => {
|
||||
const violations = await violationsPromise;
|
||||
const jsonOutput = await jsonOutputPromise;
|
||||
|
||||
expect(violations).toEqual([]);
|
||||
expect(jsonOutput.exitCode).toBe(0);
|
||||
expect(jsonOutput.stderr).toBe("");
|
||||
expect(jsonOutput.json).toEqual([]);
|
||||
});
|
||||
});
|
||||
62
test/web-provider-boundary.test.ts
Normal file
62
test/web-provider-boundary.test.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
collectWebFetchProviderBoundaryViolations,
|
||||
main as webFetchMain,
|
||||
} from "../scripts/check-web-fetch-provider-boundaries.mjs";
|
||||
import {
|
||||
collectWebSearchProviderBoundaryInventory,
|
||||
main as webSearchMain,
|
||||
} from "../scripts/check-web-search-provider-boundaries.mjs";
|
||||
import { BUNDLED_PLUGIN_PATH_PREFIX } from "./helpers/bundled-plugin-paths.js";
|
||||
import { createCapturedIo } from "./helpers/captured-io.js";
|
||||
|
||||
const webFetchViolationsPromise = collectWebFetchProviderBoundaryViolations();
|
||||
const webFetchJsonOutputPromise = getJsonOutput(webFetchMain);
|
||||
const webSearchInventoryPromise = collectWebSearchProviderBoundaryInventory();
|
||||
const webSearchJsonOutputPromise = getJsonOutput(webSearchMain);
|
||||
|
||||
async function getJsonOutput(
|
||||
main: (argv: string[], io: ReturnType<typeof createCapturedIo>["io"]) => Promise<number>,
|
||||
) {
|
||||
const captured = createCapturedIo();
|
||||
const exitCode = await main(["--json"], captured.io);
|
||||
return {
|
||||
exitCode,
|
||||
stderr: captured.readStderr(),
|
||||
json: JSON.parse(captured.readStdout()),
|
||||
};
|
||||
}
|
||||
|
||||
describe("web provider boundaries", () => {
|
||||
it("keeps Firecrawl-specific fetch logic out of core runtime/tooling", async () => {
|
||||
const violations = await webFetchViolationsPromise;
|
||||
const jsonOutput = await webFetchJsonOutputPromise;
|
||||
|
||||
expect(violations).toEqual([]);
|
||||
expect(jsonOutput.exitCode).toBe(0);
|
||||
expect(jsonOutput.stderr).toBe("");
|
||||
expect(jsonOutput.json).toEqual([]);
|
||||
});
|
||||
|
||||
it("keeps web search provider boundary inventory empty, core-only, and sorted", async () => {
|
||||
const inventory = await webSearchInventoryPromise;
|
||||
const jsonOutput = await webSearchJsonOutputPromise;
|
||||
|
||||
expect(inventory).toEqual([]);
|
||||
expect(inventory.some((entry) => entry.file.startsWith(BUNDLED_PLUGIN_PATH_PREFIX))).toBe(
|
||||
false,
|
||||
);
|
||||
expect(
|
||||
[...inventory].toSorted(
|
||||
(left, right) =>
|
||||
left.provider.localeCompare(right.provider) ||
|
||||
left.file.localeCompare(right.file) ||
|
||||
left.line - right.line ||
|
||||
left.reason.localeCompare(right.reason),
|
||||
),
|
||||
).toEqual(inventory);
|
||||
expect(jsonOutput.exitCode).toBe(0);
|
||||
expect(jsonOutput.stderr).toBe("");
|
||||
expect(jsonOutput.json).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -1,44 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
collectWebSearchProviderBoundaryInventory,
|
||||
main,
|
||||
} from "../scripts/check-web-search-provider-boundaries.mjs";
|
||||
import { BUNDLED_PLUGIN_PATH_PREFIX } from "./helpers/bundled-plugin-paths.js";
|
||||
import { createCapturedIo } from "./helpers/captured-io.js";
|
||||
|
||||
const inventoryPromise = collectWebSearchProviderBoundaryInventory();
|
||||
const jsonOutputPromise = getJsonOutput();
|
||||
|
||||
async function getJsonOutput() {
|
||||
const captured = createCapturedIo();
|
||||
const exitCode = await main(["--json"], captured.io);
|
||||
return {
|
||||
exitCode,
|
||||
stderr: captured.readStderr(),
|
||||
json: JSON.parse(captured.readStdout()),
|
||||
};
|
||||
}
|
||||
|
||||
describe("web search provider boundary inventory", () => {
|
||||
it("stays empty, core-only, and sorted", async () => {
|
||||
const inventory = await inventoryPromise;
|
||||
const jsonOutput = await jsonOutputPromise;
|
||||
|
||||
expect(inventory).toEqual([]);
|
||||
expect(inventory.some((entry) => entry.file.startsWith(BUNDLED_PLUGIN_PATH_PREFIX))).toBe(
|
||||
false,
|
||||
);
|
||||
expect(
|
||||
[...inventory].toSorted(
|
||||
(left, right) =>
|
||||
left.provider.localeCompare(right.provider) ||
|
||||
left.file.localeCompare(right.file) ||
|
||||
left.line - right.line ||
|
||||
left.reason.localeCompare(right.reason),
|
||||
),
|
||||
).toEqual(inventory);
|
||||
expect(jsonOutput.exitCode).toBe(0);
|
||||
expect(jsonOutput.stderr).toBe("");
|
||||
expect(jsonOutput.json).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user