From 5e1a8a14f92ec348da2dee30d4a4b0bfba3c0d28 Mon Sep 17 00:00:00 2001 From: Dotta <34892728+cryppadotta@users.noreply.github.com> Date: Wed, 14 Oct 2026 17:48:51 -0500 Subject: [PATCH] test(skills): retain resolution for requested and legacy skills Co-Authored-By: Paperclip --- .../company-skills-empty-runtime.test.ts | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 server/src/__tests__/company-skills-empty-runtime.test.ts diff --git a/server/src/__tests__/company-skills-empty-runtime.test.ts b/server/src/__tests__/company-skills-empty-runtime.test.ts new file mode 100644 index 00000000000..369546e4e40 --- /dev/null +++ b/server/src/__tests__/company-skills-empty-runtime.test.ts @@ -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() }, + { onlyKeys: new Set(), 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); +});