Narrow chat tests to Material hosts
Remove Cupertino-only fixtures, test variants, and the obsolete readable-text test now that the app is Material-only. Preserve the Material coverage while avoiding unreachable platform branches.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -46,20 +45,15 @@ class _ExportGateway extends FakeChatGateway {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _host(Widget child, bool cupertino) => cupertino
|
||||
? CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.light),
|
||||
home: CupertinoPageScaffold(child: child),
|
||||
)
|
||||
: MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
Widget _host(Widget child) => MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
|
||||
Future<
|
||||
({_ExportGateway gateway, List<ArtifactFile> shared, List<String> clipboard})
|
||||
>
|
||||
_open(WidgetTester tester, {required bool cupertino, JsonMap? row}) async {
|
||||
_open(WidgetTester tester, {JsonMap? row}) async {
|
||||
tester.view.physicalSize = const Size(800, 2400);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
@@ -100,7 +94,6 @@ _open(WidgetTester tester, {required bool cupertino, JsonMap? row}) async {
|
||||
onBack: () {},
|
||||
fileBridge: bridge,
|
||||
),
|
||||
cupertino,
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
@@ -117,68 +110,58 @@ Future<void> _tap(WidgetTester tester, Key key) async {
|
||||
|
||||
void main() {
|
||||
// Chat details is Material only (a dialog, or a sheet on a phone).
|
||||
for (final cupertino in [false]) {
|
||||
final host = cupertino ? 'cupertino' : 'material';
|
||||
testWidgets('shows the native id, harness and directory', (tester) async {
|
||||
await _open(tester);
|
||||
expect(find.text('Session'), findsOneWidget);
|
||||
expect(find.text('Session ID'), findsOneWidget);
|
||||
expect(find.text(_id), findsOneWidget);
|
||||
expect(find.text('Claude'), findsOneWidget);
|
||||
expect(find.text('/work/app'), findsOneWidget);
|
||||
expect(find.text(_resume), findsOneWidget);
|
||||
expect(find.text('Export native session'), findsOneWidget);
|
||||
expect(find.bySemanticsLabel('Copy session ID'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('$host: shows the native id, harness and directory', (
|
||||
tester,
|
||||
) async {
|
||||
await _open(tester, cupertino: cupertino);
|
||||
expect(find.text('Session'), findsOneWidget);
|
||||
expect(find.text('Session ID'), findsOneWidget);
|
||||
expect(find.text(_id), findsOneWidget);
|
||||
expect(find.text('Claude'), findsOneWidget);
|
||||
expect(find.text('/work/app'), findsOneWidget);
|
||||
expect(find.text(_resume), findsOneWidget);
|
||||
expect(find.text('Export native session'), findsOneWidget);
|
||||
expect(find.bySemanticsLabel('Copy session ID'), findsOneWidget);
|
||||
testWidgets('copies the id and the resume command', (tester) async {
|
||||
final opened = await _open(tester);
|
||||
await _tap(tester, const Key('chat-session-copy-id'));
|
||||
expect(opened.clipboard, [_id]);
|
||||
expect(find.text('Copied'), findsOneWidget);
|
||||
await _tap(tester, const Key('chat-session-copy-resume'));
|
||||
expect(opened.clipboard, [_id, _resume]);
|
||||
await tester.pump(const Duration(seconds: 3));
|
||||
expect(find.text('Copied'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('export hands the server file to the file action', (
|
||||
tester,
|
||||
) async {
|
||||
final opened = await _open(tester);
|
||||
await _tap(tester, const Key('chat-session-export-markdown'));
|
||||
await tester.pumpAndSettle();
|
||||
final request = opened.gateway.calls.lastWhere(
|
||||
(call) => call.type == 'chat_export',
|
||||
);
|
||||
expect(request.fields['chat_export'], {
|
||||
'session_id': _id,
|
||||
'format': 'markdown',
|
||||
});
|
||||
expect(opened.shared, hasLength(1));
|
||||
final file = opened.shared.single;
|
||||
expect(file.name, 'Fix-tests.md');
|
||||
expect(file.mimeType, 'text/markdown');
|
||||
expect(utf8.decode(file.bytes), '# Fix tests\n');
|
||||
expect(find.text('Shared Fix-tests.md.'), findsOneWidget);
|
||||
|
||||
testWidgets('$host: copies the id and the resume command', (tester) async {
|
||||
final opened = await _open(tester, cupertino: cupertino);
|
||||
await _tap(tester, const Key('chat-session-copy-id'));
|
||||
expect(opened.clipboard, [_id]);
|
||||
expect(find.text('Copied'), findsOneWidget);
|
||||
await _tap(tester, const Key('chat-session-copy-resume'));
|
||||
expect(opened.clipboard, [_id, _resume]);
|
||||
await tester.pump(const Duration(seconds: 3));
|
||||
expect(find.text('Copied'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$host: export hands the server file to the file action', (
|
||||
tester,
|
||||
) async {
|
||||
final opened = await _open(tester, cupertino: cupertino);
|
||||
await _tap(tester, const Key('chat-session-export-markdown'));
|
||||
await tester.pumpAndSettle();
|
||||
final request = opened.gateway.calls.lastWhere(
|
||||
(call) => call.type == 'chat_export',
|
||||
);
|
||||
expect(request.fields['chat_export'], {
|
||||
'session_id': _id,
|
||||
'format': 'markdown',
|
||||
});
|
||||
expect(opened.shared, hasLength(1));
|
||||
final file = opened.shared.single;
|
||||
expect(file.name, 'Fix-tests.md');
|
||||
expect(file.mimeType, 'text/markdown');
|
||||
expect(utf8.decode(file.bytes), '# Fix tests\n');
|
||||
expect(find.text('Shared Fix-tests.md.'), findsOneWidget);
|
||||
|
||||
await _tap(tester, const Key('chat-session-export-json'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(opened.shared.last.name, 'Fix-tests.json');
|
||||
});
|
||||
}
|
||||
await _tap(tester, const Key('chat-session-export-json'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(opened.shared.last.name, 'Fix-tests.json');
|
||||
});
|
||||
|
||||
testWidgets('no native export or resume command when the row has none', (
|
||||
tester,
|
||||
) async {
|
||||
await _open(
|
||||
tester,
|
||||
cupertino: false,
|
||||
row: {'id': _id, 'directory': '/work/app'},
|
||||
);
|
||||
await _open(tester, row: {'id': _id, 'directory': '/work/app'});
|
||||
expect(find.text('OpenCode'), findsOneWidget);
|
||||
expect(find.text('Export native session'), findsNothing);
|
||||
expect(find.text('Copy resume command'), findsNothing);
|
||||
|
||||
Reference in New Issue
Block a user