test(mcp): await matching responses for persisted project tools
Gitea CI / Check code and tests (pull_request) Successful in 14m1s
Gitea CI / Build Android APK (pull_request) Successful in 4m29s
Gitea CI / Assemble and validate CI artifacts (pull_request) Skipped
Gitea CI / Build Windows x64 app (pull_request) Successful in 3m34s
Gitea CI / Audit and package Windows x64 (pull_request) Skipped
Gitea CI / Gitea CI passed (pull_request) Successful in 5s

This commit is contained in:
lingjhf committed 2026-10-12 05:03:57 +08:00
1 parent 8785eaf095
commit 8a671a0eb4
1 file changed
+16 -2
+16 -2
View File
@@ -332,10 +332,13 @@ void main() {
String workspace = 'application', String workspace = 'application',
String? operation, String? operation,
}) async { }) async {
final id = ++requestId;
final elapsed = Stopwatch()..start();
stdout.writeln('MCP request $id: $name started');
socket.writeln( socket.writeln(
jsonEncode({ jsonEncode({
'jsonrpc': '2.0', 'jsonrpc': '2.0',
'id': ++requestId, 'id': id,
'method': 'tools/call', 'method': 'tools/call',
'params': { 'params': {
'_meta': { '_meta': {
@@ -351,8 +354,19 @@ void main() {
}, },
}), }),
); );
expect(await lines.moveNext().timeout(const Duration(seconds: 5)), true); await socket.flush();
// Project tools persist real files. Await their response rather than
// imposing an unrelated transport SLA; the test's timeout bounds hangs.
expect(
await lines.moveNext(),
true,
reason: 'MCP stream closed for $name request $id',
);
stdout.writeln(
'MCP request $id: $name replied after ${elapsed.elapsedMilliseconds}ms',
);
final response = jsonDecode(lines.current) as Map; final response = jsonDecode(lines.current) as Map;
expect(response['id'], id, reason: '$response');
expect(response['error'], isNull, reason: '$response'); expect(response['error'], isNull, reason: '$response');
return (response['result'] as Map)['structuredContent'] as Map; return (response['result'] as Map)['structuredContent'] as Map;
} }