test: update tests for production readiness features

Update btmsg-bridge, bttask-bridge, and agent-dispatcher tests for new
APIs (registerAgents, version param, notification mocks).
This commit is contained in:
Hibryda 2026-03-12 04:57:29 +01:00
parent c193db49a8
commit bbb5f24cf9
3 changed files with 20 additions and 4 deletions

View file

@ -23,6 +23,7 @@ import {
sendChannelMessage, sendChannelMessage,
createChannel, createChannel,
addChannelMember, addChannelMember,
registerAgents,
type BtmsgAgent, type BtmsgAgent,
type BtmsgMessage, type BtmsgMessage,
type BtmsgFeedMessage, type BtmsgFeedMessage,
@ -228,6 +229,17 @@ describe('btmsg-bridge', () => {
await addChannelMember('ch1', AgentId('a1')); await addChannelMember('ch1', AgentId('a1'));
expect(mockInvoke).toHaveBeenCalledWith('btmsg_add_channel_member', { channelId: 'ch1', agentId: 'a1' }); expect(mockInvoke).toHaveBeenCalledWith('btmsg_add_channel_member', { channelId: 'ch1', agentId: 'a1' });
}); });
it('registerAgents invokes btmsg_register_agents with groups config', async () => {
mockInvoke.mockResolvedValue(undefined);
const config = {
version: 1,
groups: [{ id: 'g1', name: 'Test', projects: [], agents: [] }],
activeGroupId: 'g1',
};
await registerAgents(config as any);
expect(mockInvoke).toHaveBeenCalledWith('btmsg_register_agents', { config });
});
}); });
describe('error propagation', () => { describe('error propagation', () => {

View file

@ -95,10 +95,11 @@ describe('bttask-bridge', () => {
expect(mockInvoke).toHaveBeenCalledWith('bttask_comments', { taskId: 't1' }); expect(mockInvoke).toHaveBeenCalledWith('bttask_comments', { taskId: 't1' });
}); });
it('updateTaskStatus invokes bttask_update_status', async () => { it('updateTaskStatus invokes bttask_update_status with version', async () => {
mockInvoke.mockResolvedValue(undefined); mockInvoke.mockResolvedValue(2);
await updateTaskStatus('t1', 'done'); const newVersion = await updateTaskStatus('t1', 'done', 1);
expect(mockInvoke).toHaveBeenCalledWith('bttask_update_status', { taskId: 't1', status: 'done' }); expect(newVersion).toBe(2);
expect(mockInvoke).toHaveBeenCalledWith('bttask_update_status', { taskId: 't1', status: 'done', version: 1 });
}); });
it('addTaskComment invokes bttask_add_comment', async () => { it('addTaskComment invokes bttask_add_comment', async () => {

View file

@ -18,6 +18,7 @@ const {
mockAddPane, mockAddPane,
mockGetPanes, mockGetPanes,
mockNotify, mockNotify,
mockAddNotification,
} = vi.hoisted(() => ({ } = vi.hoisted(() => ({
capturedCallbacks: { capturedCallbacks: {
msg: null as ((msg: any) => void) | null, msg: null as ((msg: any) => void) | null,
@ -37,6 +38,7 @@ const {
mockAddPane: vi.fn(), mockAddPane: vi.fn(),
mockGetPanes: vi.fn().mockReturnValue([]), mockGetPanes: vi.fn().mockReturnValue([]),
mockNotify: vi.fn(), mockNotify: vi.fn(),
mockAddNotification: vi.fn(),
})); }));
vi.mock('./adapters/agent-bridge', () => ({ vi.mock('./adapters/agent-bridge', () => ({
@ -171,6 +173,7 @@ vi.mock('./stores/layout.svelte', () => ({
vi.mock('./stores/notifications.svelte', () => ({ vi.mock('./stores/notifications.svelte', () => ({
notify: (...args: unknown[]) => mockNotify(...args), notify: (...args: unknown[]) => mockNotify(...args),
addNotification: (...args: unknown[]) => mockAddNotification(...args),
})); }));
vi.mock('./stores/conflicts.svelte', () => ({ vi.mock('./stores/conflicts.svelte', () => ({