mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
test(extensions): derive Firecrawl batch expectations from tracked tests (#103369)
* fix(firecrawl): require own legacy provider config entries * fix(firecrawl): make legacy config lookup type-safe * test(firecrawl): keep extension batch assertions data-driven * test(firecrawl): cover inherited config in client path * test(firecrawl): avoid request object stringification * test(extensions): keep firecrawl batch expectations data-driven * test(extensions): simplify shard fixture mapping --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
co-authored by
Peter Steinberger
parent
92fc907ffb
commit
c4cd643c1b
@@ -15,6 +15,7 @@ import {
|
||||
import {
|
||||
DEFAULT_EXTENSION_TEST_SHARD_COUNT,
|
||||
createExtensionTestShards,
|
||||
listTrackedTestFilesForRoots,
|
||||
resolveExtensionBatchPlan,
|
||||
resolveExtensionTestConfig,
|
||||
resolveExtensionTestPlan,
|
||||
@@ -48,7 +49,7 @@ function createConcurrentExtensionBatchPlan() {
|
||||
] as const;
|
||||
return {
|
||||
extensionCount: groups.length,
|
||||
extensionIds: groups.map(([, , extensionId]) => extensionId),
|
||||
extensionIds: groups.map((group) => group[2]),
|
||||
estimatedCost: 60,
|
||||
hasTests: true,
|
||||
planGroups: groups.map(([config, estimatedCost, extensionId, testFileCount]) => ({
|
||||
@@ -92,6 +93,10 @@ function findExtensionWithoutTests() {
|
||||
return extensionId;
|
||||
}
|
||||
|
||||
function listExtensionTestFiles(extensionId: string): string[] {
|
||||
return listTrackedTestFilesForRoots([bundledPluginRoot(extensionId)]);
|
||||
}
|
||||
|
||||
function expectPositiveIntegerMetric(value: number) {
|
||||
expect(Number.isInteger(value)).toBe(true);
|
||||
expect(value).toBeGreaterThan(0);
|
||||
@@ -501,19 +506,21 @@ describe("scripts/test-extension.mjs", () => {
|
||||
|
||||
it("keeps explicitly requested extensions without tests in batch plans", () => {
|
||||
const extensionId = findExtensionWithoutTests();
|
||||
const testedExtensionId = "firecrawl";
|
||||
const testedExtensionFiles = listExtensionTestFiles(testedExtensionId);
|
||||
const batch = resolveExtensionBatchPlan({
|
||||
cwd: process.cwd(),
|
||||
extensionIds: [extensionId, "firecrawl"],
|
||||
extensionIds: [extensionId, testedExtensionId],
|
||||
});
|
||||
|
||||
expect(batch.extensionIds).toEqual(
|
||||
[extensionId, "firecrawl"].toSorted((left, right) => left.localeCompare(right)),
|
||||
[extensionId, testedExtensionId].toSorted((left, right) => left.localeCompare(right)),
|
||||
);
|
||||
expect(batch.extensionCount).toBe(2);
|
||||
expect(batch.noTestExtensionIds).toEqual([extensionId]);
|
||||
expect(batch.hasTests).toBe(true);
|
||||
expect(batch.testFileCount).toBe(2);
|
||||
expect(batch.planGroups.flatMap((group) => group.extensionIds)).toEqual(["firecrawl"]);
|
||||
expect(batch.testFileCount).toBe(testedExtensionFiles.length);
|
||||
expect(batch.planGroups.flatMap((group) => group.extensionIds)).toEqual([testedExtensionId]);
|
||||
});
|
||||
|
||||
it("counts tracked extension tests without walking extension directories", () => {
|
||||
@@ -869,16 +876,12 @@ describe("scripts/test-extension.mjs", () => {
|
||||
|
||||
it("fails extension batch groups when exact excludes remove every test", async () => {
|
||||
const runGroup = vi.fn<() => Promise<number>>().mockResolvedValue(0);
|
||||
const firecrawlTestFiles = listExtensionTestFiles("firecrawl");
|
||||
const result = await runExtensionBatchPlan(
|
||||
resolveExtensionBatchPlan({ cwd: process.cwd(), extensionIds: ["firecrawl"] }),
|
||||
{
|
||||
runGroup,
|
||||
vitestArgs: [
|
||||
"--exclude",
|
||||
bundledPluginFile("firecrawl", "src/firecrawl-tools.test.ts"),
|
||||
"--exclude",
|
||||
bundledPluginFile("firecrawl", "src/firecrawl-client.test.ts"),
|
||||
],
|
||||
vitestArgs: firecrawlTestFiles.flatMap((testFile) => ["--exclude", testFile]),
|
||||
},
|
||||
);
|
||||
|
||||
@@ -888,16 +891,15 @@ describe("scripts/test-extension.mjs", () => {
|
||||
|
||||
it("fails extension batch groups when dir-relative exact excludes remove every test", async () => {
|
||||
const runGroup = vi.fn<() => Promise<number>>().mockResolvedValue(0);
|
||||
const firecrawlTestFiles = listExtensionTestFiles("firecrawl");
|
||||
const result = await runExtensionBatchPlan(
|
||||
resolveExtensionBatchPlan({ cwd: process.cwd(), extensionIds: ["firecrawl"] }),
|
||||
{
|
||||
runGroup,
|
||||
vitestArgs: [
|
||||
vitestArgs: firecrawlTestFiles.flatMap((testFile) => [
|
||||
"--exclude",
|
||||
"firecrawl/src/firecrawl-tools.test.ts",
|
||||
"--exclude",
|
||||
"firecrawl/src/firecrawl-client.test.ts",
|
||||
],
|
||||
testFile.replace(/^extensions\//u, ""),
|
||||
]),
|
||||
},
|
||||
);
|
||||
|
||||
@@ -907,17 +909,13 @@ describe("scripts/test-extension.mjs", () => {
|
||||
|
||||
it("allows extension batch groups to opt into empty exact excludes", async () => {
|
||||
const runGroup = vi.fn<() => Promise<number>>().mockResolvedValue(0);
|
||||
const firecrawlTestFiles = listExtensionTestFiles("firecrawl");
|
||||
const result = await runExtensionBatchPlan(
|
||||
resolveExtensionBatchPlan({ cwd: process.cwd(), extensionIds: ["firecrawl"] }),
|
||||
{
|
||||
allowEmptyAfterExclude: true,
|
||||
runGroup,
|
||||
vitestArgs: [
|
||||
"--exclude",
|
||||
bundledPluginFile("firecrawl", "src/firecrawl-tools.test.ts"),
|
||||
"--exclude",
|
||||
bundledPluginFile("firecrawl", "src/firecrawl-client.test.ts"),
|
||||
],
|
||||
vitestArgs: firecrawlTestFiles.flatMap((testFile) => ["--exclude", testFile]),
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user