Files
orca/src/shared/skill-delete-contract.test.ts
T
OrcaWinandOrcaWin de93f326ea test: remove low-value inventories, passthroughs and redundant cases (#33796)
* test: remove low-value inventories, passthroughs and redundant cases

* style: format test suites after pruning redundant cases

* test: remove obsolete workflow and flaky-test references

* test: prune deleted builder test from Windows shim allowlist

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-25 23:41:49 -07:00

47 lines
1.5 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { MAX_SKILL_DELETE_BATCH, SkillDeleteRequestSchema } from './skill-delete-contract'
const SKILL = {
id: 'skill-id',
directoryPath: '/root/demo',
skillFilePath: '/root/demo/SKILL.md',
name: 'demo',
updatedAt: 1
}
describe('SkillDeleteRequestSchema', () => {
it('rejects an unknown top-level field rather than ignoring it', () => {
// Old hosts must reject delete-affecting unknown fields instead of silently dropping them.
expect(() =>
SkillDeleteRequestSchema.parse({ operationId: 'op', skills: [SKILL], force: true })
).toThrow()
})
it('strips unknown keys inside the nested discovery target', () => {
const parsed = SkillDeleteRequestSchema.parse({
operationId: 'op',
target: { runtime: 'host', somethingNew: 1 },
skills: [SKILL]
})
expect(parsed.target).toEqual({ runtime: 'host' })
})
it('keeps a null updatedAt, which the host fails closed on', () => {
const parsed = SkillDeleteRequestSchema.parse({
operationId: 'op',
skills: [{ ...SKILL, updatedAt: null }]
})
expect(parsed.skills[0].updatedAt).toBeNull()
})
it('refuses an empty or oversized batch', () => {
expect(() => SkillDeleteRequestSchema.parse({ operationId: 'op', skills: [] })).toThrow()
expect(() =>
SkillDeleteRequestSchema.parse({
operationId: 'op',
skills: Array.from({ length: MAX_SKILL_DELETE_BATCH + 1 }, () => SKILL)
})
).toThrow()
})
})