fa95c2fcae
Keep the running indicator and Needs you flow, but remove the failed-count badge and its tab count plumbing until unseen-state behavior is addressed. Preserve the unfinished seen-state work separately. Verify application, Runs, attention and shell regressions.
96 lines
3.0 KiB
Dart
96 lines
3.0 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
|
import 'package:pipelines_app/shell/attention_badge.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
|
import 'pipelines_app_test.dart' show pumpApp, replyList;
|
|
|
|
void main() {
|
|
testWidgets('running updates across tabs without restoring the error counter', (
|
|
tester,
|
|
) async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
final channel = FakeChannel()..readyCompleter.complete();
|
|
final client = PipelinesClient(channelFactory: (_) => channel);
|
|
final provider = PlatformRouteInformationProvider(
|
|
initialRouteInformation: RouteInformation(uri: Uri.parse('/runs')),
|
|
);
|
|
addTearDown(provider.dispose);
|
|
await pumpApp(tester, channel: channel, client: client, provider: provider);
|
|
final now = DateTime.now().toIso8601String();
|
|
await replyList(
|
|
tester,
|
|
channel,
|
|
runs: [
|
|
{
|
|
'id': 1,
|
|
'pipeline_id': 1,
|
|
'name': 'fixture',
|
|
'title': 'Running job',
|
|
'status': 'running',
|
|
'executing': true,
|
|
'created_at': now,
|
|
},
|
|
{
|
|
'id': 2,
|
|
'pipeline_id': 1,
|
|
'name': 'fixture',
|
|
'title': 'Failed job',
|
|
'status': 'failed',
|
|
'executing': false,
|
|
'created_at': now,
|
|
},
|
|
{
|
|
'id': 3,
|
|
'pipeline_id': 1,
|
|
'name': 'fixture',
|
|
'title': 'Decision job',
|
|
'status': 'waiting',
|
|
'executing': false,
|
|
'created_at': now,
|
|
},
|
|
],
|
|
);
|
|
await tester.pumpAndSettle();
|
|
RunsDestinationIcon counts() =>
|
|
tester.widget<RunsDestinationIcon>(find.byType(RunsDestinationIcon));
|
|
expect(counts().running, 1);
|
|
expect(find.byKey(const ValueKey('shell.badge.runs.failed')), findsNothing);
|
|
expect(counts().attention, 2);
|
|
|
|
await tester.tap(find.byKey(const ValueKey('shell.destination.pipelines')));
|
|
await tester.pumpAndSettle();
|
|
channel.incoming.add(
|
|
jsonEncode({
|
|
'type': 'run_event',
|
|
'run_id': 3,
|
|
'status': 'failed',
|
|
'executing': false,
|
|
}),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(provider.value.uri.path, '/pipelines');
|
|
expect(counts().running, 1);
|
|
expect(find.byKey(const ValueKey('shell.badge.runs.failed')), findsNothing);
|
|
// Waiting -> failed must repaint even though total attention is unchanged.
|
|
expect(counts().attention, 2);
|
|
|
|
channel.incoming.add(
|
|
jsonEncode({
|
|
'type': 'run_event',
|
|
'run_id': 1,
|
|
'status': 'succeeded',
|
|
'executing': false,
|
|
}),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(counts().running, 0);
|
|
expect(find.byKey(const ValueKey('shell.badge.runs.failed')), findsNothing);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
}
|