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:
parent
c193db49a8
commit
bbb5f24cf9
3 changed files with 20 additions and 4 deletions
|
|
@ -23,6 +23,7 @@ import {
|
|||
sendChannelMessage,
|
||||
createChannel,
|
||||
addChannelMember,
|
||||
registerAgents,
|
||||
type BtmsgAgent,
|
||||
type BtmsgMessage,
|
||||
type BtmsgFeedMessage,
|
||||
|
|
@ -228,6 +229,17 @@ describe('btmsg-bridge', () => {
|
|||
await addChannelMember('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', () => {
|
||||
|
|
|
|||
|
|
@ -95,10 +95,11 @@ describe('bttask-bridge', () => {
|
|||
expect(mockInvoke).toHaveBeenCalledWith('bttask_comments', { taskId: 't1' });
|
||||
});
|
||||
|
||||
it('updateTaskStatus invokes bttask_update_status', async () => {
|
||||
mockInvoke.mockResolvedValue(undefined);
|
||||
await updateTaskStatus('t1', 'done');
|
||||
expect(mockInvoke).toHaveBeenCalledWith('bttask_update_status', { taskId: 't1', status: 'done' });
|
||||
it('updateTaskStatus invokes bttask_update_status with version', async () => {
|
||||
mockInvoke.mockResolvedValue(2);
|
||||
const newVersion = await updateTaskStatus('t1', 'done', 1);
|
||||
expect(newVersion).toBe(2);
|
||||
expect(mockInvoke).toHaveBeenCalledWith('bttask_update_status', { taskId: 't1', status: 'done', version: 1 });
|
||||
});
|
||||
|
||||
it('addTaskComment invokes bttask_add_comment', async () => {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ const {
|
|||
mockAddPane,
|
||||
mockGetPanes,
|
||||
mockNotify,
|
||||
mockAddNotification,
|
||||
} = vi.hoisted(() => ({
|
||||
capturedCallbacks: {
|
||||
msg: null as ((msg: any) => void) | null,
|
||||
|
|
@ -37,6 +38,7 @@ const {
|
|||
mockAddPane: vi.fn(),
|
||||
mockGetPanes: vi.fn().mockReturnValue([]),
|
||||
mockNotify: vi.fn(),
|
||||
mockAddNotification: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('./adapters/agent-bridge', () => ({
|
||||
|
|
@ -171,6 +173,7 @@ vi.mock('./stores/layout.svelte', () => ({
|
|||
|
||||
vi.mock('./stores/notifications.svelte', () => ({
|
||||
notify: (...args: unknown[]) => mockNotify(...args),
|
||||
addNotification: (...args: unknown[]) => mockAddNotification(...args),
|
||||
}));
|
||||
|
||||
vi.mock('./stores/conflicts.svelte', () => ({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue