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 { describe, expect, it } from "vitest";
|
||||||
import { classifyBundledExtensionSourcePath } from "../../scripts/lib/extension-source-classifier.mjs";
|
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", () => {
|
describe("classifyBundledExtensionSourcePath", () => {
|
||||||
it("treats runtime barrels as non-production source", () => {
|
it("treats runtime barrels as non-production source", () => {
|
||||||
expect(classifyBundledExtensionSourcePath("extensions/msteams/runtime-api.ts")).toMatchObject({
|
expectClassification("extensions/msteams/runtime-api.ts", {
|
||||||
isCodeFile: true,
|
isCodeFile: true,
|
||||||
isRuntimeApiBarrel: true,
|
isRuntimeApiBarrel: true,
|
||||||
|
isPublicApiBarrel: false,
|
||||||
isTestLike: false,
|
isTestLike: false,
|
||||||
|
isInfraArtifact: false,
|
||||||
isProductionSource: false,
|
isProductionSource: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("treats extension tests and fixtures as test-like across naming styles", () => {
|
it("treats extension tests and fixtures as test-like across naming styles", () => {
|
||||||
expect(
|
expectClassification("extensions/feishu/src/monitor-handler.test.ts", {
|
||||||
classifyBundledExtensionSourcePath("extensions/feishu/src/monitor-handler.test.ts"),
|
isCodeFile: true,
|
||||||
).toMatchObject({
|
isRuntimeApiBarrel: false,
|
||||||
|
isPublicApiBarrel: false,
|
||||||
isTestLike: true,
|
isTestLike: true,
|
||||||
|
isInfraArtifact: false,
|
||||||
isProductionSource: false,
|
isProductionSource: false,
|
||||||
});
|
});
|
||||||
expect(
|
expectClassification("extensions/discord/src/test-fixtures/message.ts", {
|
||||||
classifyBundledExtensionSourcePath("extensions/discord/src/test-fixtures/message.ts"),
|
isCodeFile: true,
|
||||||
).toMatchObject({
|
isRuntimeApiBarrel: false,
|
||||||
|
isPublicApiBarrel: false,
|
||||||
isTestLike: true,
|
isTestLike: true,
|
||||||
|
isInfraArtifact: false,
|
||||||
isProductionSource: false,
|
isProductionSource: false,
|
||||||
});
|
});
|
||||||
expect(
|
expectClassification("extensions/telegram/src/bot.test-harness.ts", {
|
||||||
classifyBundledExtensionSourcePath("extensions/telegram/src/bot.test-harness.ts"),
|
isCodeFile: true,
|
||||||
).toMatchObject({
|
isRuntimeApiBarrel: false,
|
||||||
|
isPublicApiBarrel: false,
|
||||||
isTestLike: true,
|
isTestLike: true,
|
||||||
|
isInfraArtifact: false,
|
||||||
isProductionSource: false,
|
isProductionSource: false,
|
||||||
});
|
});
|
||||||
expect(
|
expectClassification("extensions/telegram/src/target-writeback.test-shared.ts", {
|
||||||
classifyBundledExtensionSourcePath("extensions/telegram/src/target-writeback.test-shared.ts"),
|
isCodeFile: true,
|
||||||
).toMatchObject({
|
isRuntimeApiBarrel: false,
|
||||||
|
isPublicApiBarrel: false,
|
||||||
isTestLike: true,
|
isTestLike: true,
|
||||||
|
isInfraArtifact: false,
|
||||||
isProductionSource: false,
|
isProductionSource: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("keeps normal extension production files eligible for guardrails", () => {
|
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,
|
isCodeFile: true,
|
||||||
isRuntimeApiBarrel: false,
|
isRuntimeApiBarrel: false,
|
||||||
|
isPublicApiBarrel: false,
|
||||||
isTestLike: false,
|
isTestLike: false,
|
||||||
|
isInfraArtifact: false,
|
||||||
isProductionSource: true,
|
isProductionSource: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user