skillhub/plugins/dsh/test/installed-context.test.ts
XiaoSeS 7f653a14b0
Some checks failed
Security / Dependency Review (push) Waiting to run
Security / CodeQL (java-kotlin) (push) Waiting to run
Security / CodeQL (javascript-typescript) (push) Waiting to run
Security / CodeQL (python) (push) Waiting to run
Deploy Docs / build (push) Has been cancelled
Deploy Docs / Deploy (push) Has been cancelled
feat(dsh): add efficient installed skill update overview (#1030)
Add user-triggered installed skill update checks with grouped progressive results, filters, retry, and per-installation update confirmation.

Use bounded Host-owned scan rounds with a trusted inventory snapshot, per-target validation, shared version resolution, and cancellation/context invalidation. Preserve existing mutation checks and document the workflow in OpenSpec.

Related to #998

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-10-29 11:35:31 +08:00

18 lines
885 B
TypeScript

import { expect, test } from 'bun:test';
import { installedContext } from '../src/client/installed-context.js';
test('workspace, scope and retention changes invalidate monotonically including A to B to A', () => {
const scope = {};
let snapshot = { scope, cwd: 'A', active: true };
let listener = () => {};
const context = installedContext(() => snapshot, next => { listener = next; return () => { listener = () => {}; }; });
const seen: number[] = [];
const stop = context.subscribe(() => seen.push(context.getSnapshot()));
expect(context.getSnapshot()).toBe(0);
snapshot = { ...snapshot, cwd: 'B' }; listener();
snapshot = { ...snapshot, cwd: 'A' }; listener();
snapshot = { ...snapshot, scope: {} }; listener();
snapshot = { ...snapshot, active: false }; listener();
expect(seen).toEqual([1, 2, 3, 4]);
expect(context.getSnapshot()).toBe(4);
stop();
});