Merge branch 'main' into run/artifacts-split

This commit is contained in:
2026-10-31 12:56:19 +00:00
137 changed files with 5916 additions and 1382 deletions
+1 -1
View File
@@ -351,7 +351,7 @@ void main() {
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
await tester.pump(const Duration(milliseconds: 400));
expectVisitHeading(tester, 'plan', 5);
expectVisitHeading(tester, 'plan', 2);
expect(provider.value.uri.path, '/runs/77/stage/plan');
expect(provider.value.uri.query, 'visit=1');
});
+3 -3
View File
@@ -401,7 +401,7 @@ void main() {
await tester.pump();
await tester.pump();
expect(find.text('run #7 · Preserved run'), findsOneWidget);
expect(find.text('Run 7 · Preserved run'), findsOneWidget);
await tester.tap(find.byKey(const ValueKey('search.result.run:7')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
@@ -497,7 +497,7 @@ void main() {
expect(provider.value.uri.path, '/runs/7');
expect(find.byType(SearchScreen), findsNothing);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expectVisitHeading(tester, 'build', 2);
expectVisitHeading(tester, 'build', 1);
// Leave the visit page (it covers the shell), then a retired field hit
// opens the plain Summary with no visit.
@@ -608,7 +608,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expectVisitHeading(tester, 'build', 2);
expectVisitHeading(tester, 'build', 1);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
@@ -13,7 +13,7 @@ import 'templates_wiring_test.dart' show openSettings, openTemplates, pumpApp;
/// The app-level Templates page: one bar (Back + Refresh), the gallery and an
/// open template reach the top edge, start below the bar at rest and scroll
/// behind it. Cupertino draws inset-grouped rows on the grouped background.
/// behind it. Both hosts draw the shared list rows on the page background.
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
@@ -69,13 +69,14 @@ void main() {
)
.first,
);
expect(scaffold.backgroundColor, AppColors.groupedBackground);
// Plain shared rows on the page background, like the other lists.
expect(scaffold.backgroundColor, AppColors.background);
expect(
find.descendant(
of: gallery,
matching: find.byType(CupertinoListSection),
),
findsOneWidget,
findsNothing,
);
}
@@ -0,0 +1,27 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_preview_failure.dart';
void main() {
test('fetch failures read as plain language, never raw errors', () {
expect(
artifactPreviewFailureMessage(),
'The preview could not be loaded. Check the connection and try again.',
);
expect(
artifactPreviewFailureMessage(status: 404),
'This file is no longer on the server.',
);
expect(
artifactPreviewFailureMessage(status: 403),
'The server did not allow this file to be opened.',
);
expect(
artifactPreviewFailureMessage(status: 502),
'The server could not send this file right now.',
);
expect(
artifactPreviewFailureMessage(status: 418),
'The preview could not be loaded (status 418).',
);
});
}
@@ -12,6 +12,8 @@ import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_record.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_external_open.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_gallery_page.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_content.dart'
show artifactPreviewRetryKey;
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_fetch.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_page.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
@@ -464,8 +466,39 @@ void main() {
pending.complete(ArtifactFetchResult(status: 404, bytes: Uint8List(0)));
await tester.pumpAndSettle();
expect(find.text('The server answered 404.'), findsOneWidget);
expect(find.text('This file is no longer on the server.'), findsOneWidget);
expect(find.textContaining('answered'), findsNothing);
expect(find.byType(SelectableText), findsNothing);
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
});
testWidgets('Retry fetches a failed preview again', (tester) async {
final text = recordedArtifact(
'notes.txt',
url: '/artifacts/1/1/notes.txt',
contentType: 'text/plain',
);
final group = _group([text]);
var calls = 0;
await _pumpViewer(
tester,
groups: [group],
selected: artifactVisitIdentity(group, text),
fetch: (_) async {
calls++;
if (calls == 1) throw const ArtifactFetchException('network down');
return ArtifactFetchResult(
status: 200,
bytes: Uint8List.fromList('hello'.codeUnits),
);
},
);
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
await tester.tap(find.byKey(artifactPreviewRetryKey));
await tester.pumpAndSettle();
expect(calls, 2);
expect(find.byKey(artifactPreviewRetryKey), findsNothing);
expect(find.text('hello'), findsOneWidget);
});
testWidgets('a network failure is reported instead of an empty preview', (
@@ -483,8 +516,15 @@ void main() {
selected: artifactVisitIdentity(group, text),
fetch: (_) async => throw const ArtifactFetchException('network down'),
);
expect(find.textContaining('Could not load preview'), findsOneWidget);
expect(find.textContaining('network down'), findsOneWidget);
// A friendly line with Retry, never the raw exception text.
expect(
find.text(
'The preview could not be loaded. Check the connection and try again.',
),
findsOneWidget,
);
expect(find.textContaining('network down'), findsNothing);
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
});
testWidgets('Cupertino draws the same text preview and controls', (
@@ -7,6 +7,7 @@ import 'package:pipelines_app/features/attention/notify/notification_controller.
import 'package:pipelines_app/features/attention/notify/notification_models.dart';
import 'package:pipelines_app/features/attention/notify/notification_store.dart';
import 'package:pipelines_app/features/attention/ui/needs_you_runs_heading.dart';
import 'package:pipelines_app/features/attention/ui/notification_permission_tile.dart';
import 'package:pipelines_app/features/settings/settings_notifications_section.dart';
import 'notification_test_support.dart';
@@ -70,13 +71,13 @@ void main() {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SettingsNotificationsSection(controller: notify),
),
home: Scaffold(body: SettingsNotificationsSection(controller: notify)),
),
);
await tester.pump();
expect(find.text(notificationRationale), findsOneWidget);
// One compact row: the short state, not the long rationale paragraph.
expect(find.byKey(notificationStateKey), findsOneWidget);
expect(find.text(notificationRationale), findsNothing);
// A denied platform answer shows its own words and no Enable action.
final denied = NotificationController(
@@ -86,12 +87,11 @@ void main() {
addTearDown(denied.dispose);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: SettingsNotificationsSection(controller: denied),
),
home: Scaffold(body: SettingsNotificationsSection(controller: denied)),
),
);
await tester.pump();
expect(find.text(notificationRationale), findsOneWidget);
expect(find.byKey(notificationStateKey), findsOneWidget);
expect(find.text(notificationRationale), findsNothing);
});
}
@@ -0,0 +1,198 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/attention/domain/attention_acks.dart';
import 'package:pipelines_app/features/attention/runtime/attention_ack_queue.dart';
import 'package:pipelines_app/features/attention/runtime/attention_ack_sync.dart';
import 'package:pipelines_app/features/attention/runtime/attention_controller.dart';
import 'package:pipelines_app/features/attention/runtime/attention_store.dart';
import 'fake_ack_server.dart';
final _now = DateTime(2026, 10, 22, 12);
Map<String, dynamic> _failed(int id) => {
'id': id,
'name': 'release',
'title': 'Run $id',
'status': 'failed',
'created_at': _now.subtract(const Duration(hours: 1)).toIso8601String(),
'finished_at': _now.subtract(const Duration(minutes: 30)).toIso8601String(),
};
/// One device: its gateway, sync, local stores and Needs-you controller.
class _Device {
_Device(FakeAckServer server)
: client = server.connect(),
store = MemoryAttentionStore(),
queue = MemoryAttentionAckQueue() {
sync = AttentionAckSync(gateway: client, queue: queue);
attention = AttentionController(store: store, sync: sync, now: () => _now);
}
final FakeAckClient client;
final MemoryAttentionStore store;
final MemoryAttentionAckQueue queue;
late final AttentionAckSync sync;
late final AttentionController attention;
Future<void> start(List<Map<String, dynamic>> rows) async {
await sync.load();
await attention.load();
attention.seedRows(rows);
await sync.connected();
}
List<int> get shown => [for (final e in attention.entries) e.runId];
void dispose() {
attention.dispose();
sync.dispose();
}
}
void main() {
late FakeAckServer server;
late _Device web;
late _Device phone;
final rows = [_failed(1), _failed(2), _failed(3)];
setUp(() async {
server = FakeAckServer();
web = _Device(server);
phone = _Device(server);
await web.start(rows);
await phone.start(rows);
});
tearDown(() {
web.dispose();
phone.dispose();
});
test(
'a dismissal on one device disappears on the other via the push',
() async {
expect(phone.shown, [3, 2, 1]);
await web.attention.dismiss(
web.attention.entries.firstWhere((e) => e.runId == 2),
);
await settle();
expect(web.shown, [3, 1]);
expect(phone.shown, [3, 1]);
expect(server.state.dismissed, {'2:Failed'});
// The other device caches the shared identity locally for offline use.
expect(phone.store.stored, contains('2:Failed'));
// The receiving device did not send anything back.
expect(phone.client.count('ack_attention'), 0);
},
);
test('Clear all on the web clears the phone too', () async {
final snapshot = web.attention.entries;
await web.attention.clearAll(snapshot);
await settle();
expect(web.shown, isEmpty);
expect(phone.shown, isEmpty);
expect(server.state.dismissed, {'1:Failed', '2:Failed', '3:Failed'});
});
test('a device that connects later loads the shared set', () async {
await web.attention.dismiss(web.attention.entries.first);
await settle();
final late = _Device(server);
addTearDown(late.dispose);
await late.start(rows);
await settle();
expect(late.shown, [2, 1]);
});
test(
'a dismissal made offline is queued, then synced on reconnect',
() async {
phone.client.online = false;
await phone.attention.dismiss(phone.attention.entries.first);
await settle();
expect(phone.shown, [2, 1]);
expect(web.shown, [3, 2, 1]);
expect(phone.sync.pending.dismissed, {'3:Failed'});
expect(AttentionAcks.decode(phone.queue.stored).dismissed, {'3:Failed'});
// A restarted app reads the persisted queue.
final restarted = AttentionAckSync(
gateway: phone.client,
queue: phone.queue,
);
addTearDown(restarted.dispose);
await restarted.load();
expect(restarted.pending.dismissed, {'3:Failed'});
phone.client.online = true;
await phone.sync.connected();
await settle();
expect(phone.sync.pending.isEmpty, isTrue);
expect(AttentionAcks.decode(phone.queue.stored).isEmpty, isTrue);
expect(web.shown, [2, 1]);
},
);
test('a refused batch is dropped; a legacy server keeps the queue', () async {
server.refuse = 'invalid attention identity';
await web.sync.acknowledge(dismissed: ['9:Failed']);
expect(web.sync.pending.isEmpty, isTrue);
server
..refuse = null
..legacy = true;
await web.sync.connected();
expect(web.sync.supported, isFalse);
await web.attention.dismiss(web.attention.entries.first);
await settle();
expect(web.shown, [2, 1], reason: 'the local dismissal still applies');
expect(web.sync.pending.dismissed, {'3:Failed'});
server.legacy = false;
await web.sync.connected();
await settle();
expect(web.sync.pending.isEmpty, isTrue);
expect(phone.shown, [2, 1]);
});
test('batches stay within the server bound', () {
final big = AttentionAcks(
dismissed: {for (var i = 1; i <= 600; i++) '$i:Failed'},
chatSeen: const {'ses_a': 1},
);
final batch = attentionAckBatch(big);
expect(batch.length, maxAttentionAckItems);
final rest = big.without(batch);
expect(rest.length, big.length - maxAttentionAckItems);
});
test('the send-only path matches replies and refusals by id', () async {
final client = server.connect();
final sync = AttentionAckSync(
gateway: client,
queue: MemoryAttentionAckQueue(),
sendOnly: client.sendOnly,
);
addTearDown(sync.dispose);
await sync.acknowledge(dismissed: ['1:Failed']);
await settle();
expect(sync.pending.isEmpty, isTrue);
expect(phone.shown, [3, 2]);
server.refuse = 'invalid attention identity';
await sync.acknowledge(dismissed: ['2:Failed']);
await settle();
expect(sync.pending.isEmpty, isTrue, reason: 'a refusal is dropped');
server.refuse = null;
await web.attention.dismiss(web.attention.entries.first);
await settle();
await sync.connected();
expect(sync.acks.dismissed, containsAll(['1:Failed', '3:Failed']));
});
}
@@ -0,0 +1,113 @@
import 'dart:async';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/core/transport/connection_state.dart';
import 'package:pipelines_app/features/attention/domain/attention_acks.dart';
/// An in-memory stand-in for the server's `attention_acks` / `ack_attention`
/// protocol with any number of connected clients. Like the Go handler, an ack
/// that changes the set is pushed to every *other* connected client as an
/// `attention_acks_changed` delta.
class FakeAckServer {
AttentionAcks state = const AttentionAcks();
final clients = <FakeAckClient>[];
/// When set, every ack_attention is refused with this reason.
String? refuse;
/// When true the server predates shared acks and answers `pong`.
bool legacy = false;
/// The chat list this server reports, for chat-list controllers.
List<JsonMap> chatSessions = const [];
FakeAckClient connect() {
final client = FakeAckClient(this);
clients.add(client);
return client;
}
JsonMap _reply() => {
'type': 'attention_acks',
'attention_acks': state.toJson(),
};
JsonMap _ack(FakeAckClient from, JsonMap fields) {
final incoming = AttentionAcks.fromJson(fields['attention_acks']);
final delta = AttentionAcks(
dismissed: incoming.dismissed.difference(state.dismissed),
chatSeen: {
for (final entry in incoming.chatSeen.entries)
if (entry.value > (state.chatSeen[entry.key] ?? 0))
entry.key: entry.value,
},
);
state = state.merge(incoming);
if (!delta.isEmpty) {
for (final client in clients) {
if (identical(client, from) || !client.online) continue;
client.pushed.add({
'type': 'attention_acks_changed',
'attention_acks': delta.toJson(),
});
}
}
return _reply();
}
}
class FakeAckClient implements ApiGateway {
FakeAckClient(this.server);
final FakeAckServer server;
final pushed = StreamController<JsonMap>.broadcast();
final calls = <String>[];
bool online = true;
@override
Stream<JsonMap> get frames => pushed.stream;
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async {
calls.add(type);
if (!online) throw const NotConnectedError();
switch (type) {
case 'attention_acks':
case 'ack_attention':
if (server.legacy) return {'type': 'pong'};
if (type == 'attention_acks') return server._reply();
final reason = server.refuse;
if (reason != null) throw ProtocolError(reason);
return server._ack(this, fields);
case 'chat_sessions':
return {'type': 'chat_sessions', 'chat_sessions': server.chatSessions};
}
return {'type': 'pong'};
}
int count(String type) => calls.where((call) => call == type).length;
var _sequence = 0;
/// The socket's send-only path: the reply (or error) arrives later as a
/// frame carrying the request id, like the real transport.
String sendOnly(String type, JsonMap fields) {
if (!online) throw const NotConnectedError();
final id = 'send-${++_sequence}';
scheduleMicrotask(() async {
try {
pushed.add({...await call(type, fields), 'id': id});
} on ProtocolError catch (error) {
pushed.add({'type': 'error', 'id': id, 'error': error.message});
}
});
return id;
}
}
/// Lets queued microtasks and stream deliveries settle.
Future<void> settle() async {
for (var i = 0; i < 10; i++) {
await Future<void>.delayed(Duration.zero);
}
}
@@ -33,7 +33,7 @@ void main() {
for (final native in [false, true]) {
final host = native ? 'Cupertino' : 'Material';
testWidgets('$host shows the state\'s own honest copy', (tester) async {
testWidgets('$host shows a compact row for each state', (tester) async {
final cases = <NotificationPermissionState, String>{
NotificationPermissionState.unsupported: notificationUnsupportedCopy,
NotificationPermissionState.needsSecureContext:
@@ -46,10 +46,15 @@ void main() {
await tester.pumpWidget(
_page(state: entry.key, cupertino: native, onRequest: _noop),
);
// The Settings section owns the heading; the tile is its body.
final view = notificationPermissionView(entry.key);
// The Settings section owns the heading; the tile is one short row.
expect(find.text(notificationSectionTitle), findsNothing);
expect(find.text(notificationRationale), findsOneWidget);
expect(find.text(entry.value), findsOneWidget, reason: '${entry.key}');
expect(find.text(notificationRationale), findsNothing);
expect(find.text(view.headline), findsOneWidget);
expect(find.text(view.helper), findsOneWidget);
// The full honest sentence is what assistive technology reads.
expect(view.body, entry.value);
expect(find.bySemanticsLabel(entry.value), findsOneWidget);
expect(
find.byKey(notificationEnableKey),
entry.key == NotificationPermissionState.notRequested
@@ -70,8 +75,9 @@ void main() {
cupertino: native,
),
);
expect(find.text(notificationDefaultAskedCopy), findsOneWidget);
expect(find.text(notificationDefaultCopy), findsNothing);
expect(find.text('Alerts are still off'), findsOneWidget);
expect(find.bySemanticsLabel(notificationDefaultAskedCopy), findsOne);
expect(find.bySemanticsLabel(notificationDefaultCopy), findsNothing);
});
testWidgets('$host Enable runs the explicit request', (tester) async {
@@ -115,16 +121,19 @@ void main() {
);
expect(tester.takeException(), isNull);
final rationale = tester.renderObject<RenderParagraph>(
find.text(notificationRationale),
final view = notificationPermissionView(
NotificationPermissionState.notRequested,
);
final helper = tester.renderObject<RenderParagraph>(
find.text(view.helper),
);
expect(
rationale.size.width,
helper.size.width,
greaterThan(100),
reason: 'the action must not squeeze the section copy',
reason: 'the action must not squeeze the row copy',
);
final body = tester.renderObject<RenderParagraph>(
find.text(notificationDefaultCopy),
find.text(view.headline),
);
expect(body.didExceedMaxLines, isFalse);
expect(find.byKey(notificationEnableKey), findsOneWidget);
@@ -125,11 +125,11 @@ void main() {
);
// The run-wide aggregate still counts the file this visit recorded.
expect(find.textContaining('1 file changed'), findsOneWidget);
expect(find.text('implementer'), findsOneWidget);
expect(find.text('implementer'), findsNothing);
expect(find.text('Visit 1 · completed'), findsOneWidget);
expect(
find.text(
'partial (1 files), 1 skipped, 2 omitted · Excluded protected files.',
'partial (1 file), 1 skipped, 2 omitted · Excluded protected files.',
),
findsOneWidget,
);
@@ -157,7 +157,7 @@ void main() {
await tester.pump();
expect(find.text('implementer'), findsNothing);
expect(find.text('reviewer'), findsOneWidget);
expect(find.text('reviewer'), findsNothing);
// The reviewer's first visit is Visit 1, not the run-wide step ordinal 2.
expect(find.text('Visit 1 · failed'), findsOneWidget);
expect(find.text('Visit 2 · failed'), findsNothing);
@@ -205,18 +205,18 @@ void main() {
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
await tester.pump();
// The reviewer's first recorded visit is Visit 1 too.
expect(find.text('reviewer'), findsOneWidget);
expect(find.text('reviewer'), findsNothing);
expect(find.text('Visit 1 · completed'), findsOneWidget);
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
await tester.pump();
expect(find.text('implementer'), findsOneWidget);
expect(find.text('implementer'), findsNothing);
expect(find.text('Visit 2 · completed'), findsOneWidget);
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
await tester.pump();
// The resumed reviewer visit records control.visit 6.
expect(find.text('reviewer'), findsOneWidget);
expect(find.text('reviewer'), findsNothing);
expect(find.text('Visit 6 · completed'), findsOneWidget);
expect(find.text('Visit 3 · completed'), findsNothing);
expect(find.text('Visit 4 · completed'), findsNothing);
@@ -411,7 +411,7 @@ void main() {
expect(parsed.files.map((entry) => entry.path), ['x']);
expect(
fileChangesSummary(parsed),
'partial (1 files), 2 skipped, 1 omitted · Excluded protected files.',
'partial (1 file), 2 skipped, 1 omitted · Excluded protected files.',
);
});
@@ -43,7 +43,7 @@ void main() {
// change as the operator pages.
expect(find.text('3 files changed'), findsOneWidget);
expect(find.text('1 of 2'), findsOneWidget);
expect(find.text('implementer'), findsOneWidget);
expect(find.text('implementer'), findsNothing);
expect(find.text('Visit 1 · completed'), findsOneWidget);
expect(find.text('lib/a.dart'), findsOneWidget);
expect(find.text('lib/c.dart'), findsNothing);
@@ -52,7 +52,7 @@ void main() {
await tester.pump();
// The shown page keeps its own visit identity in the heading.
expect(find.text('reviewer'), findsOneWidget);
expect(find.text('reviewer'), findsNothing);
expect(find.text('Visit 1 · completed'), findsOneWidget);
expect(find.text('lib/c.dart'), findsOneWidget);
expect(find.text('lib/a.dart'), findsNothing);
@@ -62,7 +62,7 @@ void main() {
await tester.tap(find.byKey(ChangesVisitPager.previousKey));
await tester.pump();
expect(find.text('implementer'), findsOneWidget);
expect(find.text('implementer'), findsNothing);
expect(find.text('lib/a.dart'), findsOneWidget);
expect(find.text('lib/c.dart'), findsNothing);
expect(find.text('1 of 2'), findsOneWidget);
@@ -104,11 +104,11 @@ void main() {
// The disabled Next is inert; the page stays on the last visit.
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
await tester.pump();
expect(find.text('reviewer'), findsOneWidget);
expect(find.text('reviewer'), findsNothing);
await tester.tap(find.byKey(ChangesVisitPager.previousKey));
await tester.pump();
expect(find.text('implementer'), findsOneWidget);
expect(find.text('implementer'), findsNothing);
expect(previous().onPressed, isNull);
});
@@ -133,7 +133,7 @@ void main() {
findsNothing,
);
// The single visit still keeps its identity heading.
expect(find.text('implementer'), findsOneWidget);
expect(find.text('implementer'), findsNothing);
expect(find.text('Visit 1 · completed'), findsOneWidget);
expect(find.text('lib/only.dart'), findsOneWidget);
});
@@ -154,12 +154,12 @@ void main() {
await tester.pumpWidget(materialHost(ChangesViewer(steps: first)));
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
await tester.pump();
expect(find.text('reviewer'), findsOneWidget);
expect(find.text('reviewer'), findsNothing);
await tester.pumpWidget(materialHost(ChangesViewer(steps: second)));
await tester.pump();
expect(tester.takeException(), isNull);
expect(find.text('implementer'), findsOneWidget);
expect(find.text('implementer'), findsNothing);
expect(find.text('Visit 1 · completed'), findsOneWidget);
expect(find.byKey(ChangesVisitPager.previousKey), findsNothing);
});
@@ -187,7 +187,7 @@ void main() {
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
await tester.pump();
expect(tester.takeException(), isNull);
expect(find.text('reviewer'), findsOneWidget);
expect(find.text('reviewer'), findsNothing);
expect(find.text('Visit 1 · completed'), findsOneWidget);
expect(find.text('lib/c.dart'), findsOneWidget);
});
@@ -210,7 +210,7 @@ void main() {
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
await tester.pump();
expect(find.text('reviewer'), findsOneWidget);
expect(find.text('reviewer'), findsNothing);
expect(
tester
.widget<CupertinoButton>(find.byKey(ChangesVisitPager.nextKey))
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/empty_detail_pane.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
@@ -52,7 +53,10 @@ void main() {
testWidgets('a wide window keeps the tab bar and list beside the open chat '
'at $size', (tester) async {
await _pumpShell(tester, size);
expect(find.text('Select a chat to open it here.'), findsOneWidget);
expect(
find.widgetWithText(EmptyDetailPane, 'Select a chat to open it here.'),
findsOneWidget,
);
expect(
tester.widget<AppListRow>(find.byKey(const Key('chat-row-a'))).selected,
isFalse,
@@ -0,0 +1,167 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/attention/runtime/attention_ack_queue.dart';
import 'package:pipelines_app/features/attention/runtime/attention_ack_sync.dart';
import 'package:pipelines_app/features/chat/data/chat_repository.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_session_local.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_controller.dart';
import '../../../attention/runtime/fake_ack_server.dart';
import 'chat_test_harness.dart';
JsonMap _text(String id) => {
'type': 'chat_event',
'chat_event': {'session_id': id, 'kind': 'text', 'delta': 'hello'},
};
/// One device's chat list sharing read state through [FakeAckServer].
class _Device {
_Device(FakeAckServer server, {required this.clock})
: client = server.connect(),
local = MemoryChatSessionLocalStore() {
sync = AttentionAckSync(gateway: client, queue: MemoryAttentionAckQueue());
bindAttentionAckSync(client, sync);
list = ChatSessionsController(
ChatRepository(client),
localStore: local,
nowMillis: () => clock(),
activeAckDelay: const Duration(milliseconds: 20),
);
}
final FakeAckClient client;
final MemoryChatSessionLocalStore local;
final int Function() clock;
late final AttentionAckSync sync;
late final ChatSessionsController list;
Future<void> start() async {
await sync.connected();
await list.refresh();
await settle();
}
bool isNew(String id) =>
list.isUnseen(list.sessions.firstWhere((row) => row['id'] == id));
JsonMap row(String id) => list.sessions.firstWhere((row) => row['id'] == id);
void dispose() {
list.dispose();
sync.dispose();
}
}
void main() {
late FakeAckServer server;
late _Device web;
late _Device phone;
var now = 5000;
setUp(() async {
now = 5000;
server = FakeAckServer()
..chatSessions = [
{'id': 'ses_a', 'title': 'A', 'directory': '/w', 'updated_at': 1000},
{'id': 'ses_b', 'title': 'B', 'directory': '/w', 'updated_at': 1000},
];
web = _Device(server, clock: () => now);
phone = _Device(server, clock: () => now);
await web.start();
await phone.start();
});
tearDown(() {
web.dispose();
phone.dispose();
});
void pushToAll(JsonMap frame) {
for (final client in server.clients) {
client.pushed.add(frame);
}
}
test(
'opening a chat on one device clears its New badge everywhere',
() async {
pushToAll(_text('ses_a'));
await settle();
expect(web.isNew('ses_a'), isTrue);
expect(phone.isNew('ses_a'), isTrue);
now = 6000;
await web.list.markOpened(web.row('ses_a'));
await settle();
expect(server.state.chatSeen['ses_a'], 6000);
expect(phone.isNew('ses_a'), isFalse);
expect(phone.local.state?.watermark('ses_a'), 6000);
// Only the opened chat is affected.
pushToAll(_text('ses_b'));
await settle();
expect(phone.isNew('ses_b'), isTrue);
},
);
test('an earlier acknowledgement never clears later content', () async {
now = 6000;
await web.list.markOpened(web.row('ses_a'));
web.list.activeSessionId = null;
await settle();
// New content after the open: the phone marks it New and a reload of the
// same shared watermark must not clear it.
pushToAll(_text('ses_a'));
await settle();
expect(phone.isNew('ses_a'), isTrue);
await phone.sync.connected();
await settle();
expect(phone.isNew('ses_a'), isTrue);
});
test('content arriving in a chat open elsewhere is read there', () async {
now = 6000;
await web.list.markOpened(web.row('ses_a'));
await settle();
now = 7000;
pushToAll(_text('ses_a'));
await settle();
expect(phone.isNew('ses_a'), isTrue);
expect(web.isNew('ses_a'), isFalse);
// The open chat acknowledges once its stream goes quiet (20 ms here).
for (var i = 0; i < 100 && server.state.chatSeen['ses_a'] != 7000; i++) {
await Future<void>.delayed(const Duration(milliseconds: 20));
}
await settle();
expect(server.state.chatSeen['ses_a'], 7000);
expect(phone.isNew('ses_a'), isFalse);
});
test('a chat opened offline is synced and cleared on reconnect', () async {
pushToAll(_text('ses_a'));
await settle();
web.client.online = false;
now = 6000;
await web.list.markOpened(web.row('ses_a'));
await settle();
expect(phone.isNew('ses_a'), isTrue);
expect(web.sync.pending.chatSeen, {'ses_a': 6000});
web.client.online = true;
await web.sync.connected();
await settle();
expect(phone.isNew('ses_a'), isFalse);
// A device that was not connected for the push applies the stored set
// on its next connection.
final late = _Device(server, clock: () => now);
addTearDown(late.dispose);
late.local.state = const ChatSessionLocal(
seenAt: {'ses_a': 1000},
unseen: ['ses_a'],
);
await late.start();
expect(late.isNew('ses_a'), isFalse);
});
}
@@ -54,61 +54,64 @@ TextStyle _styleOf(WidgetTester tester, String text) =>
tester.renderObject<RenderParagraph>(find.textContaining(text)).text.style!;
void main() {
test('relative recency uses the web wording and never invents a time', () {
final now = DateTime(2026, 10, 22, 12);
final from = now.subtract;
test(
'relative recency uses shared compact wording and never invents a time',
() {
final now = DateTime(2026, 10, 22, 12);
final from = now.subtract;
expect(relativeChatSessionTime(null, now: now), '');
expect(relativeChatSessionTime(0, now: now), '');
expect(
relativeChatSessionTime(now.millisecondsSinceEpoch, now: now),
'just now',
);
expect(
relativeChatSessionTime(
from(const Duration(minutes: 5)).millisecondsSinceEpoch,
now: now,
),
'5 min ago',
);
expect(
relativeChatSessionTime(
from(const Duration(hours: 3)).millisecondsSinceEpoch,
now: now,
),
'3 hr ago',
);
expect(
relativeChatSessionTime(
from(const Duration(hours: 25)).millisecondsSinceEpoch,
now: now,
),
'1 day ago',
);
expect(
relativeChatSessionTime(
from(const Duration(days: 3)).millisecondsSinceEpoch,
now: now,
),
'3 days ago',
);
expect(
relativeChatSessionTime(
DateTime(2026, 10, 1, 9).millisecondsSinceEpoch,
now: now,
),
'1 Oct',
);
// The web formats with `Intl.DateTimeFormat('en-GB', …)`, whose short
// September is `Sept`; its own test asserts `12 Sept`.
expect(
relativeChatSessionTime(
DateTime(2026, 9, 12, 9).millisecondsSinceEpoch,
now: now,
),
'12 Sept',
);
});
expect(relativeChatSessionTime(null, now: now), '');
expect(relativeChatSessionTime(0, now: now), '');
expect(
relativeChatSessionTime(now.millisecondsSinceEpoch, now: now),
'just now',
);
expect(
relativeChatSessionTime(
from(const Duration(minutes: 5)).millisecondsSinceEpoch,
now: now,
),
'5m',
);
expect(
relativeChatSessionTime(
from(const Duration(hours: 3)).millisecondsSinceEpoch,
now: now,
),
'3h',
);
expect(
relativeChatSessionTime(
from(const Duration(hours: 25)).millisecondsSinceEpoch,
now: now,
),
'1d',
);
expect(
relativeChatSessionTime(
from(const Duration(days: 3)).millisecondsSinceEpoch,
now: now,
),
'3d',
);
expect(
relativeChatSessionTime(
DateTime(2026, 10, 1, 9).millisecondsSinceEpoch,
now: now,
),
'1 Oct',
);
// The web formats with `Intl.DateTimeFormat('en-GB', …)`, whose short
// September is `Sept`; its own test asserts `12 Sept`.
expect(
relativeChatSessionTime(
DateTime(2026, 9, 12, 9).millisecondsSinceEpoch,
now: now,
),
'12 Sep',
);
},
);
test('the subtitle and status come only from the row', () {
expect(
@@ -173,7 +176,7 @@ void main() {
);
final title = tester.getRect(find.textContaining('Unread chat'));
final time = tester.getRect(find.text('5 min ago'));
final time = tester.getRect(find.text('5m'));
final subtitle = tester.getRect(find.text('model-a · /work'));
final avatar = tester.getRect(
find.descendant(
@@ -197,10 +200,10 @@ void main() {
expect(_styleOf(tester, 'Read chat').fontWeight, FontWeight.w600);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
final accent = CupertinoTheme.of(
tester.element(find.text('5 min ago')),
tester.element(find.text('5m')),
).primaryColor;
expect(_styleOf(tester, '5 min ago').color, accent);
expect(_styleOf(tester, '2 hr ago').color, isNot(accent));
expect(_styleOf(tester, '5m').color, accent);
expect(_styleOf(tester, '2h').color, isNot(accent));
// Starred shows a small star by the title; running a badge on the avatar.
expect(
@@ -265,7 +268,7 @@ void main() {
expect(subtitle.didExceedMaxLines, isTrue);
// The time and the Closed word stay inside their row.
for (final (row, word) in [('s1', '3 days ago'), ('c1', 'Closed')]) {
for (final (row, word) in [('s1', '3d'), ('c1', 'Closed')]) {
expect(
tester.getRect(find.textContaining(word)).right,
lessThanOrEqualTo(
@@ -76,7 +76,7 @@ void main() {
], isUnseen: (session) => session['id'] == 's1');
final title = tester.getRect(find.text('Unread chat'));
final time = tester.getRect(find.text('5 min ago'));
final time = tester.getRect(find.text('5m'));
expect(time.left, greaterThan(title.right));
expect(time.center.dy, closeTo(title.center.dy, 2));
expect(
@@ -90,13 +90,10 @@ void main() {
);
// Unread: bold title, accent time and a dot; the read row stays muted.
final scheme = Theme.of(tester.element(find.text('5 min ago'))).colorScheme;
final scheme = Theme.of(tester.element(find.text('5m'))).colorScheme;
expect(tester.widget<Text>(find.text('5m')).style?.color, scheme.primary);
expect(
tester.widget<Text>(find.text('5 min ago')).style?.color,
scheme.primary,
);
expect(
tester.widget<Text>(find.text('2 hr ago')).style?.color,
tester.widget<Text>(find.text('2h')).style?.color,
scheme.onSurfaceVariant,
);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
@@ -183,7 +180,7 @@ void main() {
);
expect(subtitle.maxLines, 1);
expect(subtitle.didExceedMaxLines, isTrue);
for (final (row, word) in [('s1', '3 days ago'), ('c1', 'Closed')]) {
for (final (row, word) in [('s1', '3d'), ('c1', 'Closed')]) {
expect(
tester.getRect(find.textContaining(word)).right,
lessThanOrEqualTo(
@@ -112,9 +112,9 @@ void main() {
await _pumpPipelines(tester, gateway: gateway, pipelineId: 1, version: 2);
// The detail is open (not the "Select a pipeline." placeholder), and the
// The detail is open (not the "Select a pipeline to open it here." placeholder), and the
// detail request names the route's pinned version.
expect(find.text('Select a pipeline.'), findsNothing);
expect(find.text('Select a pipeline to open it here.'), findsNothing);
expect(find.text('Alpha review'), findsWidgets);
expect(
gateway
@@ -7,7 +7,7 @@ import 'fixtures.dart';
void main() {
group('formatting', () {
test('renders local timestamps, durations and ages', () {
test('renders local timestamps and bounded durations', () {
expect(formatLocalTimestamp('2026-10-17T21:26:00'), '17 Oct 21:26');
expect(formatLocalTimestamp(''), isNull);
expect(formatLocalTimestamp('not a time'), isNull);
@@ -15,15 +15,10 @@ void main() {
expect(formatDuration(45), '45s');
expect(formatDuration(125), '2m 5s');
expect(formatDuration(3720), '1h 2m');
expect(formatDuration(840000), '9d 17h');
expect(formatDuration(-4), '0s');
expect(stageCountText(1), '1 stage');
expect(stageCountText(2), '2 stages');
final now = DateTime(2026, 10, 17, 21, 30);
expect(formatRanAgo('2026-10-17T21:29:40', now), 'just now');
expect(formatRanAgo('2026-10-17T21:25:00', now), '5m ago');
expect(formatRanAgo('2026-10-17T19:30:00', now), '2h ago');
expect(formatRanAgo('2026-10-14T21:30:00', now), '3d ago');
expect(formatRanAgo('2026-10-17T22:00:00', now), 'just now');
});
test('maps the server status vocabulary and unknown values', () {
@@ -0,0 +1,75 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_summary_view.dart';
import 'package:pipelines_app/features/schedules/ui/pipeline/schedule_pipeline_wording.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'fixtures.dart';
/// The pipeline Summary is flat on both hosts: facts in the shared grid,
/// Schedules with Add as its heading's only action (no body Refresh), and
/// versions as the shared list row.
void main() {
for (final cupertino in [false, true]) {
testWidgets('pipeline Summary is a facts grid with flat sections '
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
final gateway = FakeGateway((type, fields) {
return switch (type) {
'list_pipelines' => pipelineListReply([
pipelineSummary(id: 1, name: 'Alpha review', version: 3),
]),
'list_runs' => runListReply([]),
'get_pipeline' => pipelineDetailReply(
pipelineDetail(
id: 1,
name: 'Alpha review',
version: 3,
latestVersion: 3,
versions: [versionSummary(2), versionSummary(3)],
),
),
'list_schedules' => {'type': 'schedules', 'schedules': <dynamic>[]},
_ => errorReply('unexpected $type'),
};
});
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final screen = PipelinesScreen(gateway: gateway);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
: MaterialApp(home: screen),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
expect(find.byKey(pipelineSummaryFactsKey), findsOneWidget);
// Short facts share a line instead of one label/value row each.
final latest = tester.getRect(
find.byKey(const ValueKey('pipeline-summary-latest-version')),
);
final versionCreated = tester.getRect(
find.byKey(const ValueKey('pipeline-summary-version-created')),
);
expect(versionCreated.top, moreOrLessEquals(latest.top));
expect(versionCreated.left, greaterThan(latest.right));
expect(find.text('Refresh'), findsNothing);
expect(find.text(scheduleAddLabel), findsNothing);
expect(find.byKey(scheduleAddKey), findsOneWidget);
expect(find.byType(CupertinoListSection), findsNothing);
expect(find.byType(ListTile), findsNothing);
final row = tester.widget<AppListRow>(
find.byKey(const Key('pipeline-version-3')),
);
expect(row.selected, isTrue);
expect(row.cupertino, cupertino);
expect(tester.takeException(), isNull);
});
}
}
@@ -141,7 +141,14 @@ void main() {
),
findsOneWidget,
);
expect(find.byType(CupertinoListTile), findsWidgets);
// Versions are the shared row in its Cupertino form, flat on the page.
expect(
tester
.widget<AppListRow>(find.byKey(const Key('pipeline-version-1')))
.cupertino,
isTrue,
);
expect(find.byType(CupertinoListSection), findsNothing);
await tester.tap(find.byKey(const Key('pipeline-version-1')));
await tester.pumpAndSettle();
@@ -116,7 +116,7 @@ void main() {
expect(find.text('pipeline 2 was not found'), findsOneWidget);
expect(find.text('Retry'), findsOneWidget);
expect(find.text('Select a pipeline.'), findsNothing);
expect(find.text('Select a pipeline to open it here.'), findsNothing);
});
testWidgets('the list switches between all and scheduled pipelines', (
@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/empty_detail_pane.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
import 'package:pipelines_app/core/api_gateway.dart';
@@ -25,7 +26,13 @@ void main() {
expect(find.textContaining('run 42'), findsNothing);
// A pipeline that never ran shows its summary alone, with no status dot.
expect(find.text('no runs recorded'), findsNothing);
expect(find.text('Select a pipeline.'), findsOneWidget);
expect(
find.widgetWithText(
EmptyDetailPane,
'Select a pipeline to open it here.',
),
findsOneWidget,
);
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/actions/decision_action.dart';
import 'package:pipelines_app/features/runs/actions/decision_option_row.dart';
import 'package:pipelines_app/features/runs/actions/decision_wording.dart';
typedef _Handler = Future<JsonMap> Function(String type, JsonMap fields);
@@ -194,9 +195,33 @@ void main() {
decisionConfirmLabel,
);
expect(tester.widget<CupertinoDialogAction>(confirm).onPressed, isNull);
// Options are check-list rows, not blue link buttons: an empty circle
// until one is picked, then a filled check on that row only.
final skip = find.byKey(decisionOptionKey('skip'));
expect(skip, findsOneWidget);
expect(
find.ancestor(
of: find.text('skip'),
matching: find.byType(CupertinoButton),
),
findsNothing,
);
expect(find.byIcon(CupertinoIcons.checkmark_circle_fill), findsNothing);
expect(
find.descendant(of: skip, matching: find.byIcon(CupertinoIcons.circle)),
findsOneWidget,
);
await tester.tap(find.text('skip'));
await tester.pump();
expect(gateway.calls, isEmpty);
expect(
find.descendant(
of: skip,
matching: find.byIcon(CupertinoIcons.checkmark_circle_fill),
),
findsOneWidget,
);
expect(find.byIcon(CupertinoIcons.checkmark_circle_fill), findsOneWidget);
await tester.tap(find.text(decisionConfirmLabel));
await tester.pumpAndSettle();
@@ -181,7 +181,7 @@ void main() {
await pumpDeepLink(tester, RunDetailTestPlatform.material, stage: 'plan');
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
expectVisitHeading(tester, 'plan', 2);
});
testWidgets('a Graph click opens the same latest visit as the stage route', (
@@ -195,7 +195,7 @@ void main() {
// The web client's graph click takes the last visit in sequence order, not
// the last row in reply order, so both entry points agree.
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
expectVisitHeading(tester, 'plan', 2);
});
testWidgets('an out-of-range visit is clamped to the stage last visit', (
@@ -209,7 +209,7 @@ void main() {
);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
expectVisitHeading(tester, 'plan', 2);
});
testWidgets('a declared but unvisited stage selects its graph node', (
@@ -259,7 +259,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
expectVisitHeading(tester, 'plan', 2);
});
testWidgets('a route change applies its visit and a plain route closes it', (
@@ -301,7 +301,7 @@ void main() {
rebuild(() => visit = 1);
await tester.pumpAndSettle();
expectVisitHeading(tester, 'plan', 5);
expectVisitHeading(tester, 'plan', 2);
rebuild(() => stage = null);
await tester.pumpAndSettle();
@@ -14,8 +14,8 @@ Finder runDetailText(String text) => find.descendant(
);
/// The stage page's bar names the stage over its visit (and run): the title
/// is keyed `run-visit-title` and the subtitle starts `Visit <sequence>`.
void expectVisitHeading(WidgetTester tester, String stage, num sequence) {
/// is keyed `run-visit-title` and the subtitle starts `Visit <stage visit>`.
void expectVisitHeading(WidgetTester tester, String stage, num visit) {
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
final heading = find.byKey(const Key('run-visit-title'));
expect(
@@ -25,7 +25,7 @@ void expectVisitHeading(WidgetTester tester, String stage, num sequence) {
expect(
find.descendant(
of: heading,
matching: find.textContaining(RegExp('^Visit $sequence( ·|\$)')),
matching: find.textContaining(RegExp('^Visit $visit( ·|\$)')),
),
findsOneWidget,
);
@@ -0,0 +1,91 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
import 'package:pipelines_app/ui/layout/section_heading.dart';
import 'run_detail_graph_support.dart';
import 'run_detail_visit_support.dart';
/// The run and stage detail bodies are flat on the page on both hosts: no
/// Cupertino inset group (so none nested in another), pinned headings on the
/// page colour, and beside a list one row of tabs and header.
void main() {
for (final platform in RunDetailTestPlatform.values) {
testWidgets('${platform.name} Summary and Timeline draw no grouped '
'card', (tester) async {
await pumpRunDetail(tester, platform);
expect(find.byType(CupertinoListSection), findsNothing);
await openRunDetailTab(tester, RunDetailTab.timeline);
expect(find.byType(CupertinoListSection), findsNothing);
expect(tester.takeException(), isNull);
});
testWidgets('${platform.name} the stage Session nests no group in a '
'group', (tester) async {
await openVisit(tester, platform);
await openVisitTab(tester, RunVisitSection.session);
expect(find.text('Turn documents'), findsOneWidget);
expect(find.byType(CupertinoListSection), findsNothing);
});
testWidgets('${platform.name} beside a list the tabs and the header '
'share one row', (tester) async {
tester.view.physicalSize = const Size(720, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final gateway = RunDetailFakeGateway(graphRunFixture());
final controller = RunsController(RunsRepository(gateway));
addTearDown(controller.dispose);
await controller.select(51);
final view = PageTabsEdge(
edge: FloatingBarEdge.top,
child: RunDetailView(
controller: controller,
gateway: gateway,
onBack: () {},
),
);
await tester.pumpWidget(
platform == RunDetailTestPlatform.material
? MaterialApp(home: Scaffold(body: view))
: CupertinoApp(home: CupertinoPageScaffold(child: view)),
);
await tester.pumpAndSettle();
final tabs = tester.getRect(find.byKey(const Key('run-detail-tabs')));
final header = tester.getRect(find.byKey(const Key('run-detail-header')));
// Side by side, not stacked: the header starts after the tabs and
// overlaps them vertically.
expect(header.left, greaterThanOrEqualTo(tabs.right - 12));
expect(header.top, lessThan(tabs.bottom));
expect(header.bottom, greaterThan(tabs.top));
expect(tester.takeException(), isNull);
});
}
testWidgets('Cupertino pinned headings take the page colour', (tester) async {
for (final brightness in Brightness.values) {
late SectionHeadingStyle style;
late Color page;
await tester.pumpWidget(
CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
home: Builder(
builder: (context) {
style = SectionHeadingStyle.of(context);
page = CupertinoTheme.of(context).scaffoldBackgroundColor;
return const SizedBox.shrink();
},
),
),
);
expect(style.background, page, reason: '$brightness');
}
});
}
@@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
@@ -132,10 +133,12 @@ void main() {
size: const Size(900, 1600),
);
for (final label in recordedLabels) {
// The bar's subtitle names the pipeline, so no Pipeline fact repeats it.
for (final label in recordedLabels.where((l) => l != 'Pipeline')) {
expect(find.text(label), findsOneWidget, reason: label);
}
expect(find.text('id 3 · v2'), findsOneWidget);
expect(find.text('Pipeline'), findsNothing);
expect(find.text('id 3 · v2'), findsNothing);
expect(find.text('review'), findsOneWidget);
expect(find.text('/srv/workspaces/run-51'), findsOneWidget);
expect(find.text('abc123def456'), findsOneWidget);
@@ -199,6 +202,29 @@ void main() {
expect(hash.width, greaterThan(300));
});
testWidgets('${platform.name} a single fact starts at the leading edge, '
'with no grouped card', (tester) async {
await pumpRunDetail(
tester,
platform,
run: absentRunFixture()..['current_stage'] = 'review',
size: const Size(900, 1600),
);
final grid = tester.getRect(
find.byKey(const Key('run-detail-summary-facts')),
);
final stage = tester.getRect(
find.byKey(const ValueKey('run-detail-summary-stage')),
);
// The grid spans the Summary, and its one fact is at the start of the
// line rather than a half-width block centred on the page.
// Full Summary width, up to the shared reading cap (840) on wide panes.
expect(grid.width, moreOrLessEquals(840));
expect(stage.left, moreOrLessEquals(16));
expect(stage.center.dx, lessThan(450));
expect(find.byType(CupertinoListSection), findsNothing);
});
testWidgets('${platform.name} summary sections state their exact empty '
'wording', (tester) async {
await pumpRunDetail(
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/reading_width.dart';
import 'package:pipelines_app/features/runs/ui/run_graph_preview.dart';
import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
@@ -113,18 +114,33 @@ void main() {
expect(widePill.right, 1000 - 16);
expect(widePill.bottom, 844 - 16);
expect(widePill.width, lessThan(1000 * 0.6));
// Beside the bar the content takes taps: the body spans the width.
expect(tester.getRect(body).width, 1000);
// Beside the bar the content takes taps: the body spans the reading
// width from the leading edge (Summary is capped on a wide pane).
expect(tester.getRect(body).left, 0);
expect(tester.getRect(body).width, kReadingMaxWidth);
});
testWidgets('${platform.name} missing graph states the exact wording', (
tester,
) async {
await pumpRunDetail(tester, platform, run: graphRunFixture(graph: false));
await openRunDetailTab(tester, RunDetailTab.graph);
await openRunDetailTab(tester, RunDetailTab.summary);
// One muted line on the Summary: no framed, tappable empty preview.
expect(find.text(runGraphMissing), findsOneWidget);
expect(find.byKey(runGraphPreviewMissingKey), findsOneWidget);
expect(find.byKey(runGraphPreviewKey), findsNothing);
expect(find.byType(RunGraphView), findsNothing);
expect(find.byType(InteractiveViewer), findsNothing);
final line = tester.getSize(find.byKey(runGraphPreviewMissingKey));
expect(line.height, lessThan(60));
expect(
find.descendant(
of: find.byKey(runGraphPreviewMissingKey),
matching: find.byType(DecoratedBox),
),
findsNothing,
);
});
testWidgets('${platform.name} Graph stays bounded at 320 with 2x text', (
@@ -100,7 +100,7 @@ void main() {
expect(find.byKey(const Key('run-visit-pane')), findsNothing);
expect(find.byType(RunTimelineList), findsOneWidget);
expect(find.text('plan · visit 1'), findsOneWidget);
expect(find.text('plan · Visit 1'), findsOneWidget);
});
testWidgets('${platform.name} visit pane at 320 with 2x dark text', (
@@ -201,17 +201,17 @@ void main() {
matching: find.byType(Scrollable),
);
await tester.scrollUntilVisible(
find.textContaining('build · visit 3'),
find.textContaining('build · Visit 1').last,
200,
scrollable: timelineScroll,
);
expect(find.textContaining('build · visit 3'), findsOneWidget);
expect(find.textContaining('build · Visit 1').last, findsOneWidget);
await tester.scrollUntilVisible(
find.textContaining('test · visit 4'),
find.textContaining('test · Visit 1').last,
200,
scrollable: timelineScroll,
);
expect(find.textContaining('test · visit 4'), findsOneWidget);
expect(find.textContaining('test · Visit 1').last, findsOneWidget);
final before = tester
.state<ScrollableState>(timelineScroll)
@@ -58,7 +58,7 @@ void main() {
);
Rect at(String text) => tester.getRect(find.text(text));
final title = at('Ship the release notes');
final age = at('12h ago');
final age = at('12h');
final subtitle = at('release · 2m 5s · 3 steps');
expect(age.center.dy, moreOrLessEquals(title.center.dy));
@@ -81,10 +81,13 @@ void main() {
),
);
expect(
find.text('Pipeline unavailable · 2m 5s · 3 steps'),
findsOneWidget,
);
expect(find.text('Pipeline unavailable · 2m 5s · 3 steps'), findsOneWidget);
});
test('the run action sheet is titled with the run', () {
expect(runMoreMenuTitle(_finished), 'Ship the release notes');
expect(runMoreMenuTitle({'id': 5, 'name': 'nightly'}), 'nightly');
expect(runMoreMenuTitle({'id': 5}), 'Run 5');
});
testWidgets('gives a list action menu a per-run key', (tester) async {
@@ -113,7 +113,7 @@ void main() {
);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expectVisitHeading(tester, 'build', 2);
expectVisitHeading(tester, 'build', 1);
});
}
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_content.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_timeline.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/ui/status/run_status_icon.dart';
final _steps = [
@@ -52,8 +53,49 @@ void main() {
expect(find.text('success'), findsOneWidget);
expect(find.text('error'), findsOneWidget);
expect(find.text('→ build · 2m 5s'), findsOneWidget);
// The target is the line; the duration is the row's time.
expect(find.text('→ build'), findsOneWidget);
expect(find.text('2m 5s'), findsOneWidget);
expect(find.text('→ #failure'), findsOneWidget);
// The shared flat row, with no grouped card on either host.
expect(find.byType(AppListRow), findsNWidgets(3));
expect(find.byType(CupertinoListSection), findsNothing);
});
}
for (final cupertino in [false, true]) {
testWidgets('outcome chips are coloured by name, not by status '
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
// Every step completed: before, all three chips were the success colour.
final steps = [
for (final (i, outcome) in [
'success',
'rejected',
'success',
'approved',
].indexed)
{
'stage': 'stage$i',
'sequence': i + 1,
'status': 'completed',
'outcome': outcome,
},
];
final list = RunTimelineList(
visits: detailTimeline(steps),
cupertino: cupertino,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: list))
: MaterialApp(home: Scaffold(body: list)),
);
Color chip(String text, [int at = 0]) =>
tester.widget<Text>(find.text(text).at(at)).style!.color!;
expect(chip('success'), chip('success', 1));
expect(chip('rejected'), isNot(chip('success')));
expect(chip('approved'), isNot(chip('success')));
expect(chip('approved'), isNot(chip('rejected')));
});
}
}
@@ -65,13 +65,13 @@ void main() {
await _openVisitChanges(tester);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
// The body keeps the landed viewer's own identity for that visit.
// The stage is already named in the page bar, so Changes does not repeat it.
expect(
find.descendant(
of: find.byType(ChangesViewer),
matching: find.text('plan'),
),
findsOneWidget,
findsNothing,
);
expect(find.text('Visit 1 · completed'), findsOneWidget);
expect(find.text('lib/plan.dart'), findsOneWidget);
@@ -8,6 +8,7 @@ import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/screen.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'run_detail_finders.dart';
import 'package:pipelines_app/shell/empty_detail_pane.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
class _Gateway implements ApiGateway {
@@ -154,6 +155,11 @@ void main() {
) async {
await tester.pumpWidget(_materialScreen(gateway));
await _mountList(tester, gateway);
// Beside the list, nothing open yet: the shared empty-pane placeholder.
expect(
find.widgetWithText(EmptyDetailPane, 'Select a run to open it here.'),
findsOneWidget,
);
await tester.tap(find.text('Beta run'));
await tester.pump();
@@ -0,0 +1,187 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
import 'package:pipelines_app/features/runs/ui/runs_filter_sheet.dart';
import 'package:pipelines_app/features/runs/ui/runs_filters.dart';
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
import 'package:pipelines_app/ui/layout/app_sheet_header.dart';
class _Gateway implements ApiGateway {
final framesController = StreamController<JsonMap>.broadcast();
JsonMap? reply;
@override
Stream<JsonMap> get frames => framesController.stream;
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async =>
reply ?? {'runs': []};
}
/// The Runs sheets share one header (title and Done), single-choice groups
/// use check rows, statuses read in sentence case, and the usage page neither
/// repeats its title nor draws a chart of zeros.
void main() {
late _Gateway gateway;
late RunsController controller;
setUp(() {
gateway = _Gateway();
controller = RunsController(RunsRepository(gateway));
});
tearDown(() async {
controller.dispose();
await gateway.framesController.close();
});
Future<void> mount(
WidgetTester tester, {
required bool cupertino,
String? createdAt,
}) async {
tester.view.physicalSize = const Size(800, 1400);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final at = createdAt ?? DateTime.now().toIso8601String();
gateway.reply = {
'runs': [
{
'id': 1,
'pipeline_id': 9,
'name': 'Alpha',
'status': 'running',
'created_at': at,
'scheduled': true,
},
],
};
await controller.load();
final list = AnimatedBuilder(
animation: controller,
builder: (context, _) =>
RunsList(controller: controller, onSelected: (_) {}),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: list))
: MaterialApp(home: Scaffold(body: list)),
);
await tester.pumpAndSettle();
}
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host filter sheet has a header whose Done closes it', (
tester,
) async {
await mount(tester, cupertino: cupertino);
await tester.tap(find.byKey(const ValueKey('runs.filter')));
await tester.pumpAndSettle();
expect(find.byType(AppSheetHeader), findsOneWidget);
expect(
find.descendant(
of: find.byType(AppSheetHeader),
matching: find.text(runsFilterTitle),
),
findsOneWidget,
);
expect(find.text('Queued'), findsOneWidget);
expect(find.text('queued'), findsNothing);
expect(find.byKey(runsFilterClearKey), findsNothing);
await tester.tap(find.text('Last 7 days'));
await tester.pumpAndSettle();
expect(controller.timeRange, 'last_7_days');
// An active filter offers Clear in the header.
expect(find.byKey(runsFilterClearKey), findsOneWidget);
await tester.tap(find.byKey(runsFilterDoneKey));
await tester.pumpAndSettle();
expect(find.byKey(const ValueKey('runs.filter.sheet')), findsNothing);
// The applied chip reads in sentence case too.
expect(find.textContaining('Last 7 days'), findsOneWidget);
});
}
testWidgets('Material single-choice groups are check rows, not checkboxes', (
tester,
) async {
await mount(tester, cupertino: false);
await tester.tap(find.byKey(const ValueKey('runs.filter')));
await tester.pumpAndSettle();
// Seven statuses may be combined: those keep their checkboxes.
expect(find.byType(CheckboxListTile), findsNWidgets(7));
final anyTime = find.widgetWithText(ListTile, 'Any time');
expect(anyTime, findsOneWidget);
expect(
find.descendant(of: anyTime, matching: find.byIcon(Icons.check)),
findsOneWidget,
);
expect(
find.descendant(of: anyTime, matching: find.byType(Checkbox)),
findsNothing,
);
final today = find.widgetWithText(ListTile, 'Today');
expect(
find.descendant(of: today, matching: find.byIcon(Icons.check)),
findsNothing,
);
expect(tester.widget<ListTile>(anyTime).selected, isTrue);
});
testWidgets('Material sort sheet has the same header', (tester) async {
await mount(tester, cupertino: false);
await tester.tap(find.byKey(const ValueKey('runs.sort')));
await tester.pumpAndSettle();
expect(find.text(runsSortTitle), findsOneWidget);
await tester.tap(find.byKey(runsSortDoneKey));
await tester.pumpAndSettle();
expect(find.text(runsSortTitle), findsNothing);
expect(controller.sort, 'newest_first');
});
testWidgets('the usage page is honest when nothing was reported', (
tester,
) async {
await mount(
tester,
cupertino: false,
createdAt: DateTime(2020, 1, 1).toIso8601String(),
);
await tester.tap(find.byKey(const ValueKey('runs.stats')));
await tester.pumpAndSettle();
// The bar says Usage; the body does not repeat it.
expect(find.text('Usage'), findsOneWidget);
expect(find.byKey(const ValueKey('runs.stats.usage.empty')), findsOne);
expect(find.byKey(const ValueKey('runs.stats.days')), findsNothing);
expect(find.byKey(const ValueKey('runs.stats.days.empty')), findsOne);
expect(find.text('Running'), findsOneWidget);
expect(find.text('0'), findsNothing);
});
testWidgets('the 7-day chart shows bars over an axis when runs started', (
tester,
) async {
await mount(tester, cupertino: true);
await tester.tap(find.byKey(const ValueKey('runs.stats')));
await tester.pumpAndSettle();
expect(find.byKey(const ValueKey('runs.stats.days')), findsOneWidget);
expect(find.byKey(const ValueKey('runs.stats.days.empty')), findsNothing);
// Only the day with a run is labelled with its count.
final days = find.byKey(const ValueKey('runs.stats.days'));
expect(find.descendant(of: days, matching: find.text('1')), findsOne);
expect(find.text('0'), findsNothing);
expect(tester.takeException(), isNull);
});
}
@@ -70,18 +70,22 @@ void main() {
await tester.pumpAndSettle();
}
Future<void> reveal(WidgetTester tester, Finder target) =>
tester.scrollUntilVisible(
target,
80,
// The sheet's own list, not the search field's inner scrollable.
scrollable: find
.descendant(
of: find.byKey(const ValueKey('runs.filter.sheet')),
matching: find.byType(Scrollable),
)
.first,
);
Future<void> reveal(WidgetTester tester, Finder target) async {
await tester.scrollUntilVisible(
target,
80,
// The sheet's own list, not the search field's inner scrollable.
scrollable: find
.descendant(
of: find.byKey(const ValueKey('runs.filter.sheet')),
matching: find.byType(Scrollable),
)
.first,
);
// Built is not on screen: bring the row fully inside the sheet.
await tester.ensureVisible(target);
await tester.pumpAndSettle();
}
Future<void> closeSheet(WidgetTester tester) async {
await tester.tapAt(const Offset(4, 4));
@@ -148,7 +152,7 @@ void main() {
await tester.tap(find.byKey(const ValueKey('runs.filter')));
await tester.pumpAndSettle();
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
final failed = find.widgetWithText(CupertinoListTile, 'failed');
final failed = find.widgetWithText(CupertinoListTile, 'Failed');
await reveal(tester, failed);
await tester.pumpAndSettle();
await tester.tap(failed);
@@ -156,7 +160,7 @@ void main() {
expect(controller.statuses, {'failed'});
await closeSheet(tester);
final failedChip = find.widgetWithText(CupertinoButton, 'failed');
final failedChip = find.widgetWithText(CupertinoButton, 'Failed');
expect(failedChip, findsOneWidget);
expect(find.text('Alpha'), findsNothing);
await tester.tap(failedChip);
@@ -13,8 +13,9 @@ Future<void> pumpSchedules(
ValueChanged<SavedSchedule>? onOpen,
double textScale = 1,
bool settle = true,
Size size = const Size(390, 844),
}) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
@@ -29,11 +29,13 @@ void main() {
);
expect(find.text('2 schedules'), findsOneWidget);
expect(find.textContaining('not pipeline definitions'), findsOneWidget);
// The strip carries the count only; the helper line lives in the
// empty state.
expect(find.textContaining('not pipeline definitions'), findsNothing);
// Two lines per row: the name with its next run, then the timer
// and pinned pipeline version. The editor holds the rest.
expect(find.text('Research batteries'), findsOneWidget);
expect(find.text('22 Oct 09:00'), findsOneWidget);
expect(find.text('22 Oct'), findsOneWidget);
expect(
find.text('Every 24h · mon, wed · Pipeline 4 · v2'),
findsOneWidget,
@@ -0,0 +1,54 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/schedules/ui/list/schedule_list_toolbar.dart';
import 'package:pipelines_app/features/schedules/ui/list/schedule_list_view.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'schedule_list_test_support.dart';
import 'schedule_screen_harness.dart';
/// On a wide window the rows share the toolbar strip's width, and the strip
/// is one row: the field, the filter and the count as a muted label.
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host 1200: rows end under the strip and the strip is one '
'row', (tester) async {
await pumpSchedules(
tester,
cupertino: cupertino,
size: const Size(1200, 800),
gateway: FakeSchedulesGateway(
(type, fields) async => schedulesReply([
scheduleRecord(nextDue: '2026-10-22T09:00:00'),
pausedRecord(),
]),
),
);
final strip = tester.getRect(find.byKey(scheduleToolbarKey));
final row = tester.getRect(find.byKey(appListRowSurfaceKey).first);
expect(row.left, 0);
expect(row.width, kScheduleListMaxWidth);
// The row's trailing time ends inside the strip's trailing edge.
// The trailing time is the row's rightmost text, whatever its wording.
final time = find
.descendant(
of: find.byKey(appListRowSurfaceKey).first,
matching: find.byType(Text),
)
.evaluate()
.map((element) => tester.getRect(find.byWidget(element.widget)))
.reduce((a, b) => a.right >= b.right ? a : b);
expect(time.right, lessThanOrEqualTo(strip.right - 12 + 0.5));
// Field, filter and count on one line.
final field = tester.getRect(find.byKey(scheduleSearchFieldKey));
final filter = tester.getRect(find.byKey(scheduleFilterKey));
final count = tester.getRect(find.text('2 schedules'));
expect((field.center.dy - filter.center.dy).abs(), lessThan(4));
expect((count.center.dy - filter.center.dy).abs(), lessThan(4));
expect(find.textContaining('not pipeline definitions'), findsNothing);
});
}
}
@@ -112,10 +112,7 @@ void main() {
await pumpScheduleSection(tester, gateway: gateway, version: 3);
expect(find.text('Schedules (0)'), findsOneWidget);
expect(
find.text('No schedules yet. Add one for each topic or recurring task.'),
findsOneWidget,
);
expect(find.textContaining(scheduleSectionEmpty), findsOneWidget);
await tester.tap(find.byKey(scheduleAddKey));
await tester.pumpAndSettle();
@@ -329,10 +326,7 @@ void main() {
expect(gateway.callsOf('delete_schedule'), hasLength(1));
expect(find.text('Research batteries'), findsNothing);
expect(
find.text('No schedules yet. Add one for each topic or recurring task.'),
findsOneWidget,
);
expect(find.textContaining(scheduleSectionEmpty), findsOneWidget);
expect(gateway.calls.map((call) => call.type), [
'list_schedules',
'delete_schedule',
@@ -90,24 +90,23 @@ void main() {
final version = searchRowView(versionHit(), 'release');
expect(version.title, 'pipeline 9 · v2');
expect(version.secondary, startsWith('content abc · '));
expect(version.secondary, 'content abc');
expect(version.recency, isNotNull);
final run = searchRowView(runHit(), 'release');
expect(run.title, 'run #11 · release');
expect(run.secondary, startsWith('succeeded · '));
expect(run.secondary.split(' · '), hasLength(2));
expect(run.title, 'Run 11 · release');
expect(run.secondary, 'succeeded');
final unnamed = searchRowView(runHit({'pipeline_name': ''}), '');
expect(unnamed.title, 'run #11');
expect(unnamed.title, 'Run 11');
final step = searchRowView(stepHit({'target': '#success'}), '');
expect(step.title, 'run #11 · builder visit 2');
expect(step.title, 'Run 11 · builder visit 2');
expect(step.secondary, 'success · → #success');
final artifact = searchRowView(artifactHit(), 'notes');
expect(artifact.title, 'notes.md');
expect(artifact.secondary, 'run #11 · step 4 · text/markdown · 2.0 KiB');
expect(artifact.secondary, 'Run 11 · step 4 · text/markdown · 2.0 KiB');
});
test('a field snippet marks the first case-insensitive query occurrence', () {
@@ -154,6 +154,15 @@ void main() {
expect(find.text('Server time 2026-10-21T12:00:00Z'), findsOneWidget);
expect(find.byKey(SettingsKeys.disconnect), findsOneWidget);
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
// Beside Disconnect, the second action reconnects; it never says Connect.
expect(
find.descendant(
of: find.byKey(SettingsKeys.connect),
matching: find.text('Reconnect'),
),
findsOneWidget,
);
expect(find.text('Connect'), findsNothing);
// The only other request is the ntfy settings load, queued behind ping.
_answerNtfySettings(factory.last);
await tester.pump();
@@ -6,6 +6,9 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/templates/screen.dart';
import 'package:pipelines_app/features/templates/ui/template_detail.dart';
import 'package:pipelines_app/features/templates/ui/template_gallery.dart'
show templateAvatarKey;
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import '../data/template_test_support.dart' show source;
import 'template_gallery_test_support.dart';
@@ -31,15 +34,19 @@ void main() {
expect(find.byKey(templatesGalleryKey), findsOneWidget);
expect(find.text('Release workflow'), findsOneWidget);
expect(find.text('Ship a version'), findsOneWidget);
expect(find.text('2 stages'), findsNWidgets(2));
// One subtitle line: the description, then the parsed stage count.
expect(find.text('Ship a version · 2 stages'), findsOneWidget);
expect(find.text('No display name · 2 stages'), findsOneWidget);
expect(find.text('(unnamed template)'), findsOneWidget);
expect(find.byKey(templatesLoadingKey), findsNothing);
// The app's shared rows with an initial avatar; no chevrons or tiles.
expect(find.byType(AppListRow), findsNWidgets(2));
expect(find.byKey(templateAvatarKey('release')), findsOneWidget);
expect(find.byType(ListTile), findsNothing);
expect(find.byIcon(Icons.chevron_right), findsNothing);
});
testWidgets('stage count is unavailable when server parsing refuses', (
tester,
) async {
testWidgets('an unknown stage count is left out of the row', (tester) async {
final gateway =
GalleryGateway((type, fields) async => templatesReply(galleryTemplates))
..validationHandler = (type, fields) async {
@@ -48,8 +55,9 @@ void main() {
await pumpGallery(tester, gateway);
expect(find.text('stage count unavailable'), findsNWidgets(2));
expect(find.text('0 stages'), findsNothing);
expect(find.textContaining('stage count'), findsNothing);
expect(find.textContaining('stages'), findsNothing);
expect(find.text('Ship a version'), findsOneWidget);
expect(gateway.callsOf('validate'), hasLength(2));
expect(
gateway.callsOf('validate').first.fields['source'],
@@ -162,9 +170,20 @@ void main() {
await tester.pumpAndSettle();
expect(find.byKey(templateDetailKey), findsOneWidget);
// The bar's title pill names the template; the body does not repeat it.
final bar = find.byType(SegmentedBar);
expect(
find.descendant(of: bar, matching: find.text('Release workflow')),
findsOneWidget,
);
expect(
find.descendant(of: bar, matching: find.text('Ship a version')),
findsOneWidget,
);
expect(find.text('Release workflow'), findsOneWidget);
expect(find.text('Ship a version'), findsOneWidget);
expect(find.text('Key'), findsOneWidget);
expect(find.text('Key'), findsNothing);
expect(find.byKey(templateKeyKey), findsOneWidget);
expect(find.text('Includes a schedule'), findsOneWidget);
expect(find.text(templateSourceLabel), findsOneWidget);
expect(selectableSource(source), findsOneWidget);
@@ -230,7 +249,8 @@ void main() {
);
await pumpGallery(tester, gateway, cupertino: true);
expect(find.byType(CupertinoListTile), findsNWidgets(2));
expect(find.byType(AppListRow), findsNWidgets(2));
expect(find.byType(CupertinoListTile), findsNothing);
expect(find.byType(Scaffold), findsNothing);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
@@ -247,7 +267,7 @@ void main() {
await tester.tap(find.byKey(templatesBackKey));
await tester.pumpAndSettle();
expect(find.byType(CupertinoListTile), findsNWidgets(2));
expect(find.byType(AppListRow), findsNWidgets(2));
});
testWidgets(
@@ -0,0 +1,72 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/templates/screen.dart';
import 'package:pipelines_app/features/templates/ui/template_gallery.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import '../data/template_test_support.dart' show source;
import 'template_gallery_test_support.dart';
/// The gallery and an open template on a wide window: the column stops at the
/// Settings reading width, start-aligned; the bar names the open template and
/// the Create action is a compact button, not a full-width bar.
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host: rows and detail are capped at 720 on a wide window', (
tester,
) async {
final gateway = GalleryGateway(
(type, fields) async => templatesReply(galleryTemplates),
);
await pumpGallery(
tester,
gateway,
cupertino: cupertino,
size: const Size(1200, 800),
);
final row = tester.getRect(find.byKey(templateRowKey('release')));
expect(row.left, 0);
expect(row.width, templatesContentMaxWidth);
expect(find.text('Templates'), findsOneWidget);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
final bar = find.byType(SegmentedBar);
expect(
find.descendant(of: bar, matching: find.text('Release workflow')),
findsOneWidget,
);
expect(find.text('Templates'), findsNothing);
final create = tester.getRect(find.byKey(templateCreateActionKey));
expect(create.left, 16);
// Its own width, not stretched across the 688 content column.
expect(create.width, lessThan(templatesContentMaxWidth - 32));
final body = tester.getRect(selectableSource(source));
expect(body.right, lessThanOrEqualTo(templatesContentMaxWidth));
expect(tester.takeException(), isNull);
});
testWidgets('$host: the detail fits 320 at 2x text', (tester) async {
final gateway = GalleryGateway(
(type, fields) async => templatesReply(galleryTemplates),
);
await pumpGallery(
tester,
gateway,
cupertino: cupertino,
size: const Size(320, 800),
textScale: 2,
);
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(templateRowKey('release')));
await tester.pumpAndSettle();
expect(find.byKey(templateCreateActionKey), findsOneWidget);
expect(tester.takeException(), isNull);
});
}
}
@@ -0,0 +1,52 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/empty_detail_pane.dart';
/// One placeholder for an empty detail pane: the destination's icon above a
/// short muted line, centred, on both hosts.
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final destination in [
AppDestination.runs,
AppDestination.chat,
AppDestination.pipelines,
]) {
testWidgets('$host ${destination.name}: icon over a muted line', (
tester,
) async {
final content = EmptyDetailPane(
destination: destination,
message: 'Select one to open it here.',
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: content))
: MaterialApp(home: Scaffold(body: content)),
);
final details = destinationDetails(destination);
final icon = find.byIcon(
cupertino ? details.cupertinoIcon : details.icon,
);
expect(icon, findsOneWidget);
final text = find.text('Select one to open it here.');
expect(
tester.getTopLeft(text).dy,
greaterThan(tester.getRect(icon).bottom),
);
// Centred in the pane.
final size = tester.view.physicalSize / tester.view.devicePixelRatio;
expect(tester.getCenter(text).dx, closeTo(size.width / 2, 1));
// Muted: the same secondary colour on the icon and the line.
final context = tester.element(text);
final muted = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
expect(tester.widget<Icon>(icon).color, muted);
expect(tester.widget<Text>(text).style?.color, muted);
});
}
}
}
+25 -12
View File
@@ -12,7 +12,8 @@ import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
/// Beside a list each pane owns its bar on one shared top row, and an open
/// item's tabs never stack on the shell's tab bar at the bottom.
/// item's tabs float at the bottom of its own pane, beside (never on) the
/// shell's tab bar over the list.
void main() {
Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
@@ -149,18 +150,20 @@ void main() {
expect(find.text('Its context'), findsOneWidget);
});
testWidgets('$host 1200: the item\'s tabs float under its bar, not on '
'the shell\'s tab bar', (tester) async {
testWidgets('$host 1200: the item\'s tabs float at the bottom of its '
'pane, beside the shell\'s tab bar', (tester) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pump();
await tester.pump();
final shellTabs = tester.getRect(
find.descendant(
of: find.byKey(const ValueKey('shell.destination.runs')).first,
matching: find.byType(Icon),
),
find
.ancestor(
of: find.byKey(const ValueKey('shell.destination.runs')).first,
matching: find.byType(GlassPill),
)
.first,
);
final itemTabs = tester.getRect(
find.descendant(
@@ -168,16 +171,26 @@ void main() {
matching: find.byType(GlassPill),
),
);
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
// Near the bottom of the detail pane, never on the shell's tabs.
expect(itemTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
expect(itemTabs.left, greaterThanOrEqualTo(body.left));
expect(itemTabs.overlaps(shellTabs), isFalse);
// The item's list starts below its bar and clears its tabs at rest.
final paneBarPill = tester.getRect(
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
);
expect(itemTabs.top, greaterThanOrEqualTo(paneBarPill.bottom));
expect(itemTabs.top, lessThan(200));
expect(itemTabs.bottom, lessThan(shellTabs.top - 100));
// The item's list starts below its tabs at rest.
expect(
tester.getTopLeft(find.text('item row 0')).dy,
greaterThanOrEqualTo(itemTabs.bottom),
greaterThanOrEqualTo(paneBarPill.bottom),
);
expect(
MediaQuery.paddingOf(
tester.element(find.byKey(const Key('item-list'))),
).bottom,
greaterThanOrEqualTo(800 - itemTabs.top),
);
});
}
@@ -0,0 +1,151 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
/// While a tab shows its list beside an open item, the shell's destination
/// bar floats over the list pane only: it never covers the item, and the
/// item's own bottom control (a composer) owns the pane's bottom edge.
void main() {
Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
/// A detail whose composer sits at the bottom, padded by the media inset
/// the way the chat composer is.
Widget composerDetail() => Builder(
builder: (context) => Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom),
child: const SizedBox(
key: Key('composer'),
height: 56,
width: double.infinity,
),
),
),
);
Widget listBody() => Builder(
builder: (context) => ListView(
key: const Key('list'),
children: [
for (var index = 0; index < 40; index++)
SizedBox(height: 40, child: Text('row $index')),
],
),
);
Widget shell({
required bool cupertino,
bool split = true,
double textScale = 1,
}) {
final app = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.chat,
destinationBodies: {
AppDestination.chat: (_) => split
? ListDetailPanes(list: listBody(), detail: composerDetail())
: listBody(),
},
);
return MediaQuery(
data: MediaQueryData.fromView(
WidgetsBinding.instance.platformDispatcher.views.first,
).copyWith(textScaler: TextScaler.linear(textScale)),
child: cupertino ? CupertinoApp(home: app) : MaterialApp(home: app),
);
}
Rect destinationPill(WidgetTester tester) => tester.getRect(
find
.ancestor(
of: find.byKey(const ValueKey('shell.destination.chat')).first,
matching: find.byType(GlassPill),
)
.first,
);
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final width in [1200.0, 1600.0]) {
testWidgets('$host $width split: the destination bar stays over the '
'list pane and the composer owns the detail bottom', (tester) async {
await setSize(tester, Size(width, 800));
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pump();
await tester.pump();
final list = tester.getRect(
find.byKey(const ValueKey('list-detail-list')),
);
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
final pill = destinationPill(tester);
expect(pill.right, lessThanOrEqualTo(list.right));
expect(pill.left, greaterThanOrEqualTo(list.left));
expect(pill.overlaps(body), isFalse, reason: 'no overlap with detail');
expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
// The detail keeps only the system inset (none here): its composer
// reaches the bottom edge, below the level of the shell's pill.
final composer = tester.getRect(find.byKey(const Key('composer')));
expect(composer.bottom, 800);
expect(composer.left, body.left);
expect(composer.top, greaterThan(pill.top));
// The list still clears the bar.
final listContext = tester.element(find.byKey(const Key('list')));
expect(
MediaQuery.paddingOf(listContext).bottom,
greaterThanOrEqualTo(pill.height),
);
});
}
testWidgets('$host 1200 unsplit: the bar is compact at the right edge', (
tester,
) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino, split: false));
await tester.pump();
final pill = destinationPill(tester);
expect(pill.right, closeTo(1200 - kFloatingBarMargin, 0.5));
expect(pill.width, lessThan(1200 * 0.6));
});
testWidgets('$host 390: the bar spans the phone', (tester) async {
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(shell(cupertino: cupertino, split: false));
await tester.pump();
final pill = destinationPill(tester);
expect(pill.left, closeTo(kFloatingBarMargin, 0.5));
expect(pill.right, closeTo(390 - kFloatingBarMargin, 0.5));
});
for (final width in [600.0, 840.0]) {
testWidgets('$host $width split at 2x: the narrow list pane bar lays '
'out without overflow', (tester) async {
await setSize(tester, Size(width, 800));
await tester.pumpWidget(shell(cupertino: cupertino, textScale: 2));
await tester.pump();
await tester.pump();
expect(tester.takeException(), isNull);
final list = tester.getRect(
find.byKey(const ValueKey('list-detail-list')),
);
expect(destinationPill(tester).right, lessThanOrEqualTo(list.right));
});
}
}
}
+191
View File
@@ -0,0 +1,191 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/detail_page.dart';
import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/shell/shell_bar.dart';
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart';
/// On a wide split window (an unfolded foldable) under a system status bar,
/// every pane's bar sits below the status-bar inset while content still
/// reaches the top edge; and the open item's tabs float at the bottom of the
/// detail pane, beside (never on) the shell's tab bar over the list.
void main() {
const statusBar = 40.0;
Future<void> setUp(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
tester.view.padding = const FakeViewPadding(top: statusBar);
tester.view.viewPadding = const FakeViewPadding(top: statusBar);
addTearDown(tester.view.reset);
}
List<Widget> rows(String label) => [
for (var index = 0; index < 40; index++)
SizedBox(height: 40, child: Text('$label $index')),
];
/// An item publishing its bar to the pane, with its own floating tabs
/// placed where the pane says (like run and pipeline detail).
Widget tabbedItem(bool cupertino) => ShellBar(
title: 'Open item',
child: Builder(
builder: (context) {
final edge = PageTabsEdge.of(context);
return FloatingBarOverlay(
edge: edge,
bar: KeyedSubtree(
key: const Key('item-tabs'),
child: FloatingDestinationBar(
cupertino: cupertino,
edge: edge,
currentIndex: 0,
onTap: (_) {},
items: const [
FloatingDestinationItem(icon: Icon(Icons.notes), label: 'One'),
FloatingDestinationItem(icon: Icon(Icons.share), label: 'Two'),
],
),
),
child: Builder(
builder: (context) => ListView(
key: const Key('item-list'),
padding: withBarClearance(context, EdgeInsets.zero),
children: rows('item'),
),
),
);
},
),
);
/// An item drawing its own header over itself (like the chat thread).
Widget overlayItem(bool cupertino) => ShellBar(
barless: true,
child: SegmentedBarOverlay(
bar: SegmentedBar(
key: const Key('own-header'),
cupertino: cupertino,
automaticallyImplyLeading: false,
title: 'Own header',
),
child: ListView(key: const Key('item-list'), children: rows('item')),
),
);
Widget shell(bool cupertino, Widget Function(bool) item) {
final app = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.runs,
destinationBodies: {
AppDestination.runs: (_) => ListDetailPanes(
list: ShellBar(
child: ListView(key: const Key('list'), children: rows('list')),
),
detail: DetailPane(
destination: AppDestination.runs,
implyBack: false,
builder: (_) => item(cupertino),
),
),
},
);
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
}
Iterable<Rect> pillsOf(WidgetTester tester, Finder bar) => find
.descendant(of: bar, matching: find.byType(GlassPill))
.evaluate()
.map((element) {
final box = element.renderObject! as RenderBox;
return box.localToGlobal(Offset.zero) & box.size;
});
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host split under a status bar: list and pane bars sit '
'below it, content reaches the top edge', (tester) async {
await setUp(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino, tabbedItem));
await tester.pump();
await tester.pump();
final listBar = find.byWidgetPredicate(
(widget) => widget is SegmentedBar && widget.title == 'Runs',
);
final paneBar = find.byWidgetPredicate(
(widget) => widget is SegmentedBar && widget.title == 'Open item',
);
for (final bar in [listBar, paneBar]) {
final pills = pillsOf(tester, bar);
expect(pills, isNotEmpty);
for (final pill in pills) {
expect(pill.top, greaterThanOrEqualTo(statusBar));
}
}
// Content may still extend under the bars and the status bar.
expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0);
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
// At rest the first rows start below the bars.
final paneBottom = pillsOf(tester, paneBar).first.bottom;
expect(
tester.getTopLeft(find.text('item 0')).dy,
greaterThanOrEqualTo(paneBottom),
);
});
testWidgets('$host split under a status bar: a self-drawn header (chat) '
'sits below it', (tester) async {
await setUp(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino, overlayItem));
await tester.pump();
await tester.pump();
final pills = pillsOf(tester, find.byKey(const Key('own-header')));
expect(pills, isNotEmpty);
for (final pill in pills) {
expect(pill.top, greaterThanOrEqualTo(statusBar));
}
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
});
testWidgets('$host split: the item tabs float at the bottom of the '
'detail pane, beside the shell tab bar over the list', (tester) async {
await setUp(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino, tabbedItem));
await tester.pump();
await tester.pump();
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
final tabs = pillsOf(tester, find.byKey(const Key('item-tabs'))).single;
expect(tabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
expect(tabs.left, greaterThanOrEqualTo(body.left));
expect(tabs.right, lessThanOrEqualTo(body.right));
final shellTabs = tester.getRect(
find
.ancestor(
of: find.byKey(const ValueKey('shell.destination.runs')).first,
matching: find.byType(GlassPill),
)
.first,
);
expect(shellTabs.overlaps(tabs), isFalse);
expect(shellTabs.right, lessThanOrEqualTo(body.left));
// The item's list clears its tabs at rest.
final list = tester.element(find.byKey(const Key('item-list')));
expect(
MediaQuery.paddingOf(list).bottom,
greaterThanOrEqualTo(800 - tabs.top),
);
});
}
}
+115
View File
@@ -0,0 +1,115 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_panel.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_summary_view.dart';
import 'package:pipelines_app/ui/layout/reading_width.dart';
import '../../features/pipelines/fixtures.dart';
import '../../features/pipelines/test_helpers.dart';
import '../../features/runs/ui/run_detail_graph_support.dart';
import '../../features/runs/ui/run_detail_visit_support.dart';
/// Reading bodies (run Summary, stage page sections, pipeline Summary) keep
/// [kReadingMaxWidth] from the leading edge on a wide window and the full
/// width on a phone.
void main() {
Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
testWidgets('ReadingWidth caps from the leading edge and keeps its child '
'across the cap', (tester) async {
await setSize(tester, const Size(1200, 600));
final scroll = ScrollController();
addTearDown(scroll.dispose);
await tester.pumpWidget(
MaterialApp(
home: ReadingWidth(
child: ListView(
key: const Key('body'),
controller: scroll,
children: [
for (var index = 0; index < 50; index++)
SizedBox(height: 40, child: Text('row $index')),
],
),
),
),
);
final wide = tester.getRect(find.byKey(const Key('body')));
expect(wide.left, 0);
expect(wide.width, kReadingMaxWidth);
expect(wide.height, 600);
scroll.jumpTo(300);
await tester.pump();
await setSize(tester, const Size(500, 600));
await tester.pump();
expect(tester.getRect(find.byKey(const Key('body'))).width, 500);
expect(scroll.offset, 300, reason: 'the body was not remounted');
});
for (final platform in RunDetailTestPlatform.values) {
testWidgets('${platform.name} 1200: run Summary is capped', (tester) async {
await pumpRunDetail(tester, platform, size: const Size(1200, 800));
final body = tester.getRect(
find.byKey(const Key('run-detail-tab-body-summary')),
);
expect(body.left, 0);
expect(body.width, kReadingMaxWidth);
});
testWidgets('${platform.name} 390: run Summary keeps the full width', (
tester,
) async {
await pumpRunDetail(tester, platform, size: const Size(390, 844));
final body = tester.getRect(
find.byKey(const Key('run-detail-tab-body-summary')),
);
expect(body.width, 390);
});
testWidgets('${platform.name} 1200: stage page Summary is capped', (
tester,
) async {
await openVisit(tester, platform, size: const Size(1200, 900));
final body = tester.getRect(
find.byKey(const Key('run-visit-body-summary')),
);
expect(body.left, 0);
expect(body.width, kReadingMaxWidth);
// The section's trailing copy button sits within the cap.
final copy = find.byKey(const ValueKey('run-visit-copy-Input'));
expect(tester.getRect(copy).right, lessThanOrEqualTo(kReadingMaxWidth));
});
}
testWidgets('1200: pipeline Summary is capped, the pane still scrolls', (
tester,
) async {
await setSize(tester, const Size(1200, 800));
final gateway = gatewayFor(PipelineFixture());
final controller = PipelinesController(PipelinesRepository(gateway));
addTearDown(controller.dispose);
await controller.openPipeline(1);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: PipelineDetailPanel(
controller: controller,
gateway: gateway,
showBack: false,
),
),
),
);
await tester.pumpAndSettle();
final summary = tester.getRect(find.byType(PipelineSummaryView));
expect(summary.left, 0);
expect(summary.width, kReadingMaxWidth);
});
}
@@ -0,0 +1,31 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/status/outcome_palette.dart';
void main() {
test('same outcome names share a colour; different names never do', () {
final palette = OutcomePalette([
'success',
'rejected',
'Success',
'approved',
'',
'rejected ',
]);
expect(palette.indexOf('success'), 0);
expect(palette.indexOf('SUCCESS'), 0);
expect(palette.indexOf('rejected'), 1);
expect(palette.indexOf('approved'), 2);
expect(palette.indexOf(''), isNull);
expect(palette.indexOf('never seen'), isNull);
});
test('the first fifty outcome colours are all distinct in both themes', () {
for (final brightness in Brightness.values) {
final colours = {
for (var i = 0; i < 50; i++) outcomeColorAt(i, brightness).toARGB32(),
};
expect(colours, hasLength(50), reason: '$brightness');
}
});
}
+36
View File
@@ -0,0 +1,36 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/text/relative_time.dart';
void main() {
final now = DateTime(2026, 10, 22, 12);
test('formats compact past and future list-row times', () {
expect(formatRelativeTime(now, now: now), 'just now');
expect(
formatRelativeTime(now.subtract(const Duration(minutes: 5)), now: now),
'5m',
);
expect(
formatRelativeTime(now.subtract(const Duration(hours: 3)), now: now),
'3h',
);
expect(
formatRelativeTime(now.subtract(const Duration(days: 3)), now: now),
'3d',
);
expect(
formatRelativeTime(now.subtract(const Duration(days: 8)), now: now),
'14 Oct',
);
expect(
formatRelativeTime(now.add(const Duration(hours: 2)), now: now),
'in 2h',
);
});
test('parses timestamps and omits unusable values', () {
expect(formatRelativeTimestamp('2026-10-22T11:55:00', now: now), '5m');
expect(formatRelativeTimestamp('', now: now), isNull);
expect(formatRelativeTimestamp('not a time', now: now), isNull);
});
}