a1c4c1c402
Settings leaves the tab bar (Pipelines, Runs, Chat, Search) and opens as a page from a gear in the Pipelines bar, keeping /settings, its keys and a Back to Pipelines (also the system Back). Every floating tab bar shows icons only, named for assistive technology. On wide windows the shell's tab bar stays at the bottom right; a split detail learns its height plus a 12px gap, so its tabs or the chat composer float above it, and pages the detail opens (the stage page) stay in its pane through its own navigator.
121 lines
4.1 KiB
Dart
121 lines
4.1 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 '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
|
import 'pipelines_app_test.dart' show pumpApp, replyList;
|
|
import 'pipelines_replies.dart';
|
|
|
|
/// The app lifts one attention controller above the destinations: the Runs
|
|
/// list seeds it when it loads and the app folds pushed `run_event` frames, so
|
|
/// the shell's Runs tab badge moves while another destination is shown.
|
|
void main() {
|
|
final needingAttention = RegExp('needing attention');
|
|
|
|
Finder badgeCount(String count) =>
|
|
find.descendant(of: find.byType(Badge), matching: find.text(count));
|
|
|
|
testWidgets(
|
|
'a run_event folded to waiting raises the Runs tab badge from Pipelines',
|
|
(tester) async {
|
|
final semantics = tester.ensureSemantics();
|
|
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,
|
|
);
|
|
await replyList(
|
|
tester,
|
|
channel,
|
|
runs: [
|
|
{
|
|
'id': 1,
|
|
'pipeline_id': 4,
|
|
'name': 'nightly',
|
|
'title': 'Nightly build',
|
|
'status': 'running',
|
|
'created_at': DateTime.now().toIso8601String(),
|
|
},
|
|
],
|
|
);
|
|
expect(find.text('Nightly build'), findsWidgets);
|
|
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
|
|
expect(find.bySemanticsLabel(needingAttention), findsNothing);
|
|
|
|
await tester.tap(
|
|
find.byKey(const ValueKey('shell.destination.pipelines')),
|
|
);
|
|
await tester.pump();
|
|
expect(provider.value.uri.path, '/pipelines');
|
|
await waitForRequest(tester, channel, 'list_pipelines');
|
|
expect(find.text('Nightly build'), findsNothing);
|
|
|
|
channel.incoming.add(
|
|
jsonEncode({'type': 'run_event', 'run_id': 1, 'status': 'waiting'}),
|
|
);
|
|
await tester.pump();
|
|
await tester.pump();
|
|
|
|
expect(provider.value.uri.path, '/pipelines');
|
|
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isTrue);
|
|
expect(badgeCount('1'), findsOneWidget);
|
|
expect(
|
|
find.bySemanticsLabel(RegExp('Notifications, 1 needing attention')),
|
|
findsOneWidget,
|
|
);
|
|
|
|
// The decision taken elsewhere clears the badge the same way.
|
|
channel.incoming.add(
|
|
jsonEncode({'type': 'run_event', 'run_id': 1, 'status': 'succeeded'}),
|
|
);
|
|
await tester.pump();
|
|
await tester.pump();
|
|
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
|
|
expect(badgeCount('1'), findsNothing);
|
|
expect(find.bySemanticsLabel(needingAttention), findsNothing);
|
|
semantics.dispose();
|
|
},
|
|
);
|
|
|
|
testWidgets('a new waiting run pushed before any list read is counted', (
|
|
tester,
|
|
) async {
|
|
final channel = FakeChannel()..readyCompleter.complete();
|
|
final client = PipelinesClient(channelFactory: (_) => channel);
|
|
final provider = PlatformRouteInformationProvider(
|
|
initialRouteInformation: RouteInformation(uri: Uri.parse('/settings')),
|
|
);
|
|
addTearDown(provider.dispose);
|
|
|
|
await pumpApp(tester, channel: channel, client: client, provider: provider);
|
|
expect(tester.widget<Badge>(find.byType(Badge)).isLabelVisible, isFalse);
|
|
|
|
channel.incoming.add(
|
|
jsonEncode({
|
|
'type': 'run_event',
|
|
'run_id': 9,
|
|
'pipeline_id': 4,
|
|
'name': 'nightly',
|
|
'title': 'Arrived while away',
|
|
'status': 'waiting',
|
|
'created_at': DateTime.now().toIso8601String(),
|
|
}),
|
|
);
|
|
await tester.pump();
|
|
await tester.pump();
|
|
|
|
expect(provider.value.uri.path, '/settings');
|
|
expect(badgeCount('1'), findsOneWidget);
|
|
});
|
|
}
|