Refresh runs from nested wire events and foreground resume
This commit is contained in:
@@ -157,35 +157,42 @@ void main() {
|
||||
});
|
||||
|
||||
group('pushed frames and reconnect', () {
|
||||
test('a live frame that becomes failed appears without a reload', () async {
|
||||
final controller = _controller(MemoryAttentionStore());
|
||||
addTearDown(controller.dispose);
|
||||
await controller.load();
|
||||
controller.seedRows([_run(1, 'running')]);
|
||||
expect(controller.entries, isEmpty);
|
||||
test(
|
||||
'wire envelopes update attention and deduplicate transitions',
|
||||
() async {
|
||||
final controller = _controller(MemoryAttentionStore());
|
||||
addTearDown(controller.dispose);
|
||||
await controller.load();
|
||||
controller.seedRows([_run(1, 'running')]);
|
||||
expect(controller.entries, isEmpty);
|
||||
|
||||
controller.observeFrame({
|
||||
'type': 'run_event',
|
||||
'run_id': 1,
|
||||
'status': 'failed',
|
||||
'diagnostic': 'Stage 4 failed',
|
||||
'finished_at': _at(const Duration(minutes: 1)),
|
||||
});
|
||||
controller.observeFrame({
|
||||
'type': 'run_event',
|
||||
'run_event': {
|
||||
'run_id': 1,
|
||||
'status': 'failed',
|
||||
'diagnostic': 'Stage 4 failed',
|
||||
'finished_at': _at(const Duration(minutes: 1)),
|
||||
},
|
||||
});
|
||||
|
||||
expect(controller.entries.map((entry) => entry.key), ['1:Failed']);
|
||||
expect(controller.entries.single.detail, 'Stage 4 failed');
|
||||
expect(controller.transitions.map((item) => item.key), ['1:Failed']);
|
||||
expect(controller.entries.map((entry) => entry.key), ['1:Failed']);
|
||||
expect(controller.entries.single.detail, 'Stage 4 failed');
|
||||
expect(controller.transitions.map((item) => item.key), ['1:Failed']);
|
||||
|
||||
// The same state again is not a new transition.
|
||||
controller.observeFrame({
|
||||
'type': 'run_event',
|
||||
'run_id': 1,
|
||||
'status': 'failed',
|
||||
'diagnostic': 'Stage 4 failed',
|
||||
});
|
||||
expect(controller.entries, hasLength(1));
|
||||
expect(controller.transitions, hasLength(1));
|
||||
});
|
||||
// The same state again is not a new transition.
|
||||
controller.observeFrame({
|
||||
'type': 'run_event',
|
||||
'run_event': {
|
||||
'run_id': 1,
|
||||
'status': 'failed',
|
||||
'diagnostic': 'Stage 4 failed',
|
||||
},
|
||||
});
|
||||
expect(controller.entries, hasLength(1));
|
||||
expect(controller.transitions, hasLength(1));
|
||||
},
|
||||
);
|
||||
|
||||
test('a live frame for a new run can create its own summary', () async {
|
||||
final controller = _controller(MemoryAttentionStore());
|
||||
|
||||
@@ -46,6 +46,67 @@ void main() {
|
||||
gateway.framesController.close();
|
||||
});
|
||||
|
||||
test(
|
||||
'wire envelopes update new rows, progress and selected completion',
|
||||
() async {
|
||||
controller.listen(gateway.frames);
|
||||
final load = controller.load();
|
||||
gateway.listReply(0, [
|
||||
{'id': 1, 'pipeline_id': 7, 'name': 'test', 'status': 'running'},
|
||||
]);
|
||||
await load;
|
||||
final select = controller.select(1);
|
||||
gateway.detailReply(1, 0, {'id': 1, 'status': 'running'});
|
||||
await select;
|
||||
controller.setPipeline(7);
|
||||
controller.setQuery('test');
|
||||
void event(JsonMap value) => gateway.framesController.add({
|
||||
'type': 'run_event',
|
||||
'run_event': value,
|
||||
});
|
||||
event({
|
||||
'run_id': 2,
|
||||
'pipeline_id': 7,
|
||||
'name': 'test new',
|
||||
'status': 'running',
|
||||
'completed_steps': 0,
|
||||
});
|
||||
event({'run_id': 1, 'status': 'running', 'completed_steps': 3});
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
expect(controller.runs, hasLength(2));
|
||||
expect(
|
||||
controller.runs.firstWhere((run) => run['id'] == 1)['completed_steps'],
|
||||
3,
|
||||
);
|
||||
expect(controller.detail?['completed_steps'], 3);
|
||||
event({'run_id': 1, 'status': 'succeeded', 'completed_steps': 4});
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
expect(controller.detail?['status'], 'succeeded');
|
||||
expect(
|
||||
controller.runs.firstWhere((run) => run['id'] == 1)['status'],
|
||||
'succeeded',
|
||||
);
|
||||
expect(controller.selectedRunId, 1);
|
||||
expect(controller.pipelineId, 7);
|
||||
expect(controller.query, 'test');
|
||||
expect(
|
||||
gateway.listCalls,
|
||||
1,
|
||||
reason: 'valid deltas require no list reload',
|
||||
);
|
||||
await Future<void>.delayed(const Duration(milliseconds: 180));
|
||||
expect(gateway.details[1], hasLength(2));
|
||||
gateway.detailReply(1, 1, {
|
||||
'id': 1,
|
||||
'status': 'succeeded',
|
||||
'completed_steps': 4,
|
||||
'summary': 'Fresh completion evidence',
|
||||
});
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
expect(controller.detail?['summary'], 'Fresh completion evidence');
|
||||
},
|
||||
);
|
||||
|
||||
test('late selection response cannot replace latest selection', () async {
|
||||
final first = controller.select(1);
|
||||
final second = controller.select(2);
|
||||
|
||||
@@ -53,6 +53,7 @@ Widget _materialScreen(
|
||||
int? initialRunId,
|
||||
int? initialPipelineId,
|
||||
int syncToken = 0,
|
||||
int listRefreshToken = 0,
|
||||
ValueChanged<int>? onRunSelected,
|
||||
ValueChanged<int?>? onBack,
|
||||
ValueChanged<int?>? onPipelineFilterChanged,
|
||||
@@ -63,6 +64,7 @@ Widget _materialScreen(
|
||||
initialRunId: initialRunId,
|
||||
initialPipelineId: initialPipelineId,
|
||||
syncToken: syncToken,
|
||||
listRefreshToken: listRefreshToken,
|
||||
onRunSelected: onRunSelected,
|
||||
onBack: onBack,
|
||||
onPipelineFilterChanged: onPipelineFilterChanged,
|
||||
@@ -307,6 +309,42 @@ void main() {
|
||||
expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget);
|
||||
});
|
||||
|
||||
for (final reconnect in [false, true]) {
|
||||
testWidgets('foreground refresh resyncs detail (reconnect: $reconnect)', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(_materialScreen(gateway, initialRunId: 2));
|
||||
await _mountList(tester, gateway);
|
||||
gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'});
|
||||
await tester.pump();
|
||||
await tester.pumpWidget(
|
||||
_materialScreen(
|
||||
gateway,
|
||||
initialRunId: 2,
|
||||
syncToken: reconnect ? 1 : 0,
|
||||
listRefreshToken: 1,
|
||||
),
|
||||
);
|
||||
expect(
|
||||
gateway.listRequests,
|
||||
hasLength(2),
|
||||
reason: 'simultaneous reconnect and foreground refresh coalesce',
|
||||
);
|
||||
gateway.replyList(1, _runs);
|
||||
await tester.pump();
|
||||
expect(gateway.detailRequests[2], hasLength(2));
|
||||
expect(
|
||||
runDetailText('Beta run'),
|
||||
findsOneWidget,
|
||||
reason: 'the selected detail remains visible during refresh',
|
||||
);
|
||||
gateway.replyDetail(2, 1, {'id': 2, 'title': 'Fresh detail'});
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(runDetailText('Fresh detail'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets(
|
||||
'wide Cupertino host keeps list and detail bars while pending',
|
||||
(tester) async {
|
||||
|
||||
Reference in New Issue
Block a user