Skip to content

Commit ee7202d

Browse files
committed
test: tighten review coverage and teardown
1 parent c12dc46 commit ee7202d

3 files changed

Lines changed: 42 additions & 4 deletions

File tree

apps/pythinker-web/test/task-detach.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ describe('detachTask API client', () => {
173173
const api = new DaemonPythinkerWebApi({
174174
serverHttpUrl: 'http://example.test:58627',
175175
clientId: 'web_test',
176-
clientName: 'pythinker-code-web',
176+
clientName: 'test',
177177
clientVersion: '0.1.1',
178178
clientUiMode: 'web',
179179
});

packages/agent-core-v2/test/app/workspaceAliases/workspaceAliasesService.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ interface SessionIndexLine {
4040
describe('WorkspaceAliasesService (file-backed)', () => {
4141
let homeDir: string;
4242
let currentHost: ReturnType<typeof createScopedTestHost> | undefined;
43+
let currentPersistence: FileWorkspacePersistence | undefined;
4344

4445
beforeEach(async () => {
4546
_clearScopedRegistryForTests();
@@ -70,6 +71,8 @@ describe('WorkspaceAliasesService (file-backed)', () => {
7071
afterEach(async () => {
7172
currentHost?.dispose();
7273
currentHost = undefined;
74+
currentPersistence?.dispose();
75+
currentPersistence = undefined;
7376
await fsp.rm(homeDir, { recursive: true, force: true });
7477
});
7578

@@ -288,9 +291,8 @@ describe('WorkspaceAliasesService (file-backed)', () => {
288291
const legacyId = 'wd_proj_deadbeef0002';
289292
await writeWorkspacesJson({ [typedId]: entry(typedRoot) });
290293
const storage = new FileStorageService(homeDir);
291-
const persistence = new GatedPersistence(
292-
new FileWorkspacePersistence(new JsonAtomicDocumentStore(storage)),
293-
);
294+
currentPersistence = new FileWorkspacePersistence(new JsonAtomicDocumentStore(storage));
295+
const persistence = new GatedPersistence(currentPersistence);
294296
const aliases = build(undefined, storage, persistence);
295297
const ws = (id: string, root: string): Workspace => ({
296298
id,

packages/transcript/test/layers.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,42 @@ describe('groupMessagesIntoSnapshot (cold path)', () => {
870870
expect(turn.attachmentIds).toEqual(['att_1']);
871871
});
872872

873+
it.each(['user', 'skill_activation'] as const)(
874+
'filters malformed origin file attachments on %s messages',
875+
(kind) => {
876+
const snapshot = groupMessagesIntoSnapshot([
877+
{
878+
role: 'user',
879+
content: [{ type: 'text', text: 'attached files' }],
880+
toolCalls: [],
881+
origin: {
882+
kind,
883+
...(kind === 'skill_activation' ? { trigger: 'user-slash' } : {}),
884+
attachments: [
885+
null,
886+
{ name: 'wrong-size.txt', mediaType: 'text/plain', size: '12' },
887+
{ name: 'note.txt', mediaType: 'text/plain', size: 12, path: '/data/note.txt' },
888+
{ name: 'wrong-path.txt', mediaType: 'text/plain', size: 12, path: 42 },
889+
],
890+
} as { kind: string; trigger?: string; attachments: unknown },
891+
},
892+
{ role: 'assistant', content: [{ type: 'text', text: 'done' }], toolCalls: [] },
893+
]);
894+
895+
expect(snapshot.attachments).toEqual([
896+
{
897+
attachmentId: 'att_1',
898+
mediaType: 'text/plain',
899+
name: 'note.txt',
900+
size: 12,
901+
},
902+
]);
903+
const turn = snapshot.items.find((item) => item.kind === 'turn');
904+
if (turn?.kind !== 'turn') throw new Error('expected turn');
905+
expect(turn.attachmentIds).toEqual(['att_1']);
906+
},
907+
);
908+
873909
it('maps persisted pythinker-file media refs to attachments', () => {
874910
const snapshot = groupMessagesIntoSnapshot([
875911
{

0 commit comments

Comments
 (0)