feat(app): chat create dialog matches the web create flow
This commit is contained in:
@@ -26,10 +26,6 @@ void main() {
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
expect(find.text('Loading directories…'), findsOneWidget);
|
||||
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('chat-create-name')),
|
||||
'Draft chat',
|
||||
);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('chat-create-instructions')),
|
||||
'Keep me',
|
||||
@@ -44,7 +40,6 @@ void main() {
|
||||
find.textContaining('Unable to load chat options'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Draft chat'), findsOneWidget);
|
||||
expect(find.text('Keep me'), findsOneWidget);
|
||||
|
||||
gateway.directoriesHandler = () async => {
|
||||
@@ -58,27 +53,21 @@ void main() {
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.text('New chats use the server default model.'),
|
||||
find.text(
|
||||
"This server has no request for choosing a chat's model, so a new "
|
||||
"chat uses the server's default.",
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Start in ~'), findsOneWidget);
|
||||
|
||||
await tester.enterText(find.byKey(const Key('chat-create-name')), '');
|
||||
await tester.tap(find.text('Create'));
|
||||
await tester.pump();
|
||||
expect(find.text('Enter a name and server directory.'), findsOneWidget);
|
||||
expect(gateway.count('chat_create'), 0);
|
||||
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('chat-create-name')),
|
||||
'Draft chat',
|
||||
);
|
||||
await tester.tap(find.text('Create'));
|
||||
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final fields =
|
||||
gateway.lastFields('chat_create')!['chat_create']! as JsonMap;
|
||||
expect(fields['title'], 'Draft chat');
|
||||
expect(fields['directory'], '/work');
|
||||
expect(fields['title'], 'New chat');
|
||||
expect(fields['directory'], '~');
|
||||
expect(fields.containsKey('backend'), isFalse);
|
||||
expect(fields['instructions'], 'Keep me');
|
||||
expect(fields.containsKey('operation_id'), isTrue);
|
||||
@@ -98,15 +87,10 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('Unable to load chat options'), findsOneWidget);
|
||||
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('chat-create-name')),
|
||||
'Cupertino draft',
|
||||
);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('chat-create-instructions')),
|
||||
'Keep me too',
|
||||
);
|
||||
expect(find.text('Cupertino draft'), findsOneWidget);
|
||||
expect(find.text('Keep me too'), findsOneWidget);
|
||||
|
||||
gateway.directoriesHandler = () async => {
|
||||
@@ -115,11 +99,10 @@ void main() {
|
||||
await tester.tap(find.text('Retry'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('Unable to load chat options'), findsNothing);
|
||||
expect(find.text('Cupertino draft'), findsOneWidget);
|
||||
expect(find.text('Keep me too'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('material create dialog reports an empty catalog', (
|
||||
testWidgets('an empty directory list still offers home and sends ~', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = FakeChatGateway();
|
||||
@@ -128,10 +111,12 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('The server has no chat directories or backends available.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Home (~) — ~'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
||||
await tester.pumpAndSettle();
|
||||
final fields =
|
||||
gateway.lastFields('chat_create')!['chat_create']! as JsonMap;
|
||||
expect(fields['directory'], '~');
|
||||
});
|
||||
|
||||
testWidgets('Cupertino create dialog uses native selectors and fields', (
|
||||
@@ -148,36 +133,43 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('chat-new-chat')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
||||
expect(find.text('Server directory: /work'), findsOneWidget);
|
||||
expect(find.text('Backend: opencode'), findsOneWidget);
|
||||
expect(find.text('Start a chat'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Where should this chat live?: Home (~) — /work'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Chat harness: OpenCode'), findsOneWidget);
|
||||
expect(
|
||||
find.textContaining('Act as a careful coding agent.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-create-backend')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('codex'));
|
||||
await tester.tap(find.text('Codex'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Backend: codex'), findsOneWidget);
|
||||
expect(find.text('Chat harness: Codex'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-create-server-directory')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('/archive'), findsOneWidget);
|
||||
await tester.tap(find.text('/archive'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Server directory: /archive'), findsOneWidget);
|
||||
expect(find.text('Where should this chat live?: /archive'), findsOneWidget);
|
||||
expect(find.text('Start in /archive'), findsOneWidget);
|
||||
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('chat-create-name')),
|
||||
'Cupertino draft',
|
||||
);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('chat-create-instructions')),
|
||||
'Be careful',
|
||||
);
|
||||
await tester.tap(find.text('Create'));
|
||||
await tester.ensureVisible(find.byKey(const Key('chat-create-confirm')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final fields =
|
||||
gateway.lastFields('chat_create')!['chat_create']! as JsonMap;
|
||||
expect(fields['title'], 'Cupertino draft');
|
||||
expect(fields['title'], 'New chat');
|
||||
expect(fields['directory'], '/archive');
|
||||
expect(fields['backend'], 'codex');
|
||||
expect(fields['instructions'], 'Be careful');
|
||||
@@ -199,7 +191,7 @@ void main() {
|
||||
gateway.pendingSessions.add(refresh);
|
||||
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Create'));
|
||||
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.byKey(const Key('chat-create-name')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-create-instructions')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino create catalog fits real paths at 320px and 2x', (
|
||||
@@ -91,7 +91,10 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('chat-new-chat')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.textContaining('Server directory:'), findsOneWidget);
|
||||
expect(
|
||||
find.textContaining('Where should this chat live?:'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -32,26 +32,22 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('chat-create-name')),
|
||||
'Probe chat',
|
||||
);
|
||||
await tester.tap(find.text('Create'));
|
||||
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('chat-create-name')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-create-instructions')), findsOneWidget);
|
||||
expect(
|
||||
find.text('Bad state: no chat harness is available on this server'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(opened, isNull);
|
||||
|
||||
await tester.tap(find.text('Create'));
|
||||
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(bodies, hasLength(2));
|
||||
expect(bodies[1]['operation_id'], bodies[0]['operation_id']);
|
||||
expect(bodies[1]['title'], 'Probe chat');
|
||||
expect(find.byKey(const Key('chat-create-name')), findsNothing);
|
||||
expect(bodies[1]['title'], 'New chat');
|
||||
expect(find.byKey(const Key('chat-create-instructions')), findsNothing);
|
||||
expect(opened?['id'], 'created');
|
||||
expect(gateway.count('chat_sessions'), greaterThanOrEqualTo(2));
|
||||
});
|
||||
@@ -66,7 +62,7 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Create'));
|
||||
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
||||
await tester.pump();
|
||||
await tester.tap(find.text('Creating…'), warnIfMissed: false);
|
||||
await tester.pump();
|
||||
@@ -189,7 +185,7 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Create'));
|
||||
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(
|
||||
@@ -197,7 +193,7 @@ void main() {
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.textContaining('Bad state'), findsNothing);
|
||||
expect(find.byKey(const Key('chat-create-name')), findsOneWidget);
|
||||
expect(find.byKey(const Key('chat-create-instructions')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('rename refusal stays in the dialog, not on the row', (
|
||||
|
||||
Reference in New Issue
Block a user