feat(companion): add typed canvas RPC helpers for runtime clients
This commit is contained in:
@@ -224,4 +224,48 @@ describe('CompanionRuntimeClient', () => {
|
||||
client.disconnect();
|
||||
}
|
||||
});
|
||||
|
||||
it('supports canvas artifact lifecycle via typed helper methods', async () => {
|
||||
if (!LISTEN_ALLOWED) {
|
||||
return;
|
||||
}
|
||||
|
||||
const client = new CompanionRuntimeClient({
|
||||
url: `ws://127.0.0.1:${TEST_PORT}`,
|
||||
token: TEST_TOKEN,
|
||||
});
|
||||
|
||||
await client.connect();
|
||||
|
||||
try {
|
||||
const sessionId = 'ws:companion-canvas';
|
||||
const put = await client.putCanvasArtifact({
|
||||
sessionId,
|
||||
artifactId: 'artifact-1',
|
||||
type: 'markdown',
|
||||
title: 'Companion note',
|
||||
content: { body: '# Hello' },
|
||||
metadata: { source: 'runtime-client-test' },
|
||||
});
|
||||
expect(put.upserted).toBe(true);
|
||||
expect(put.artifact.id).toBe('artifact-1');
|
||||
expect(put.artifact.type).toBe('markdown');
|
||||
|
||||
const list = await client.listCanvasArtifacts(sessionId);
|
||||
expect(list.artifacts.length).toBeGreaterThanOrEqual(1);
|
||||
expect(list.artifacts.some((artifact) => artifact.id === 'artifact-1')).toBe(true);
|
||||
|
||||
const get = await client.getCanvasArtifact({ sessionId, artifactId: 'artifact-1' });
|
||||
expect(get.artifact.id).toBe('artifact-1');
|
||||
expect(get.artifact.title).toBe('Companion note');
|
||||
|
||||
const del = await client.deleteCanvasArtifact({ sessionId, artifactId: 'artifact-1' });
|
||||
expect(del.deleted).toBe(true);
|
||||
|
||||
const clear = await client.clearCanvasArtifacts(sessionId);
|
||||
expect(clear.cleared).toBe(0);
|
||||
} finally {
|
||||
client.disconnect();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user