takt/e2e/specs/opencode-conversation.e2e.ts
nrslib df2d4a786d test: E2E プロバイダー別テストをコンフィグレベルで制御し JSON レポートを追加
プロバイダー固有テストの skip ロジックをテストファイルから vitest.config.e2e.provider.ts に移動。
JSON レポート出力を追加し e2e/results/ を gitignore に追加。
2026-03-04 01:57:49 +09:00

79 lines
2.5 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.

import { describe, it, expect, afterAll } from 'vitest';
import { resetSharedServer } from '../../src/infra/opencode/client.js';
import { OpenCodeProvider } from '../../src/infra/providers/opencode.js';
const MODEL = process.env.OPENCODE_E2E_MODEL ?? 'minimax/MiniMax-M2.5-highspeed';
describe('OpenCode real E2E conversation', () => {
afterAll(() => {
resetSharedServer();
});
it('should complete a two-turn conversation with sessionId inheritance', async () => {
const provider = new OpenCodeProvider();
const agent = provider.setup({
name: 'coder',
systemPrompt: 'You are a concise assistant. Keep all responses under 20 words.',
});
// 1ターン目
const result1 = await agent.call('Say only the word "apple".', {
cwd: process.cwd(),
model: MODEL,
});
expect(result1.status).toBe('done');
expect(result1.sessionId).toBeDefined();
// 2ターン目: sessionId を引き継いで送るconversationLoop と同じ)
const result2 = await agent.call('What fruit did I ask you about?', {
cwd: process.cwd(),
model: MODEL,
sessionId: result1.sessionId,
});
expect(result2.status).toBe('done');
// 同じセッションを再利用している
expect(result2.sessionId).toBe(result1.sessionId);
// 会話が引き継がれていれば "apple" に言及するはず
expect(result2.content.toLowerCase()).toContain('apple');
}, 120_000);
it('should complete a three-turn conversation without hanging', async () => {
const provider = new OpenCodeProvider();
const agent = provider.setup({
name: 'coder',
systemPrompt: 'You are a concise assistant. Keep all responses under 20 words.',
});
const results = [];
let prevSessionId: string | undefined;
const prompts = [
'Remember the number 42.',
'What number did I ask you to remember?',
'Double that number.',
];
for (const prompt of prompts) {
const result = await agent.call(prompt, {
cwd: process.cwd(),
model: MODEL,
sessionId: prevSessionId,
});
expect(result.status).toBe('done');
results.push(result);
prevSessionId = result.sessionId;
}
// すべてのターンが同じセッションを使っている
expect(results[1].sessionId).toBe(results[0].sessionId);
expect(results[2].sessionId).toBe(results[0].sessionId);
// 会話が引き継がれている
expect(results[1].content).toMatch(/42/);
expect(results[2].content).toMatch(/84/);
}, 180_000);
});