WIP: message delivery status and refresh safety; fix reconcile listener recursion
The transcript listener read the lazily built _controller while _attach was still building it (load() notifies synchronously), so it built another controller, recursively, until the test process ran out of memory.
This commit is contained in:
@@ -95,6 +95,10 @@ class _ProbeGateway implements ApiGateway {
|
||||
if (text.toLowerCase().contains('refuse')) {
|
||||
throw StateError('The fixture refused this prompt.');
|
||||
}
|
||||
// `hold`: the reply never arrives, so the message stays Sending….
|
||||
if (text.toLowerCase().contains('hold')) {
|
||||
return Completer<JsonMap>().future;
|
||||
}
|
||||
final queued = text.toLowerCase().contains('queued');
|
||||
Timer(const Duration(milliseconds: 150), _running);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 450));
|
||||
@@ -197,6 +201,11 @@ const _probeStyle = String.fromEnvironment(
|
||||
/// Browser overrides: `?platform=cupertino|material`, `?theme=dark|light`,
|
||||
/// `?long=1`, `?paras=1` (a chunked multi-paragraph reply), `?tasks=<n>`, `?mode=0` (no permission mode recorded) and
|
||||
/// `?model=0` (a backend without models).
|
||||
///
|
||||
/// Delivery states: `?send=<text>` types and sends that text once the thread
|
||||
/// has loaded (`hold` never replies, `queued` queues, `refuse` is refused), and
|
||||
/// `?unsent=1` opens with a message a previous visit sent but never saw
|
||||
/// accepted, as after a page reload mid-request.
|
||||
Map<String, String> get _query => Uri.base.queryParameters;
|
||||
int get _probeTasks => int.tryParse(_query['tasks'] ?? '') ?? 0;
|
||||
|
||||
@@ -219,9 +228,28 @@ void main() {
|
||||
},
|
||||
},
|
||||
onBack: () {},
|
||||
drafts: MemoryChatDraftStore(),
|
||||
drafts: MemoryChatDraftStore(
|
||||
drafts: {'probe-composer': ?_query['send']},
|
||||
unsent: {
|
||||
if (_query['unsent'] == '1')
|
||||
'probe-composer': [
|
||||
{
|
||||
'session_id': 'probe-composer',
|
||||
'text': 'Did this one reach the server before the reload?',
|
||||
'operation_id': 'probe-op-reloaded',
|
||||
'native_message_id': 'msg_probeopreloaded',
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
newOperationId: gateway.nextOperation,
|
||||
);
|
||||
if (_query['send'] != null) {
|
||||
Timer(
|
||||
const Duration(milliseconds: 1200),
|
||||
() => _press('chat-composer-primary'),
|
||||
);
|
||||
}
|
||||
if (cupertino) {
|
||||
runApp(
|
||||
CupertinoApp(
|
||||
@@ -243,3 +271,20 @@ void main() {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Presses the native button carrying [key], as a tap would; the probe has no
|
||||
/// pointer in a headless screenshot.
|
||||
void _press(String key) {
|
||||
void visit(Element element) {
|
||||
final widget = element.widget;
|
||||
if (widget.key == Key(key)) {
|
||||
if (widget is CupertinoButton) widget.onPressed?.call();
|
||||
if (widget is ButtonStyleButton) widget.onPressed?.call();
|
||||
if (widget is IconButton) widget.onPressed?.call();
|
||||
return;
|
||||
}
|
||||
element.visitChildren(visit);
|
||||
}
|
||||
|
||||
WidgetsBinding.instance.rootElement?.visitChildren(visit);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user