mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
test: tighten extension source classifier assertions
This commit is contained in:
@@ -1,48 +1,77 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { classifyBundledExtensionSourcePath } from "../../scripts/lib/extension-source-classifier.mjs";
|
||||
|
||||
function expectClassification(
|
||||
filePath: string,
|
||||
expected: {
|
||||
isCodeFile: boolean;
|
||||
isRuntimeApiBarrel: boolean;
|
||||
isPublicApiBarrel: boolean;
|
||||
isTestLike: boolean;
|
||||
isInfraArtifact: boolean;
|
||||
isProductionSource: boolean;
|
||||
},
|
||||
) {
|
||||
expect(classifyBundledExtensionSourcePath(filePath)).toEqual({
|
||||
normalizedPath: filePath,
|
||||
...expected,
|
||||
});
|
||||
}
|
||||
|
||||
describe("classifyBundledExtensionSourcePath", () => {
|
||||
it("treats runtime barrels as non-production source", () => {
|
||||
expect(classifyBundledExtensionSourcePath("extensions/msteams/runtime-api.ts")).toMatchObject({
|
||||
expectClassification("extensions/msteams/runtime-api.ts", {
|
||||
isCodeFile: true,
|
||||
isRuntimeApiBarrel: true,
|
||||
isPublicApiBarrel: false,
|
||||
isTestLike: false,
|
||||
isInfraArtifact: false,
|
||||
isProductionSource: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("treats extension tests and fixtures as test-like across naming styles", () => {
|
||||
expect(
|
||||
classifyBundledExtensionSourcePath("extensions/feishu/src/monitor-handler.test.ts"),
|
||||
).toMatchObject({
|
||||
expectClassification("extensions/feishu/src/monitor-handler.test.ts", {
|
||||
isCodeFile: true,
|
||||
isRuntimeApiBarrel: false,
|
||||
isPublicApiBarrel: false,
|
||||
isTestLike: true,
|
||||
isInfraArtifact: false,
|
||||
isProductionSource: false,
|
||||
});
|
||||
expect(
|
||||
classifyBundledExtensionSourcePath("extensions/discord/src/test-fixtures/message.ts"),
|
||||
).toMatchObject({
|
||||
expectClassification("extensions/discord/src/test-fixtures/message.ts", {
|
||||
isCodeFile: true,
|
||||
isRuntimeApiBarrel: false,
|
||||
isPublicApiBarrel: false,
|
||||
isTestLike: true,
|
||||
isInfraArtifact: false,
|
||||
isProductionSource: false,
|
||||
});
|
||||
expect(
|
||||
classifyBundledExtensionSourcePath("extensions/telegram/src/bot.test-harness.ts"),
|
||||
).toMatchObject({
|
||||
expectClassification("extensions/telegram/src/bot.test-harness.ts", {
|
||||
isCodeFile: true,
|
||||
isRuntimeApiBarrel: false,
|
||||
isPublicApiBarrel: false,
|
||||
isTestLike: true,
|
||||
isInfraArtifact: false,
|
||||
isProductionSource: false,
|
||||
});
|
||||
expect(
|
||||
classifyBundledExtensionSourcePath("extensions/telegram/src/target-writeback.test-shared.ts"),
|
||||
).toMatchObject({
|
||||
expectClassification("extensions/telegram/src/target-writeback.test-shared.ts", {
|
||||
isCodeFile: true,
|
||||
isRuntimeApiBarrel: false,
|
||||
isPublicApiBarrel: false,
|
||||
isTestLike: true,
|
||||
isInfraArtifact: false,
|
||||
isProductionSource: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps normal extension production files eligible for guardrails", () => {
|
||||
expect(classifyBundledExtensionSourcePath("extensions/msteams/src/send.ts")).toMatchObject({
|
||||
expectClassification("extensions/msteams/src/send.ts", {
|
||||
isCodeFile: true,
|
||||
isRuntimeApiBarrel: false,
|
||||
isPublicApiBarrel: false,
|
||||
isTestLike: false,
|
||||
isInfraArtifact: false,
|
||||
isProductionSource: true,
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user