Merge commit '661dfc66'
This commit is contained in:
@@ -0,0 +1,81 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'chat_create_fields.dart';
|
||||||
|
|
||||||
|
/// Native platform controls for choosing what editable prompt to start with.
|
||||||
|
class ChatPromptChooser extends StatelessWidget {
|
||||||
|
const ChatPromptChooser({
|
||||||
|
super.key,
|
||||||
|
required this.cupertino,
|
||||||
|
required this.enabled,
|
||||||
|
required this.choice,
|
||||||
|
required this.hasLastUsed,
|
||||||
|
required this.onEnabled,
|
||||||
|
required this.onChoice,
|
||||||
|
});
|
||||||
|
|
||||||
|
static const custom = 'custom';
|
||||||
|
static const careful = 'careful';
|
||||||
|
static const lastUsed = 'last-used';
|
||||||
|
|
||||||
|
final bool cupertino;
|
||||||
|
final bool enabled;
|
||||||
|
final String choice;
|
||||||
|
final bool hasLastUsed;
|
||||||
|
final ValueChanged<bool> onEnabled;
|
||||||
|
final ValueChanged<String> onChoice;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final choices = <String>[custom, careful, if (hasLastUsed) lastUsed];
|
||||||
|
String label(String value) => switch (value) {
|
||||||
|
custom => 'Custom',
|
||||||
|
careful => 'Careful coding',
|
||||||
|
lastUsed => 'Last used prompt',
|
||||||
|
_ => value,
|
||||||
|
};
|
||||||
|
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
const Expanded(child: Text('Start with a prompt')),
|
||||||
|
if (cupertino)
|
||||||
|
CupertinoSwitch(
|
||||||
|
key: const Key('chat-create-send-prompt'),
|
||||||
|
value: enabled,
|
||||||
|
onChanged: onEnabled,
|
||||||
|
)
|
||||||
|
else
|
||||||
|
Switch(
|
||||||
|
key: const Key('chat-create-send-prompt'),
|
||||||
|
value: enabled,
|
||||||
|
onChanged: onEnabled,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
if (enabled)
|
||||||
|
if (cupertino)
|
||||||
|
CupertinoPickerField(
|
||||||
|
fieldKey: const Key('chat-create-prompt-choice'),
|
||||||
|
label: 'Prompt',
|
||||||
|
value: choices.contains(choice) ? choice : custom,
|
||||||
|
values: choices,
|
||||||
|
labelOf: label,
|
||||||
|
onSelected: onChoice,
|
||||||
|
)
|
||||||
|
else
|
||||||
|
MaterialPickerField(
|
||||||
|
fieldKey: const Key('chat-create-prompt-choice'),
|
||||||
|
label: 'Prompt',
|
||||||
|
value: choices.contains(choice) ? choice : custom,
|
||||||
|
values: choices,
|
||||||
|
labelOf: label,
|
||||||
|
onSelected: onChoice,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import '../../domain/chat_commands.dart';
|
|||||||
import 'chat_adaptive.dart';
|
import 'chat_adaptive.dart';
|
||||||
import 'chat_create_dialog_frame.dart';
|
import 'chat_create_dialog_frame.dart';
|
||||||
import 'chat_create_fields.dart';
|
import 'chat_create_fields.dart';
|
||||||
|
import 'chat_prompt_chooser.dart';
|
||||||
|
|
||||||
/// The instructions field's helper and the model note, verbatim from the web.
|
/// The instructions field's helper and the model note, verbatim from the web.
|
||||||
const String chatCreateInstructionsHelper =
|
const String chatCreateInstructionsHelper =
|
||||||
@@ -91,10 +92,12 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
|||||||
bool _nameEdited = false;
|
bool _nameEdited = false;
|
||||||
|
|
||||||
/// Whether the new chat starts with the prompt below.
|
/// Whether the new chat starts with the prompt below.
|
||||||
bool _sendPrompt = true;
|
bool _sendPrompt = false;
|
||||||
|
|
||||||
/// The remembered prompt fills in only until the operator types one.
|
/// A user's choice or edit wins over any pending saved-prompt read.
|
||||||
bool _promptEdited = false;
|
bool _promptTouched = false;
|
||||||
|
String _promptChoice = ChatPromptChooser.custom;
|
||||||
|
ChatCreatePrompt? _savedPrompt;
|
||||||
int _recall = 0;
|
int _recall = 0;
|
||||||
List<String> _directories = const [];
|
List<String> _directories = const [];
|
||||||
List<String> _backends = const [];
|
List<String> _backends = const [];
|
||||||
@@ -168,10 +171,30 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
|||||||
final recall = ++_recall;
|
final recall = ++_recall;
|
||||||
final saved = await _prompts.read(backend, directory);
|
final saved = await _prompts.read(backend, directory);
|
||||||
if (!mounted || recall != _recall) return;
|
if (!mounted || recall != _recall) return;
|
||||||
if (_promptEdited) return;
|
if (_promptTouched) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
_sendPrompt = saved?.send ?? true;
|
// Prompt text can be recalled, but sending it always requires an
|
||||||
|
// explicit choice in this new-chat dialog.
|
||||||
|
_sendPrompt = false;
|
||||||
_instructions.text = saved?.text ?? chatDefaultSessionInstructions;
|
_instructions.text = saved?.text ?? chatDefaultSessionInstructions;
|
||||||
|
_savedPrompt = saved;
|
||||||
|
_promptChoice = ChatPromptChooser.custom;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _selectPrompt(String choice) {
|
||||||
|
setState(() {
|
||||||
|
_promptTouched = true;
|
||||||
|
_promptChoice = choice;
|
||||||
|
if (choice == ChatPromptChooser.careful) {
|
||||||
|
_instructions.text = chatDefaultSessionInstructions;
|
||||||
|
_sendPrompt = true;
|
||||||
|
} else if (choice == ChatPromptChooser.lastUsed) {
|
||||||
|
_instructions.text = _savedPrompt!.text;
|
||||||
|
_sendPrompt = true;
|
||||||
|
} else {
|
||||||
|
_sendPrompt = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,22 +279,16 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
|||||||
onChanged: (_) => _nameEdited = true,
|
onChanged: (_) => _nameEdited = true,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
Row(
|
ChatPromptChooser(
|
||||||
children: [
|
cupertino: cupertino,
|
||||||
const Expanded(child: Text('Start with a prompt')),
|
enabled: _sendPrompt,
|
||||||
if (cupertino)
|
choice: _promptChoice,
|
||||||
CupertinoSwitch(
|
hasLastUsed: _savedPrompt?.text.trim().isNotEmpty == true,
|
||||||
key: const Key('chat-create-send-prompt'),
|
onEnabled: (value) => setState(() {
|
||||||
value: _sendPrompt,
|
_promptTouched = true;
|
||||||
onChanged: (value) => setState(() => _sendPrompt = value),
|
_sendPrompt = value;
|
||||||
)
|
}),
|
||||||
else
|
onChoice: _selectPrompt,
|
||||||
Switch(
|
|
||||||
key: const Key('chat-create-send-prompt'),
|
|
||||||
value: _sendPrompt,
|
|
||||||
onChanged: (value) => setState(() => _sendPrompt = value),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
if (_sendPrompt) ...[
|
if (_sendPrompt) ...[
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
@@ -281,7 +298,12 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
|||||||
controller: _instructions,
|
controller: _instructions,
|
||||||
minLines: 2,
|
minLines: 2,
|
||||||
maxLines: 4,
|
maxLines: 4,
|
||||||
onChanged: (_) => _promptEdited = true,
|
onChanged: (_) {
|
||||||
|
setState(() {
|
||||||
|
_promptTouched = true;
|
||||||
|
_promptChoice = ChatPromptChooser.custom;
|
||||||
|
});
|
||||||
|
},
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
TextField(
|
TextField(
|
||||||
@@ -289,7 +311,12 @@ class _CreateChatDialogState extends State<CreateChatDialog> {
|
|||||||
controller: _instructions,
|
controller: _instructions,
|
||||||
minLines: 2,
|
minLines: 2,
|
||||||
maxLines: 4,
|
maxLines: 4,
|
||||||
onChanged: (_) => _promptEdited = true,
|
onChanged: (_) {
|
||||||
|
setState(() {
|
||||||
|
_promptTouched = true;
|
||||||
|
_promptChoice = ChatPromptChooser.custom;
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
const Text(chatCreateInstructionsHelper),
|
const Text(chatCreateInstructionsHelper),
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 83 KiB |
@@ -0,0 +1,13 @@
|
|||||||
|
# Chat creation prompt option
|
||||||
|
|
||||||
|
- Prompt sending now starts off, regardless of the previous choice stored for
|
||||||
|
the current backend and directory. When enabled, the existing default careful
|
||||||
|
coding instructions remain editable.
|
||||||
|
- Material browser fixture evidence: `chat-prompt-create-material.png` shows
|
||||||
|
the create dialog with the prompt switch off by default at 320 CSS px / 2x.
|
||||||
|
- Focused widget tests cover the Material and Cupertino controls, editing a
|
||||||
|
custom prompt, and omission of `instructions` from the off-state create
|
||||||
|
payload.
|
||||||
|
- The broader pre-existing `chat_sessions_probe.mjs` completed through the
|
||||||
|
create-dialog capture but exited later at its unrelated “New” row-marker
|
||||||
|
assertion; that probe was not treated as a full pass.
|
||||||
@@ -26,6 +26,9 @@ void main() {
|
|||||||
await tester.pump(const Duration(milliseconds: 400));
|
await tester.pump(const Duration(milliseconds: 400));
|
||||||
expect(find.text('Loading directories…'), findsOneWidget);
|
expect(find.text('Loading directories…'), findsOneWidget);
|
||||||
|
|
||||||
|
expect(find.byKey(const Key('chat-create-instructions')), findsNothing);
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
await tester.enterText(
|
await tester.enterText(
|
||||||
find.byKey(const Key('chat-create-instructions')),
|
find.byKey(const Key('chat-create-instructions')),
|
||||||
'Keep me',
|
'Keep me',
|
||||||
@@ -88,6 +91,9 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.textContaining('Unable to load chat options'), findsOneWidget);
|
expect(find.textContaining('Unable to load chat options'), findsOneWidget);
|
||||||
|
|
||||||
|
expect(find.byKey(const Key('chat-create-instructions')), findsNothing);
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
await tester.enterText(
|
await tester.enterText(
|
||||||
find.byKey(const Key('chat-create-instructions')),
|
find.byKey(const Key('chat-create-instructions')),
|
||||||
'Keep me too',
|
'Keep me too',
|
||||||
@@ -118,6 +124,7 @@ void main() {
|
|||||||
final fields =
|
final fields =
|
||||||
gateway.lastFields('chat_create')!['chat_create']! as JsonMap;
|
gateway.lastFields('chat_create')!['chat_create']! as JsonMap;
|
||||||
expect(fields['directory'], '~');
|
expect(fields['directory'], '~');
|
||||||
|
expect(fields.containsKey('instructions'), isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Cupertino create dialog uses native selectors and fields', (
|
testWidgets('Cupertino create dialog uses native selectors and fields', (
|
||||||
@@ -135,6 +142,9 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
|
||||||
expect(find.text('Start a chat'), findsOneWidget);
|
expect(find.text('Start a chat'), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('chat-create-instructions')), findsNothing);
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
expect(
|
expect(
|
||||||
find.text('Where should this chat live?: Home (~) — /work'),
|
find.text('Where should this chat live?: Home (~) — /work'),
|
||||||
findsOneWidget,
|
findsOneWidget,
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/features/chat/data/chat_create_prompt_store.dart';
|
import 'package:pipelines_app/features/chat/data/chat_create_prompt_store.dart';
|
||||||
import 'package:pipelines_app/features/chat/data/chat_repository.dart';
|
import 'package:pipelines_app/features/chat/data/chat_repository.dart';
|
||||||
import 'package:pipelines_app/features/chat/ui/sessions/create_chat_dialog.dart';
|
import 'package:pipelines_app/features/chat/ui/sessions/create_chat_dialog.dart';
|
||||||
|
import 'package:pipelines_app/features/chat/domain/chat_commands.dart';
|
||||||
|
|
||||||
import 'fake_chat_gateway.dart';
|
import 'fake_chat_gateway.dart';
|
||||||
|
|
||||||
@@ -21,10 +25,17 @@ class _MemoryPrompts implements ChatCreatePromptStore {
|
|||||||
) async => saved['$backend|$directory'] = value;
|
) async => saved['$backend|$directory'] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _DelayedPrompts extends _MemoryPrompts {
|
||||||
|
final Completer<ChatCreatePrompt?> result = Completer<ChatCreatePrompt?>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ChatCreatePrompt?> read(String backend, String directory) =>
|
||||||
|
result.future;
|
||||||
|
}
|
||||||
|
|
||||||
Future<ChatDraft?> _create(
|
Future<ChatDraft?> _create(
|
||||||
WidgetTester tester,
|
WidgetTester tester,
|
||||||
_MemoryPrompts prompts, {
|
_MemoryPrompts prompts, {
|
||||||
bool turnOff = false,
|
|
||||||
String? prompt,
|
String? prompt,
|
||||||
}) async {
|
}) async {
|
||||||
ChatDraft? sent;
|
ChatDraft? sent;
|
||||||
@@ -48,16 +59,16 @@ Future<ChatDraft?> _create(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
if (prompt != null) {
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
if (prompt != null) {
|
if (prompt != null) {
|
||||||
await tester.enterText(
|
await tester.enterText(
|
||||||
find.byKey(const Key('chat-create-instructions')),
|
find.byKey(const Key('chat-create-instructions')),
|
||||||
prompt,
|
prompt,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (turnOff) {
|
|
||||||
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
}
|
|
||||||
await tester.ensureVisible(find.byKey(const Key('chat-create-confirm')));
|
await tester.ensureVisible(find.byKey(const Key('chat-create-confirm')));
|
||||||
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
@@ -73,25 +84,24 @@ void main() {
|
|||||||
expect(defaultChatName('~', 'OpenCode'), 'Home OpenCode');
|
expect(defaultChatName('~', 'OpenCode'), 'Home OpenCode');
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets(
|
testWidgets('a custom prompt is sent, but the next chat defaults to off', (
|
||||||
'a custom prompt is sent and comes back for that harness and folder',
|
|
||||||
(tester) async {
|
|
||||||
final prompts = _MemoryPrompts();
|
|
||||||
final first = await _create(tester, prompts, prompt: 'Review only.');
|
|
||||||
expect(first!.instructions, 'Review only.');
|
|
||||||
expect(prompts.saved.values.single, (send: true, text: 'Review only.'));
|
|
||||||
|
|
||||||
await tester.pumpWidget(const SizedBox());
|
|
||||||
final second = await _create(tester, prompts);
|
|
||||||
expect(second!.instructions, 'Review only.');
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
testWidgets('a chat can start without a prompt, and that is remembered', (
|
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
final prompts = _MemoryPrompts();
|
final prompts = _MemoryPrompts();
|
||||||
final draft = await _create(tester, prompts, turnOff: true);
|
final first = await _create(tester, prompts, prompt: 'Review only.');
|
||||||
|
expect(first!.instructions, 'Review only.');
|
||||||
|
expect(prompts.saved.values.single, (send: true, text: 'Review only.'));
|
||||||
|
|
||||||
|
await tester.pumpWidget(const SizedBox());
|
||||||
|
final second = await _create(tester, prompts);
|
||||||
|
expect(second!.instructions, isEmpty);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('a chat starts without a prompt even after a prior choice', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final prompts = _MemoryPrompts();
|
||||||
|
final draft = await _create(tester, prompts);
|
||||||
expect(draft!.instructions, isEmpty);
|
expect(draft!.instructions, isEmpty);
|
||||||
expect(prompts.saved.values.single.send, isFalse);
|
expect(prompts.saved.values.single.send, isFalse);
|
||||||
|
|
||||||
@@ -99,4 +109,130 @@ void main() {
|
|||||||
await _create(tester, prompts);
|
await _create(tester, prompts);
|
||||||
expect(prompts.saved.values.single.send, isFalse);
|
expect(prompts.saved.values.single.send, isFalse);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('the prompt menu selects a preset and permits custom edits', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final prompts = _MemoryPrompts();
|
||||||
|
await _open(tester, prompts);
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-prompt-choice')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('Careful coding').last);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(
|
||||||
|
tester
|
||||||
|
.widget<TextField>(find.byKey(const Key('chat-create-instructions')))
|
||||||
|
.controller!
|
||||||
|
.text,
|
||||||
|
chatDefaultSessionInstructions,
|
||||||
|
);
|
||||||
|
await tester.enterText(
|
||||||
|
find.byKey(const Key('chat-create-instructions')),
|
||||||
|
'My own instructions',
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text('Custom'), findsOneWidget);
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('a recalled prompt is offered as an editable preset', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final prompts = _MemoryPrompts()
|
||||||
|
..saved['opencode|~'] = (send: true, text: 'Previously used');
|
||||||
|
await _open(tester, prompts);
|
||||||
|
expect(find.byKey(const Key('chat-create-instructions')), findsNothing);
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-prompt-choice')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.text('Last used prompt').last);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(
|
||||||
|
tester
|
||||||
|
.widget<TextField>(find.byKey(const Key('chat-create-instructions')))
|
||||||
|
.controller!
|
||||||
|
.text,
|
||||||
|
'Previously used',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('a delayed saved prompt cannot override a user edit', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final prompts = _DelayedPrompts();
|
||||||
|
await _open(tester, prompts, settle: false);
|
||||||
|
await tester.pump(const Duration(milliseconds: 1));
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
|
||||||
|
await tester.pump();
|
||||||
|
await tester.enterText(
|
||||||
|
find.byKey(const Key('chat-create-instructions')),
|
||||||
|
'User choice wins',
|
||||||
|
);
|
||||||
|
prompts.result.complete((send: true, text: 'Stale saved prompt'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(
|
||||||
|
tester
|
||||||
|
.widget<TextField>(find.byKey(const Key('chat-create-instructions')))
|
||||||
|
.controller!
|
||||||
|
.text,
|
||||||
|
'User choice wins',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Cupertino prompt chooser has native preset and custom choices', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final prompts = _MemoryPrompts();
|
||||||
|
await tester.pumpWidget(
|
||||||
|
CupertinoApp(
|
||||||
|
home: CupertinoPageScaffold(
|
||||||
|
child: CreateChatDialog(
|
||||||
|
repository: ChatRepository(FakeChatGateway()),
|
||||||
|
operationId: 'op',
|
||||||
|
prompts: prompts,
|
||||||
|
onSubmit: (_, _) async => {'id': 'new'},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byKey(const Key('chat-create-send-prompt')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('chat-create-instructions')), findsNothing);
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-prompt-choice')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.byType(CupertinoActionSheet), findsOneWidget);
|
||||||
|
expect(find.text('Careful coding'), findsOneWidget);
|
||||||
|
await tester.tap(find.text('Cancel').last);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(tester.takeException(), isNull);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _open(
|
||||||
|
WidgetTester tester,
|
||||||
|
ChatCreatePromptStore prompts, {
|
||||||
|
bool settle = true,
|
||||||
|
}) async {
|
||||||
|
final gateway = FakeChatGateway()
|
||||||
|
..directoriesHandler = () async => {
|
||||||
|
'chat_directories': ['/work/pipelines'],
|
||||||
|
};
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: CreateChatDialog(
|
||||||
|
repository: ChatRepository(gateway),
|
||||||
|
operationId: 'op',
|
||||||
|
prompts: prompts,
|
||||||
|
onSubmit: (_, _) async => {'id': 'new'},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (settle) await tester.pumpAndSettle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ void main() {
|
|||||||
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
|
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
|
await tester.ensureVisible(find.byKey(const Key('chat-create-send-prompt')));
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.ensureVisible(find.byKey(const Key('chat-create-server-directory')));
|
||||||
|
|
||||||
await tester.tap(find.byKey(const Key('chat-create-server-directory')));
|
await tester.tap(find.byKey(const Key('chat-create-server-directory')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ void main() {
|
|||||||
|
|
||||||
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
|
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
@@ -192,6 +194,8 @@ void main() {
|
|||||||
|
|
||||||
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
|
await tester.tap(find.byKey(const Key('chat-new-chat-fab')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
await tester.tap(find.byKey(const Key('chat-create-confirm')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user