Files
maestro/ui/src/components/chat/ChatMessage.toolFile.test.tsx
T
oss-sync 57702b4f34
CI / build-and-test (push) Canceled after 0s
sync: update from private repo (2336949a)
2026-09-17 11:29:31 +00:00

59 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// @vitest-environment jsdom
/**
* ツール履歴からファイルを開く導線が、チャットの実行中の行にも届いているか
* (issue #989 要望③)。
*
* 実行中に流れる tool_call コメントは ChatMessage → ProgressCard の中で
* ToolCallsSection に化ける。この受け渡しが 1 段でも抜けると、ステップが
* 終わるまでファイル名が押せない。
*/
import '../../test/dom-setup';
import { describe, it, expect, vi } from 'vitest';
import { fireEvent, screen } from '@testing-library/react';
import { renderWithProviders } from '../../test/render-helpers';
import type { LocalTaskComment } from '../../api';
import { ChatMessage } from './ChatMessage';
vi.mock('../embed/EmbedBlock', () => ({ EmbedBlock: () => null }));
const toolCallComment = {
id: 9,
taskId: 42,
author: 'agent',
kind: 'progress',
body: JSON.stringify({
type: 'tool_call',
callId: 'call-1',
movement: 'execute',
name: 'Write',
args: JSON.stringify({ file_path: 'output/report.md', content: 'x' }),
result: 'ok',
isError: false,
durationMs: 10,
}),
attachments: [],
createdAt: '2026-08-07T10:00:20.000Z',
injectedAt: null,
} as unknown as LocalTaskComment;
describe('ChatMessage のツール行', () => {
it('実行中に流れる書き込みの行でも、ファイル名を押せる', () => {
const onOpenToolFile = vi.fn();
renderWithProviders(<ChatMessage comment={toolCallComment} taskId={42} onOpenToolFile={onOpenToolFile} />);
fireEvent.click(screen.getByRole('button', { name: 'output/report.md' }));
expect(onOpenToolFile).toHaveBeenCalledWith({
section: 'output',
path: 'report.md',
wroteFile: true,
at: '2026-08-07T10:00:20.000Z',
});
});
it('開く先が無ければリンクにしない', () => {
renderWithProviders(<ChatMessage comment={toolCallComment} taskId={42} />);
expect(screen.queryByRole('button', { name: 'output/report.md' })).toBeNull();
});
});