mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-08 18:33:39 +02:00
97 lines
2.9 KiB
TypeScript
97 lines
2.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildVitestRunPlans,
|
|
resolveChangedTargetArgs,
|
|
} from "../../scripts/test-projects.test-support.mjs";
|
|
|
|
describe("scripts/test-projects changed-target routing", () => {
|
|
it("maps changed source files into scoped lane targets", () => {
|
|
expect(
|
|
resolveChangedTargetArgs(["--changed", "origin/main"], process.cwd(), () => [
|
|
"src/shared/string-normalization.ts",
|
|
"src/utils/provider-utils.ts",
|
|
]),
|
|
).toEqual(["src/shared/string-normalization.ts", "src/utils/provider-utils.ts"]);
|
|
});
|
|
|
|
it("keeps the broad changed run for Vitest wiring edits", () => {
|
|
expect(
|
|
resolveChangedTargetArgs(["--changed", "origin/main"], process.cwd(), () => [
|
|
"vitest.shared.config.ts",
|
|
"src/utils/provider-utils.ts",
|
|
]),
|
|
).toBeNull();
|
|
});
|
|
|
|
it("ignores changed files that cannot map to test lanes", () => {
|
|
expect(
|
|
resolveChangedTargetArgs(["--changed", "origin/main"], process.cwd(), () => [
|
|
"docs/help/testing.md",
|
|
]),
|
|
).toBeNull();
|
|
});
|
|
|
|
it("narrows default-lane changed source files to include globs", () => {
|
|
const plans = buildVitestRunPlans(["--changed", "origin/main"], process.cwd(), () => [
|
|
"packages/sdk/src/index.ts",
|
|
]);
|
|
|
|
expect(plans).toEqual([
|
|
{
|
|
config: "vitest.unit.config.ts",
|
|
forwardedArgs: [],
|
|
includePatterns: ["packages/sdk/src/**/*.test.ts"],
|
|
watchMode: false,
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("routes changed utils and shared files to their light scoped lanes", () => {
|
|
const plans = buildVitestRunPlans(["--changed", "origin/main"], process.cwd(), () => [
|
|
"src/shared/string-normalization.ts",
|
|
"src/utils/provider-utils.ts",
|
|
]);
|
|
|
|
expect(plans).toEqual([
|
|
{
|
|
config: "vitest.shared-core.config.ts",
|
|
forwardedArgs: [],
|
|
includePatterns: ["src/shared/**/*.test.ts"],
|
|
watchMode: false,
|
|
},
|
|
{
|
|
config: "vitest.utils.config.ts",
|
|
forwardedArgs: [],
|
|
includePatterns: ["src/utils/**/*.test.ts"],
|
|
watchMode: false,
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("routes explicit plugin-sdk light tests to the lighter plugin-sdk lane", () => {
|
|
const plans = buildVitestRunPlans(["src/plugin-sdk/temp-path.test.ts"], process.cwd());
|
|
|
|
expect(plans).toEqual([
|
|
{
|
|
config: "vitest.plugin-sdk-light.config.ts",
|
|
forwardedArgs: [],
|
|
includePatterns: ["src/plugin-sdk/temp-path.test.ts"],
|
|
watchMode: false,
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("routes explicit commands light tests to the lighter commands lane", () => {
|
|
const plans = buildVitestRunPlans(["src/commands/cleanup-utils.test.ts"], process.cwd());
|
|
|
|
expect(plans).toEqual([
|
|
{
|
|
config: "vitest.commands-light.config.ts",
|
|
forwardedArgs: [],
|
|
includePatterns: ["src/commands/cleanup-utils.test.ts"],
|
|
watchMode: false,
|
|
},
|
|
]);
|
|
});
|
|
});
|