test(skills): retain resolution for requested and legacy skills

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip authored and GitHub committed 2026-10-14 17:48:51 -05:00
1 parent f80398313c
commit 5e1a8a14f9
1 file changed
+27
@@ -0,0 +1,27 @@
import { randomUUID } from "node:crypto";
import { expect, it } from "vitest";
import type { Db } from "@paperclipai/db";
import { companySkillService } from "../services/company-skills.js";
const databaseAccess = new Error("Runtime selection touched the inventory database");
const db = new Proxy({} as Db, { get() { throw databaseAccess; } });
it.each([
{ onlyKeys: new Set<string>() },
{ onlyKeys: new Set<string>(), includeLegacy: true, selectionConfig: { paperclipSkillSync: { desiredSkills: ["selected"] } } },
{ selectionConfig: {} },
{ selectionConfig: { paperclipSkillSync: { desiredSkills: [] } } },
{ selectionConfig: { paperclipSkillSync: { desiredSkills: [" ", null, {}] } } },
])("does no inventory work for an empty runtime selection: %o", async options => {
await expect(companySkillService(db).listRuntimeSkillEntries(randomUUID(), options)).resolves.toEqual([]);
});
it.each([
{},
{ includeLegacy: true, selectionConfig: {} },
{ includeLegacy: true, selectionConfig: { paperclipSkillSync: { desiredSkills: [] } } },
{ selectionConfig: { paperclipSkillSync: { desiredSkills: ["selected"] } } },
{ onlyKeys: new Set(["selected"]), selectionConfig: {} },
])("retains inventory resolution for a requested or legacy skill set: %o", async options => {
await expect(companySkillService(db).listRuntimeSkillEntries(randomUUID(), options)).rejects.toBe(databaseAccess);
});