Refresh runs from nested wire events and foreground resume

This commit is contained in:
2026-11-07 23:46:02 +00:00
parent 8e041af6ad
commit 7287ba35c9
11 changed files with 274 additions and 59 deletions
@@ -225,25 +225,67 @@ void main() {
await tester.pump();
});
testWidgets('foreground resume does not refresh an open run detail', (
tester,
) async {
final channel = FakeChannel()..readyCompleter.complete();
final provider = routeProvider();
final client = PipelinesClient(channelFactory: (_) => channel);
await pumpApp(tester, provider: provider, client: client);
await replyPipelines(tester, channel, PipelineFixture());
provider.routerReportsNewRouteInformation(
RouteInformation(uri: Uri.parse('/runs/1')),
type: RouteInformationReportingType.navigate,
);
await tester.pump();
final before = countType(channel, 'list_runs');
testWidgets(
'foreground resume refreshes an open run detail without navigation',
(tester) async {
final channel = FakeChannel()..readyCompleter.complete();
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs/1')),
);
addTearDown(provider.dispose);
final client = PipelinesClient(channelFactory: (_) => channel);
await pumpApp(tester, provider: provider, client: client);
await waitForRequest(tester, channel, 'list_runs');
final initialList = pipelineRequest(channel, 'list_runs')!;
channel.incoming.add(
jsonEncode({
'id': initialList['id'],
'type': 'runs',
'runs': [
{'id': 1, 'title': 'Live run', 'status': 'running'},
],
}),
);
await waitForRequest(tester, channel, 'get_run');
final initialDetail = pipelineRequest(channel, 'get_run')!;
channel.incoming.add(
jsonEncode({
'id': initialDetail['id'],
'type': 'run',
'run_detail': {'id': 1, 'title': 'Live run', 'status': 'running'},
}),
);
await tester.pump();
final before = countType(channel, 'list_runs');
await resume(tester);
await resume(tester);
expect(countType(channel, 'list_runs'), before);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
expect(countType(channel, 'list_runs'), before + 1);
final refreshedList = await waitForLaterRequest(
tester,
channel,
'list_runs',
initialList['id'] as String,
);
channel.incoming.add(
jsonEncode({
'id': refreshedList['id'],
'type': 'runs',
'runs': [
{'id': 1, 'title': 'Live run', 'status': 'succeeded'},
],
}),
);
final refreshedDetail = await waitForLaterRequest(
tester,
channel,
'get_run',
initialDetail['id'] as String,
);
expect(refreshedDetail['run_id'], 1);
expect(countType(channel, 'subscribe'), 1);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
},
);
}