* fix: OpenCode SDKサーバー起動タイムアウトを30秒に延長 * takt: github-issue-256-takt-list-instruct * refactor: 会話後アクションフローを共通化
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { describe, it, expect, vi } from 'vitest';
|
|
|
|
import { dispatchConversationAction } from '../features/interactive/actionDispatcher.js';
|
|
|
|
describe('dispatchConversationAction', () => {
|
|
it('should dispatch to matching handler with full result payload', async () => {
|
|
const execute = vi.fn().mockResolvedValue('executed');
|
|
const saveTask = vi.fn().mockResolvedValue('saved');
|
|
const cancel = vi.fn().mockResolvedValue('cancelled');
|
|
|
|
const result = await dispatchConversationAction(
|
|
{ action: 'save_task', task: 'refine branch docs' },
|
|
{
|
|
execute,
|
|
save_task: saveTask,
|
|
cancel,
|
|
},
|
|
);
|
|
|
|
expect(result).toBe('saved');
|
|
expect(saveTask).toHaveBeenCalledWith({ action: 'save_task', task: 'refine branch docs' });
|
|
expect(execute).not.toHaveBeenCalled();
|
|
expect(cancel).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('should support synchronous handlers', async () => {
|
|
const result = await dispatchConversationAction(
|
|
{ action: 'cancel', task: '' },
|
|
{
|
|
execute: () => true,
|
|
save_task: () => true,
|
|
cancel: () => false,
|
|
},
|
|
);
|
|
|
|
expect(result).toBe(false);
|
|
});
|
|
});
|
|
|