Files
openclaw/test/vitest/vitest.channel-paths.mjs
2026-08-15 04:47:33 -07:00

25 lines
1.1 KiB
JavaScript

// Test routing roots and globs for core channel tests and channel plugin tests.
import path from "node:path";
import { BUNDLED_PLUGIN_PATH_PREFIX } from "../../scripts/lib/bundled-plugin-paths.mjs";
import { splitChannelExtensionTestRoots } from "./vitest.extension-channel-split-paths.mjs";
const normalizeRepoPath = (value) => value.split(path.sep).join("/");
const channelTestRoots = ["src/channels", ...splitChannelExtensionTestRoots];
const coreChannelTestRoots = channelTestRoots.filter(
(root) => !root.startsWith(BUNDLED_PLUGIN_PATH_PREFIX),
);
const channelTestPrefixes = channelTestRoots.map((root) => `${root}/`);
export const coreChannelTestInclude = coreChannelTestRoots.map((root) => `${root}/**/*.test.ts`);
export const extensionExcludedChannelTestGlobs = channelTestRoots
.filter((root) => root.startsWith(BUNDLED_PLUGIN_PATH_PREFIX))
.map((root) => root.slice(BUNDLED_PLUGIN_PATH_PREFIX.length))
.map((relativeRoot) => `${relativeRoot}/**`);
export function isChannelSurfaceTestFile(filePath) {
const normalizedFile = normalizeRepoPath(filePath);
return channelTestPrefixes.some((prefix) => normalizedFile.startsWith(prefix));
}