Merge commit '40623991e8709e5c1ab3e875b51d4de55f0c20a5' into pipelines/run-20261112-0206-composer-border-shows-the-agent-working-fd87

This commit is contained in:
2026-11-12 02:58:45 +00:00
130 changed files with 5209 additions and 813 deletions
@@ -133,9 +133,8 @@ void main() {
await tester.pumpWidget(const SizedBox.shrink());
});
testWidgets('single pane focuses input; empty workspace does not consume', (
tester,
) async {
testWidgets('single pane with no shown window does nothing; empty workspace '
'does not consume', (tester) async {
await _setup(tester, open: false);
await _chord(tester);
expect(find.byType(ChatWorkspace), findsNothing);
@@ -144,7 +143,9 @@ void main() {
_focusSidebar(tester);
await tester.pumpAndSettle();
await _chord(tester);
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isTrue);
expect(find.byType(ChatWorkspace), findsOneWidget);
expect(_workspace(tester).paneCount, 1);
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isFalse);
expect(_editable(tester, 'a').controller.text, isEmpty);
await tester.pumpWidget(const SizedBox.shrink());
});
@@ -531,25 +531,36 @@ void main() {
await tester.pumpAndSettle();
expect(app.floating, ['b', 'c', 'a']);
// The cycle follows the order the windows were opened in (b, c, a), not
// the stacking order, which each raise changes. From a (opened last) the
// next is b, the first opened.
await _tab(tester);
expect(app.floating, ['c', 'a', 'b']);
expect(_composerFocused(tester, 'b'), isTrue);
// Past the top, the bottom window comes up again.
await _tab(tester);
expect(app.floating, ['a', 'b', 'c']);
expect(_composerFocused(tester, 'c'), isTrue);
await _tab(tester);
expect(app.floating, ['b', 'c', 'a']);
expect(_composerFocused(tester, 'a'), isTrue);
await _tab(tester, shift: true);
expect(app.floating, ['b', 'a', 'c']);
expect(_composerFocused(tester, 'c'), isTrue);
await _tab(tester, shift: true);
expect(app.floating, ['a', 'c', 'b']);
expect(_composerFocused(tester, 'b'), isTrue);
// Back past the first opened: the last opened (a) comes up.
await _tab(tester, shift: true);
expect(app.floating, ['a', 'b', 'c']);
expect(_composerFocused(tester, 'c'), isTrue);
expect(app.floating, ['c', 'b', 'a']);
expect(_composerFocused(tester, 'a'), isTrue);
expect(tester.takeException(), isNull);
await app.stop(tester);
});
testWidgets('with the tiling focused Ctrl+Tab cycles its panes and leaves '
'the windows alone', (tester) async {
testWidgets('with the tiling focused Ctrl+Tab goes to the top-most shown '
'window, and cycles the panes only when no window is shown', (
tester,
) async {
await _saved('a', 'b', 'c');
final app = _App(_Store());
await app.start(tester);
@@ -557,26 +568,61 @@ void main() {
expect(app.floating, ['c']);
final controller = _workspace(tester);
// A window is shown: from the tiling, Ctrl+Tab takes the keyboard to it
// and the panes stay where they are.
await tester.tapAt(tester.getCenter(_input('a')));
await tester.pump();
expect(controller.activePane?.sessionId, 'a');
await _tab(tester);
expect(controller.activePane?.sessionId, 'b');
expect(_composerFocused(tester, 'b'), isTrue);
expect(controller.activePane?.sessionId, 'a');
expect(_composerFocused(tester, 'c'), isTrue);
expect(app.floating, ['c']);
// With a window focused, the panes stay where they are; a single window
// has nothing to cycle to.
await tester.tapAt(tester.getCenter(_input('c')));
await tester.pump();
// A single shown window has nothing to cycle to.
await _tab(tester);
expect(controller.activePane?.sessionId, 'a');
expect(_composerFocused(tester, 'c'), isTrue);
expect(app.floating, ['c']);
// No window shown: the panes cycle and the hidden window stays hidden.
await _chord(tester);
expect(_shown('Chat c'), findsNothing);
await tester.tapAt(tester.getCenter(_input('a')));
await tester.pump();
await _tab(tester);
expect(controller.activePane?.sessionId, 'b');
expect(_composerFocused(tester, 'b'), isTrue);
expect(_shown('Chat c'), findsNothing);
expect(app.floating, ['c']);
expect(tester.takeException(), isNull);
await app.stop(tester);
});
testWidgets('with one tiled pane and no shown window Ctrl+Tab does nothing; '
'a minimised chat is not brought up', (tester) async {
await _saved('a', 'b');
final app = _App(_Store());
await app.start(tester);
await _menu(tester, 'b', 'Float (Alt+Y)');
await tester.tap(find.byTooltip('Minimise'));
await tester.pumpAndSettle();
expect(_shown('Chat b'), findsNothing);
final controller = _workspace(tester);
expect(controller.panes.map((p) => p.sessionId), ['a']);
await tester.tapAt(tester.getCenter(_input('a')));
await tester.pump();
await _tab(tester);
await _tab(tester, shift: true);
expect(controller.panes.map((p) => p.sessionId), ['a']);
expect(controller.activePane?.sessionId, 'a');
expect(_shown('Chat b'), findsNothing);
expect(app.floating, ['b']);
expect(app.opened, isEmpty);
expect(tester.takeException(), isNull);
await app.stop(tester);
});
testWidgets('a terminal that claims tab keys keeps Ctrl+Tab over a focused '
'floating chat', (tester) async {
await _saved('a', 'b', 'c');
@@ -150,38 +150,29 @@ void main() {
await tester.pumpWidget(const SizedBox.shrink());
});
testWidgets('Control Tab over one pane returns to the previous chat', (
tester,
) async {
testWidgets('Control Tab over one pane does nothing: it never brings up '
'another chat', (tester) async {
await _setup(tester);
await _openRow(tester, 'a');
final workspace = _workspace(tester);
// Nothing shown before: the chord only focuses the composer.
await _controlTab(tester);
expect(workspace.activePane?.sessionId, 'a');
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isTrue);
expect(_editable(tester, 'a').focusNode.hasPrimaryFocus, isFalse);
// Opening b replaces the lone pane; a is no longer shown anywhere.
await _openRow(tester, 'b');
await tester.enterText(_input('b'), 'Draft B');
await _focusSidebar(tester);
for (final id in ['a', 'b', 'a']) {
await _controlTab(tester);
for (final shift in [false, true]) {
await _controlTab(tester, shift: shift);
expect(workspace.paneCount, 1);
expect(workspace.activePane?.sessionId, id);
expect(_editable(tester, id).focusNode.hasPrimaryFocus, isTrue);
expect(workspace.activePane?.sessionId, 'b');
expect(_editable(tester, 'b').focusNode.hasPrimaryFocus, isFalse);
expect(_editable(tester, 'b').controller.text, 'Draft B');
}
await _controlTab(tester, shift: true);
expect(workspace.activePane?.sessionId, 'b');
expect(_editable(tester, 'b').controller.text, 'Draft B');
// A third chat makes the pair c and b; a is no longer one step away.
// Two panes cycle the panes, not the history.
await _openRow(tester, 'c');
await _controlTab(tester);
expect(workspace.activePane?.sessionId, 'b');
await _controlTab(tester);
expect(workspace.activePane?.sessionId, 'c');
// Two panes cycle the panes as before, not the history.
await tester.tap(_actions('a'));
await tester.pumpAndSettle();
await tester.tap(find.text('Open to the right'));
@@ -50,7 +50,7 @@ Future<void> _pumpShell(WidgetTester tester, Size size) async {
void main() {
for (final size in [const Size(1280, 800), const Size(800, 830)]) {
testWidgets('a wide window keeps the tab bar and list beside the open chat '
testWidgets('a wide window keeps the rail and list beside the open chat '
'at $size', (tester) async {
await _pumpShell(tester, size);
expect(
@@ -68,8 +68,10 @@ void main() {
find.byType(Navigator).first,
);
expect(navigator.canPop(), isFalse, reason: 'No page covers the shell');
expect(find.byType(NavigationRail), findsNothing);
expect(find.byType(FloatingDestinationBar), findsOneWidget);
// Both sizes are wide enough for the rail (the shell's own bar and list
// beside the open chat sit to its right).
expect(find.byType(NavigationRail), findsOneWidget);
expect(find.byType(FloatingDestinationBar), findsNothing);
expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget);
expect(find.text('Second chat'), findsOneWidget);
expect(
@@ -11,7 +11,7 @@ void main() {
testWidgets('chat list stays above labeled navigation ($scale)', (
tester,
) async {
tester.view.physicalSize = const Size(1200, 900);
tester.view.physicalSize = const Size(640, 900);
tester.view.devicePixelRatio = 1;
tester.platformDispatcher.textScaleFactorTestValue = scale;
addTearDown(tester.view.reset);
@@ -87,7 +87,13 @@ void main() {
),
same(scrollable),
);
expect(scrollable.position.pixels, closeTo(retainedOffset, .5));
// The list is narrower at 640 (no rail) than beside the rail, so its
// rows re-wrap into a shorter scroll extent: the offset is kept up to
// that extent, and no further.
final kept = retainedOffset < scrollable.position.maxScrollExtent
? retainedOffset
: scrollable.position.maxScrollExtent;
expect(scrollable.position.pixels, closeTo(kept, .5));
expect(tester.takeException(), isNull);
});
}
@@ -106,7 +106,16 @@ void main() {
expect(find.text('Menu'), findsOneWidget);
await tester.tap(find.text('Menu'));
await tester.pumpAndSettle();
await tester.tap(find.text('Runs'));
// The menu's own row: the rail labels Runs too, so take the text that
// is not in the rail.
await tester.tap(
find.byElementPredicate(
(element) =>
element.widget is Text &&
(element.widget as Text).data == 'Runs' &&
element.findAncestorWidgetOfExactType<NavigationRail>() == null,
),
);
await tester.pumpAndSettle();
expect(find.text('Runs destination'), findsOneWidget);
await tester.tap(find.byTooltip('Chat'));
@@ -16,6 +16,7 @@ class FakeNotificationService implements NotificationServiceBridge {
);
NotificationServiceStatus current;
List<NotificationConnectionEvent> events = const [];
final calls = <(String, Map<String, Object?>)>[];
final _changes = StreamController<NotificationServiceStatus>.broadcast();
bool batteryGranted = true;
@@ -85,4 +86,9 @@ class FakeNotificationService implements NotificationServiceBridge {
if (batteryGranted) current = copy(batteryExempt: true);
return true;
}
// Not recorded in [calls]: the log is re-read after every action, and the
// tests assert on the action calls themselves.
@override
Future<List<NotificationConnectionEvent>> connectionEvents() async => events;
}
@@ -92,5 +92,39 @@ void main() {
final bridge = createNotificationServiceBridge();
expect(bridge.supported, isFalse);
expect((await bridge.status()).state, DeliveryState.off);
expect(await bridge.connectionEvents(), isEmpty);
});
test('a refused session reports sign_in_required', () {
expect(
NotificationServiceStatus.fromMap({'status': 'sign_in_required'}).state,
DeliveryState.signInRequired,
);
});
test('connectionEvents reads the service log, newest first', () async {
messenger.setMockMethodCallHandler(channel, (call) async {
if (call.method == 'connectionEvents') {
return [
{
'time': 2000,
'event': 'failed',
'error': 'Expected HTTP 101',
'code': 403,
},
{'time': 1000, 'event': 'connected'},
];
}
return reply();
});
final bridge = MethodChannelNotificationServiceBridge(channel);
final events = await bridge.connectionEvents();
expect(events.map((event) => event.event), ['failed', 'connected']);
expect(events.first.code, 403);
expect(events.first.error, 'Expected HTTP 101');
expect(events.first.detail, 'HTTP 403 · Expected HTTP 101');
expect(events.last.code, isNull);
expect(events.last.error, isNull);
expect(events.last.time, DateTime.fromMillisecondsSinceEpoch(1000));
});
}
@@ -244,10 +244,9 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('No input recorded.'), findsOneWidget);
// Output starts open, so its empty sentence shows without a tap.
await tester.ensureVisible(find.text('Output'));
await tester.pumpAndSettle();
await tester.tap(find.text('Output'));
await tester.pumpAndSettle();
expect(find.text('No output recorded.'), findsOneWidget);
});
@@ -266,5 +265,35 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('ship it'), findsOneWidget);
});
testWidgets('${platform.name} summary output starts expanded and '
'collapses for this view', (tester) async {
await pumpRunDetail(
tester,
platform,
run: recordedRunFixture(),
size: const Size(900, 1600),
);
final output = find.byKey(const ValueKey('run-detail-summary-output'));
final outputTitle = find.descendant(
of: output,
matching: find.text('Output'),
);
final outputBody = find.descendant(of: output, matching: find.text('ok'));
// Output opens with its recorded value; Input stays closed.
expect(outputBody, findsOneWidget);
expect(find.text('ship it'), findsNothing);
await tester.ensureVisible(outputTitle.first);
await tester.pumpAndSettle();
await tester.tap(outputTitle.first);
await tester.pumpAndSettle();
expect(outputBody, findsNothing);
await tester.tap(outputTitle.first);
await tester.pumpAndSettle();
expect(outputBody, findsOneWidget);
});
}
}
@@ -49,21 +49,77 @@ void main() {
}
});
testWidgets('${platform.name} visit Output starts expanded and collapses', (
tester,
) async {
await openVisit(tester, platform);
final output = find.byKey(const ValueKey('run-visit-section-Output'));
final outputTitle = find.descendant(
of: output,
matching: find.text('Output'),
);
final outputBody = find.descendant(of: output, matching: find.text('ok'));
final input = find.byKey(const ValueKey('run-visit-section-Input'));
// Output opens expanded; Input stays closed.
expect(find.text('result'), findsOneWidget);
expect(outputBody, findsOneWidget);
expect(find.text('Ship it.'), findsNothing);
// The operator can collapse Output, and open it again.
await tester.ensureVisible(outputTitle.first);
await tester.tap(outputTitle.first);
await tester.pumpAndSettle();
expect(outputBody, findsNothing);
expect(find.text('result'), findsNothing);
await tester.tap(outputTitle.first);
await tester.pumpAndSettle();
expect(outputBody, findsOneWidget);
expect(input, findsOneWidget);
});
testWidgets('${platform.name} long visit Output opens lazily and still '
'scrolls to its last field', (tester) async {
final run = visitRunFixture();
firstVisitStep(run)['output'] = <String, dynamic>{
for (var i = 0; i < 500; i++) 'field$i': 'value $i',
};
await openVisit(tester, platform, run: run);
// Open by default, yet only the fields on screen are built.
expect(find.text('value 0'), findsOneWidget);
expect(find.text('value 499'), findsNothing);
// Scrolling the page reaches the rest of the Output.
await tester.scrollUntilVisible(
find.text('value 499'),
500,
// The page's own scroll view is the outermost of its scrollables.
scrollable: find
.descendant(
of: find.byKey(const Key('run-visit-body-summary')),
matching: find.byType(Scrollable),
)
.first,
);
expect(find.text('value 499'), findsOneWidget);
});
testWidgets('${platform.name} tabs show recorded values and exact empty '
'wording', (tester) async {
await openVisit(tester, platform);
// Each field by name with its value, never raw JSON.
// Each field by name with its value, never raw JSON. Output is open at
// once; Input's value shows only after its tap.
expect(find.text('Ship it.'), findsNothing);
expect(find.text('ok'), findsNothing);
expect(find.text('ok'), findsOneWidget);
await tester.tap(find.text('Input'));
await tester.pumpAndSettle();
expect(find.text('prompt'), findsOneWidget);
expect(find.text('Ship it.'), findsOneWidget);
expect(find.textContaining('"prompt"'), findsNothing);
// Output is open as the visit opens; no tap is needed to read it.
await openVisitTab(tester, RunVisitSection.output);
await tester.tap(find.text('Output'));
await tester.pumpAndSettle();
expect(find.text('result'), findsOneWidget);
expect(find.text('ok'), findsOneWidget);
@@ -127,13 +183,12 @@ void main() {
await openVisit(tester, platform, run: run);
expect(find.text(visitEmptyInput), findsNothing);
expect(find.text(visitEmptyOutput), findsNothing);
// Output is open, so its empty sentence is already there.
expect(find.text(visitEmptyOutput), findsOneWidget);
await tester.tap(find.text('Input'));
await tester.pumpAndSettle();
expect(find.text(visitEmptyInput), findsOneWidget);
await openVisitTab(tester, RunVisitSection.output);
await tester.tap(find.text('Output'));
await tester.pumpAndSettle();
expect(find.text(visitEmptyOutput), findsOneWidget);
await openVisitTab(tester, RunVisitSection.artifacts);
expect(
@@ -172,7 +172,17 @@ void main() {
expect(find.text('alpha=1, items=1, 2'), findsOneWidget);
expect(find.textContaining('"alpha"'), findsNothing);
await openSummarySection('Output');
// Output starts open: its value is there to scroll to, without a tap.
await tester.scrollUntilVisible(
find.text('ok=true'),
200,
scrollable: find
.descendant(
of: find.byKey(const Key('run-detail-tab-body-summary')),
matching: find.byType(Scrollable),
)
.first,
);
expect(find.text('ok=true'), findsOneWidget);
await tapTab('Timeline');
@@ -263,7 +263,7 @@ void main() {
});
for (final platform in RunDetailTestPlatform.values) {
testWidgets('${platform.name} input field expands only the input section', (
testWidgets('${platform.name} input field expands the input section', (
tester,
) async {
await pumpSelection(
@@ -277,7 +277,8 @@ void main() {
findsOneWidget,
);
expect(find.text('ship it'), findsOneWidget);
expect(find.text('ok'), findsNothing);
// Output keeps its default: open, as every Summary opens.
expect(find.text('ok'), findsOneWidget);
});
testWidgets(
@@ -310,8 +311,9 @@ void main() {
find.byKey(const Key('run-detail-tab-body-summary')),
findsOneWidget,
);
// The plain Summary shows its default sections: Output open, Input closed.
expect(find.text('ship it'), findsNothing);
expect(find.text('ok'), findsNothing);
expect(find.text('ok'), findsOneWidget);
});
for (final platform in RunDetailTestPlatform.values) {
@@ -337,8 +339,9 @@ void main() {
find.byKey(const Key('run-detail-tab-body-summary')),
findsOneWidget,
);
// The Summary's default sections: Output open, Input closed.
expect(find.text('ship it'), findsNothing);
expect(find.text('ok'), findsNothing);
expect(find.text('ok'), findsOneWidget);
},
);
}
@@ -40,6 +40,19 @@ void main() {
},
);
test('Runs and Pipelines switch is Ctrl+A on every platform', () {
for (final platform in TargetPlatform.values) {
final entry = KeyboardShortcutRegistry(platform: platform, web: false)
.entries
.firstWhere(
(entry) => entry.action == 'Switch between Runs and Pipelines',
);
expect(entry.keys, 'Ctrl+A', reason: platform.name);
expect(entry.caveat, contains('Pipelines'));
expect(entry.caveat, contains('text field'));
}
});
test('uses the shell primary modifier rule on iOS', () {
final entries = const KeyboardShortcutRegistry(
platform: TargetPlatform.iOS,
@@ -18,6 +18,9 @@ Widget _host(
return MaterialApp(home: Scaffold(body: body));
}
int _requests(FakeNotificationService service) =>
service.calls.where((call) => call.$1 == 'requestBatteryExemption').length;
bool _switchValue(WidgetTester tester) {
final tile = find.byKey(DeviceDeliveryKeys.toggle);
return tester.widget<SwitchListTile>(tile).value;
@@ -62,9 +65,11 @@ void main() {
testWidgets('allow background delivery asks for the exemption', (
tester,
) async {
final service = FakeNotificationService();
final service = FakeNotificationService()..batteryGranted = false;
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
// The open-time prompt was declined; the row is the user's second try.
service.batteryGranted = true;
await tester.tap(find.text(deviceDeliveryBatteryLabel));
await tester.pumpAndSettle();
expect(
@@ -125,6 +130,157 @@ void main() {
await tester.pumpAndSettle();
expect(find.byKey(DeviceDeliveryKeys.error), findsOneWidget);
});
testWidgets(
'a missing battery exemption keeps a warning row with the Samsung note',
(tester) async {
// The open-time prompt is declined, so the exemption stays missing.
final service = FakeNotificationService()..batteryGranted = false;
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsOneWidget);
expect(find.text(deviceDeliveryWarningTitle), findsOneWidget);
expect(find.textContaining(deviceDeliverySamsungNote), findsOneWidget);
},
);
testWidgets('the warning goes away once the exemption is granted', (
tester,
) async {
final service = FakeNotificationService()..batteryGranted = false;
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsOneWidget);
service.batteryGranted = true;
await tester.tap(find.text(deviceDeliveryBatteryLabel));
await tester.pumpAndSettle();
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsNothing);
});
testWidgets('switching on asks for the battery exemption before starting', (
tester,
) async {
final service = FakeNotificationService();
service.current = service.copy(enabled: false, state: DeliveryState.off);
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
await tester.tap(find.byKey(DeviceDeliveryKeys.toggle));
await tester.pumpAndSettle();
final names = service.calls.map((call) => call.$1).toList();
expect(names, contains('requestBatteryExemption'));
expect(
names.indexOf('requestBatteryExemption'),
lessThan(names.indexOf('setEnabled')),
);
});
testWidgets(
'opening Settings with delivery on and no exemption asks right away',
(tester) async {
final service = FakeNotificationService();
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
expect(_requests(service), 1);
expect(
find.text('Allowed: battery optimisation will not pause delivery'),
findsOneWidget,
);
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsNothing);
},
);
testWidgets('a declined open-time prompt is not repeated on resume', (
tester,
) async {
final service = FakeNotificationService()..batteryGranted = false;
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
expect(_requests(service), 1);
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsOneWidget);
// Returning from the system screen re-reads the status only.
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
await tester.pumpAndSettle();
expect(_requests(service), 1);
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsOneWidget);
});
testWidgets('no open-time prompt when the exemption is already granted', (
tester,
) async {
final service = FakeNotificationService();
service.current = service.copy(batteryExempt: true);
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
expect(_requests(service), 0);
});
testWidgets('no open-time prompt while delivery is off', (tester) async {
final service = FakeNotificationService();
service.current = service.copy(enabled: false, state: DeliveryState.off);
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
expect(_requests(service), 0);
});
testWidgets('no warning while delivery is off', (tester) async {
final service = FakeNotificationService();
service.current = service.copy(enabled: false, state: DeliveryState.off);
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsNothing);
});
testWidgets('a refused session says the user must sign in again', (
tester,
) async {
final service = FakeNotificationService();
service.current = service.copy(state: DeliveryState.signInRequired);
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
expect(
find.text('Sign in to Pipelines again to keep notifications'),
findsOneWidget,
);
});
testWidgets(
'the connection log lists the service events, failures included',
(tester) async {
final service = FakeNotificationService();
service.events = [
NotificationConnectionEvent(
time: DateTime(2026, 11, 12, 9, 30, 5),
event: 'failed',
error: 'Expected HTTP 101',
code: 403,
),
NotificationConnectionEvent(
time: DateTime(2026, 11, 12, 9, 29),
event: 'connected',
),
];
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
await tester.tap(find.text(deviceDeliveryLogTitle));
await tester.pumpAndSettle();
expect(find.text('Socket failed'), findsOneWidget);
expect(
find.textContaining('HTTP 403 · Expected HTTP 101'),
findsOneWidget,
);
expect(find.text('Socket opened'), findsOneWidget);
},
);
testWidgets('an empty connection log says so', (tester) async {
final service = FakeNotificationService();
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
await tester.tap(find.text(deviceDeliveryLogTitle));
await tester.pumpAndSettle();
expect(find.text(deviceDeliveryLogEmpty), findsOneWidget);
});
}
class _FailingService extends FakeNotificationService {
@@ -0,0 +1,36 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/settings/settings_keys.dart';
import 'package:pipelines_app/features/settings/settings_walkthrough_section.dart';
import 'package:pipelines_app/ui/theme/app_theme.dart';
void main() {
testWidgets('Settings reopens the walkthrough on the first page', (
tester,
) async {
tester.view.devicePixelRatio = 1;
tester.view.physicalSize = const Size(390, 844);
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
MaterialApp(
theme: appLightTheme(),
home: const Scaffold(body: SettingsWalkthroughSection()),
),
);
expect(find.text('Show the walkthrough'), findsOneWidget);
expect(find.text('Welcome to Pipelines'), findsNothing);
await tester.tap(find.byKey(SettingsKeys.walkthrough));
await tester.pumpAndSettle();
expect(find.text('Welcome to Pipelines'), findsOneWidget);
expect(find.text('Step 1 of 4'), findsOneWidget);
await tester.tap(find.byKey(const ValueKey<String>('walkthrough.skip')));
await tester.pumpAndSettle();
expect(find.text('Welcome to Pipelines'), findsNothing);
});
}
@@ -0,0 +1,149 @@
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/chat/ui/sessions/chat_adaptive.dart';
import 'package:pipelines_app/features/terminal/terminal_open_action.dart';
import 'package:pipelines_app/features/terminal/terminal_scope.dart';
import 'package:pipelines_app/features/terminal/terminal_toggle_button.dart';
class _Actions implements TerminalActions {
int toggles = 0;
@override
void toggle() => toggles++;
@override
bool get claimsTabKeys => false;
@override
Future<String?> openAt(ApiGateway gateway, String cwd) async => null;
}
const _filesKey = ValueKey('files');
const _terminalIdentifier = 'chat-terminal-toggle';
/// Pumps an open chat's bar at [width]: Files, then whatever
/// [terminalChatBarAction] builds (null on wide or with no terminal surface).
/// Returns what it built.
Future<Widget?> _pumpBar(
WidgetTester tester, {
required double width,
required ThemeData theme,
_Actions? actions,
}) async {
Widget? built;
final bar = MediaQuery(
data: MediaQueryData(size: Size(width, 800)),
child: Scaffold(
body: Builder(
builder: (context) {
built = terminalChatBarAction(context);
return Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
ChatBarAction(
key: _filesKey,
label: 'Files',
onPressed: () {},
materialIcon: Icons.folder_outlined,
),
?built,
],
);
},
),
),
);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: actions == null
? bar
: TerminalScope(actions: actions, child: bar),
),
);
await tester.pump();
return built;
}
/// The colour an icon inside [finder] resolves to in the current theme.
Color? _iconColor(WidgetTester tester, Finder finder) {
final icon = find.descendant(of: finder, matching: find.byType(Icon));
final element = tester.element(icon);
return tester.widget<Icon>(icon).color ?? IconTheme.of(element).color;
}
void main() {
for (final theme in [
ThemeData(brightness: Brightness.light, useMaterial3: true),
ThemeData(brightness: Brightness.dark, useMaterial3: true),
]) {
final mode = theme.brightness.name;
testWidgets('$mode, phone: an open chat has a terminal button beside '
'Files, styled as Files', (tester) async {
final actions = _Actions();
final built = await _pumpBar(
tester,
width: 390,
theme: theme,
actions: actions,
);
expect(built, isA<ChatBarAction>());
final terminal = find.bySemanticsIdentifier(_terminalIdentifier);
final files = find.byKey(_filesKey);
expect(terminal, findsOneWidget);
expect(
tester.getSize(terminal),
tester.getSize(files),
reason: 'the terminal button must be the same size as Files',
);
expect(
_iconColor(tester, terminal),
_iconColor(tester, files),
reason: 'the terminal icon must share the colour of Files',
);
expect(
tester
.widget<IconButton>(
find.descendant(of: terminal, matching: find.byType(IconButton)),
)
.isSelected,
isNull,
reason: 'the terminal must not be a selected (tinted) button',
);
expect(find.byTooltip(TerminalToggleButton.label), findsOneWidget);
});
testWidgets('$mode, phone: tapping the terminal button toggles the '
'terminal', (tester) async {
final actions = _Actions();
await _pumpBar(tester, width: 390, theme: theme, actions: actions);
await tester.tap(find.byTooltip(TerminalToggleButton.label));
await tester.pump();
expect(actions.toggles, 1);
});
testWidgets('$mode, wide: the open chat bar has no terminal button (the '
'shell bar keeps it)', (tester) async {
final built = await _pumpBar(
tester,
width: 1000,
theme: theme,
actions: _Actions(),
);
expect(built, isNull);
expect(find.bySemanticsIdentifier(_terminalIdentifier), findsNothing);
});
testWidgets('$mode, phone without a terminal surface: no terminal button', (
tester,
) async {
final built = await _pumpBar(tester, width: 390, theme: theme);
expect(built, isNull);
expect(find.bySemanticsIdentifier(_terminalIdentifier), findsNothing);
});
}
}
@@ -0,0 +1,123 @@
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_adaptive.dart';
import 'package:pipelines_app/features/terminal/terminal_layout.dart';
import 'package:pipelines_app/features/terminal/terminal_scope.dart';
import 'package:pipelines_app/features/terminal/terminal_toggle_button.dart';
import 'terminal_fixtures.dart';
class _Actions implements TerminalActions {
int toggles = 0;
@override
void toggle() => toggles++;
@override
bool get claimsTabKeys => false;
@override
Future<String?> openAt(ApiGateway gateway, String cwd) async => null;
}
const _filesKey = ValueKey('files');
const _terminalKey = ValueKey('shell.terminal');
/// A chat's bar: Files beside the terminal toggle, as the shell shows them.
Widget _bar(TerminalLayout layout, _Actions actions, ThemeData theme) =>
MaterialApp(
theme: theme,
home: TerminalScope(
actions: actions,
child: Scaffold(
body: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
ChatBarAction(
key: _filesKey,
label: 'Files',
onPressed: () {},
materialIcon: Icons.folder_outlined,
),
TerminalToggleButton(layout: layout),
],
),
),
),
);
/// The colour an icon inside [finder] resolves to in the current theme.
Color? _iconColor(WidgetTester tester, Finder finder) {
final icon = find.descendant(of: finder, matching: find.byType(Icon));
final element = tester.element(icon);
return tester.widget<Icon>(icon).color ?? IconTheme.of(element).color;
}
/// Whether the terminal button's semantics (or one of its merged parents)
/// is announced as toggled on.
bool _toggled(WidgetTester tester) {
for (
SemanticsNode? node = tester.getSemantics(
find.byTooltip(TerminalToggleButton.label),
);
node != null;
node = node.parent
) {
if (node.flagsCollection.isToggled == ui.Tristate.isTrue) return true;
}
return false;
}
void main() {
for (final theme in [
ThemeData(brightness: Brightness.light, useMaterial3: true),
ThemeData(brightness: Brightness.dark, useMaterial3: true),
]) {
final mode = theme.brightness.name;
testWidgets('$mode: the terminal button is a plain bar button, shown or '
'hidden, like Files', (tester) async {
final layout = TerminalLayout(store: MemoryLayoutStore());
final actions = _Actions();
await tester.pumpWidget(_bar(layout, actions, theme));
await tester.pump();
final files = find.byKey(_filesKey);
final terminal = find.byKey(_terminalKey);
for (final shown in [false, true]) {
if (shown) layout.show();
await tester.pump();
final button = tester.widget<IconButton>(terminal);
expect(button.isSelected, isNull, reason: 'shown: $shown');
expect(
_iconColor(tester, terminal),
_iconColor(tester, files),
reason: 'icon colour differs from Files (shown: $shown)',
);
expect(tester.getSize(terminal), tester.getSize(files));
}
});
testWidgets('$mode: the shown state is announced without a tint', (
tester,
) async {
final handle = tester.ensureSemantics();
final layout = TerminalLayout(store: MemoryLayoutStore());
final actions = _Actions();
await tester.pumpWidget(_bar(layout, actions, theme));
await tester.pump();
expect(_toggled(tester), isFalse);
layout.show();
await tester.pump();
expect(_toggled(tester), isTrue);
await tester.tap(find.byKey(_terminalKey));
expect(actions.toggles, 1);
handle.dispose();
});
}
}
@@ -0,0 +1,202 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/walkthrough/first_run_walkthrough.dart';
import 'package:pipelines_app/features/walkthrough/walkthrough_steps.dart';
import 'package:pipelines_app/ui/theme/app_theme.dart';
const _nextKey = ValueKey<String>('walkthrough.next');
const _backKey = ValueKey<String>('walkthrough.back');
const _skipKey = ValueKey<String>('walkthrough.skip');
const _copyKey = ValueKey<String>('walkthrough.copy');
const _commandKey = ValueKey<String>('walkthrough.command');
const _launchKey = ValueKey<String>('launch');
Widget _launcher({ThemeMode mode = ThemeMode.light, double textScale = 1}) =>
MaterialApp(
theme: appLightTheme(),
darkTheme: appDarkTheme(),
themeMode: mode,
builder: (context, child) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(textScale)),
child: child!,
),
home: Scaffold(
body: Builder(
builder: (context) => Center(
child: FilledButton(
key: _launchKey,
onPressed: () => showFirstRunWalkthrough(context),
child: const Text('Open'),
),
),
),
),
);
Future<void> _open(WidgetTester tester) async {
await tester.tap(find.byKey(_launchKey));
await tester.pumpAndSettle();
}
void _useViewport(WidgetTester tester, Size size) {
tester.view.devicePixelRatio = 1;
tester.view.physicalSize = size;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
}
void main() {
group('phone layout', () {
testWidgets('opens as a bottom sheet with the first page', (tester) async {
_useViewport(tester, const Size(390, 844));
await tester.pumpWidget(_launcher());
await _open(tester);
expect(find.byType(BottomSheet), findsOneWidget);
expect(find.byType(Dialog), findsNothing);
expect(find.text('Step 1 of 4'), findsOneWidget);
expect(find.text(walkthroughSteps.first.title), findsOneWidget);
});
testWidgets('Back is disabled on the first page; Next advances', (
tester,
) async {
_useViewport(tester, const Size(390, 844));
await tester.pumpWidget(_launcher());
await _open(tester);
expect(tester.widget<TextButton>(find.byKey(_backKey)).onPressed, isNull);
await tester.tap(find.byKey(_nextKey));
await tester.pumpAndSettle();
expect(find.text('Step 2 of 4'), findsOneWidget);
expect(
tester.widget<TextButton>(find.byKey(_backKey)).onPressed,
isNotNull,
);
await tester.tap(find.byKey(_backKey));
await tester.pumpAndSettle();
expect(find.text('Step 1 of 4'), findsOneWidget);
});
testWidgets('walks four pages, Done on the last, Skip on every page', (
tester,
) async {
_useViewport(tester, const Size(390, 844));
await tester.pumpWidget(_launcher());
await _open(tester);
for (var page = 0; page < 3; page++) {
expect(find.byKey(_skipKey), findsOneWidget);
expect(find.text('Next'), findsOneWidget);
await tester.tap(find.byKey(_nextKey));
await tester.pumpAndSettle();
}
expect(find.text('Step 4 of 4'), findsOneWidget);
expect(find.text('Done'), findsOneWidget);
expect(find.byKey(_skipKey), findsOneWidget);
expect(find.text(walkthroughSteps.last.title), findsOneWidget);
await tester.tap(find.text('Done'));
await tester.pumpAndSettle();
expect(find.text(walkthroughSteps.last.title), findsNothing);
});
testWidgets('Skip closes from the middle of the walkthrough', (
tester,
) async {
_useViewport(tester, const Size(390, 844));
await tester.pumpWidget(_launcher());
await _open(tester);
await tester.tap(find.byKey(_nextKey));
await tester.pumpAndSettle();
await tester.tap(find.byKey(_skipKey));
await tester.pumpAndSettle();
expect(find.byType(BottomSheet), findsNothing);
});
});
testWidgets('wide windows open the walkthrough as a dialog', (tester) async {
_useViewport(tester, const Size(1280, 900));
await tester.pumpWidget(_launcher());
await _open(tester);
expect(find.byType(Dialog), findsOneWidget);
expect(find.byType(BottomSheet), findsNothing);
expect(find.text('Step 1 of 4'), findsOneWidget);
await tester.tap(find.byKey(_nextKey));
await tester.pumpAndSettle();
expect(find.text(walkthroughSteps[1].title), findsOneWidget);
});
testWidgets('the harness page offers each agent and copies its command', (
tester,
) async {
_useViewport(tester, const Size(390, 844));
final copied = <String>[];
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(SystemChannels.platform, (call) async {
if (call.method == 'Clipboard.setData') {
copied.add((call.arguments as Map)['text'] as String);
}
return null;
});
addTearDown(
() => TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(SystemChannels.platform, null),
);
await tester.pumpWidget(_launcher());
await _open(tester);
await tester.tap(find.byKey(_nextKey));
await tester.pumpAndSettle();
expect(
tester.widget<SelectableText>(find.byKey(_commandKey)).data,
'pipelines harness setup claude',
);
await tester.tap(
find.byKey(const ValueKey<String>('walkthrough.agent.pi')),
);
await tester.pumpAndSettle();
expect(
tester.widget<SelectableText>(find.byKey(_commandKey)).data,
'pipelines harness setup pi',
);
await tester.tap(find.byKey(_copyKey));
await tester.pumpAndSettle();
expect(copied, ['pipelines harness setup pi']);
expect(
find.descendant(
of: find.byKey(_copyKey),
matching: find.byIcon(Icons.check),
),
findsOneWidget,
);
});
testWidgets('large text and dark mode lay out without overflow', (
tester,
) async {
_useViewport(tester, const Size(360, 740));
await tester.pumpWidget(_launcher(mode: ThemeMode.dark, textScale: 2));
await _open(tester);
for (var page = 0; page < walkthroughSteps.length; page++) {
expect(tester.takeException(), isNull, reason: 'page $page');
expect(find.text(walkthroughSteps[page].title), findsOneWidget);
if (page < walkthroughSteps.length - 1) {
// At 2x text the phone sheet scrolls, so Next can start off screen.
await tester.ensureVisible(find.byKey(_nextKey));
await tester.tap(find.byKey(_nextKey));
await tester.pumpAndSettle();
}
}
expect(tester.takeException(), isNull);
});
}
@@ -0,0 +1,341 @@
import 'dart:async';
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/walkthrough/walkthrough_gate.dart';
import 'package:pipelines_app/features/walkthrough/walkthrough_store.dart';
import 'package:pipelines_app/ui/theme/app_theme.dart';
import 'package:shared_preferences/shared_preferences.dart';
const _welcome = 'Welcome to Pipelines';
Future<SharedPreferences?> _noPreferences() async => null;
/// A gateway that answers the three empty-server list calls from fixed lists.
class _FakeGateway implements ApiGateway {
_FakeGateway({this.runs = const <Object>[], this.failing = false});
/// Runs the server reports; pipelines and chats are always empty here.
final List<Object> runs;
bool failing;
final calls = <String>[];
@override
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async {
calls.add(type);
if (failing) throw StateError('offline');
return switch (type) {
'list_pipelines' => <String, dynamic>{'pipelines': const <Object>[]},
'list_runs' => <String, dynamic>{'runs': runs},
'chat_sessions' => <String, dynamic>{'chat_sessions': const <Object>[]},
_ => <String, dynamic>{'type': 'error'},
};
}
@override
Stream<JsonMap> get frames => const Stream<JsonMap>.empty();
}
/// Delegates to [inner], but holds [isSeen] until [release] so a test can
/// change the page visibility while an offer is still in flight.
class _HeldStore implements WalkthroughStore {
_HeldStore(this.inner);
final MemoryWalkthroughStore inner;
Completer<void>? _gate;
void hold() => _gate = Completer<void>();
void release() {
_gate?.complete();
_gate = null;
}
@override
Future<bool> isSeen() async {
await _gate?.future;
return inner.isSeen();
}
@override
Future<void> markSeen() => inner.markSeen();
@override
Future<bool> wasOffered(String serverScope) =>
inner.wasOffered(serverScope);
@override
Future<void> markOffered(String serverScope) =>
inner.markOffered(serverScope);
}
/// [link] stands in for the session: its value is whether the server connected,
/// and notifying it is the connection transition. Defaults to connected.
Widget _host({
required WalkthroughStore store,
ApiGateway? gateway,
bool enabled = true,
ValueNotifier<bool>? link,
}) {
final session = link ?? ValueNotifier<bool>(true);
return MaterialApp(
theme: appLightTheme(),
darkTheme: appDarkTheme(),
home: Scaffold(
body: FirstRunWalkthroughGate(
store: store,
enabled: enabled,
serverScope: 'server-a',
connection: session,
connected: () => session.value,
gateway: gateway,
child: const Text('Pipelines page'),
),
),
);
}
Future<void> _finishWalkthrough(WidgetTester tester) async {
for (var page = 0; page < 3; page++) {
await tester.tap(find.byKey(const ValueKey<String>('walkthrough.next')));
await tester.pumpAndSettle();
}
await tester.tap(find.text('Done'));
await tester.pumpAndSettle();
}
void main() {
testWidgets('first launch shows the walkthrough once per device', (
tester,
) async {
final store = MemoryWalkthroughStore();
await tester.pumpWidget(_host(store: store));
await tester.pumpAndSettle();
expect(find.text(_welcome), findsOneWidget);
await _finishWalkthrough(tester);
expect(find.text(_welcome), findsNothing);
expect(store.seen, isTrue);
// A later launch on the same device does not show it again.
await tester.pumpWidget(const SizedBox());
await tester.pumpWidget(_host(store: store));
await tester.pumpAndSettle();
expect(find.text(_welcome), findsNothing);
expect(find.text('Pipelines page'), findsOneWidget);
});
testWidgets('Done persists the seen record and no server query runs', (
tester,
) async {
final store = MemoryWalkthroughStore();
final gateway = _FakeGateway();
await tester.pumpWidget(_host(store: store, gateway: gateway));
await tester.pumpAndSettle();
await _finishWalkthrough(tester);
expect(store.seen, isTrue);
expect(
gateway.calls,
isEmpty,
reason: 'first launch needs no server check',
);
});
testWidgets('Skip on the first page persists the seen record', (
tester,
) async {
final store = MemoryWalkthroughStore();
await tester.pumpWidget(_host(store: store));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey<String>('walkthrough.skip')));
await tester.pumpAndSettle();
expect(find.text(_welcome), findsNothing);
expect(store.seen, isTrue);
});
testWidgets('a seen device on an empty server is offered it once', (
tester,
) async {
final store = MemoryWalkthroughStore(seen: true);
final gateway = _FakeGateway();
await tester.pumpWidget(_host(store: store, gateway: gateway));
await tester.pumpAndSettle();
expect(find.text(_welcome), findsOneWidget);
expect(store.offered, {'server-a'});
expect(
gateway.calls,
containsAll(['list_pipelines', 'list_runs', 'chat_sessions']),
);
await tester.tap(find.byKey(const ValueKey<String>('walkthrough.skip')));
await tester.pumpAndSettle();
// The server was offered already, so a fresh mount stays quiet.
await tester.pumpWidget(const SizedBox());
await tester.pumpWidget(_host(store: store, gateway: gateway));
await tester.pumpAndSettle();
expect(find.text(_welcome), findsNothing);
});
testWidgets(
'a seen device that starts disconnected is offered once it connects',
(tester) async {
// Startup order in the app: the Pipelines page mounts before the session
// has connected. The server must not be asked yet, and the offer must
// still happen after the connection arrives.
final store = MemoryWalkthroughStore(seen: true);
final gateway = _FakeGateway();
final link = ValueNotifier<bool>(false);
await tester.pumpWidget(
_host(store: store, gateway: gateway, link: link),
);
await tester.pumpAndSettle();
expect(find.text(_welcome), findsNothing);
expect(
gateway.calls,
isEmpty,
reason: 'no server call while disconnected',
);
expect(store.offered, isEmpty);
link.value = true;
await tester.pumpAndSettle();
expect(find.text(_welcome), findsOneWidget);
expect(store.offered, {'server-a'});
expect(
gateway.calls,
containsAll(['list_pipelines', 'list_runs', 'chat_sessions']),
);
},
);
testWidgets('an unreadable check is retried on the next connection', (
tester,
) async {
final store = MemoryWalkthroughStore(seen: true);
final gateway = _FakeGateway(failing: true);
final link = ValueNotifier<bool>(true);
await tester.pumpWidget(_host(store: store, gateway: gateway, link: link));
await tester.pumpAndSettle();
expect(find.text(_welcome), findsNothing);
expect(store.offered, isEmpty);
final callsAfterFailure = gateway.calls.length;
// A repeated notification while still connected does not re-query.
link.notifyListeners();
await tester.pumpAndSettle();
expect(gateway.calls.length, callsAfterFailure);
// The server recovers; a fresh connection runs the check and offers it.
gateway.failing = false;
link.value = false;
await tester.pumpAndSettle();
link.value = true;
await tester.pumpAndSettle();
expect(find.text(_welcome), findsOneWidget);
expect(store.offered, {'server-a'});
});
testWidgets('a seen device on a server with work is not offered', (
tester,
) async {
final store = MemoryWalkthroughStore(seen: true);
final gateway = _FakeGateway(
runs: <Object>[
<String, dynamic>{'id': 'run-1'},
],
);
await tester.pumpWidget(_host(store: store, gateway: gateway));
await tester.pumpAndSettle();
expect(find.text(_welcome), findsNothing);
expect(store.offered, isEmpty);
});
testWidgets('an unreadable server never triggers the walkthrough', (
tester,
) async {
final store = MemoryWalkthroughStore(seen: true);
await tester.pumpWidget(
_host(store: store, gateway: _FakeGateway(failing: true)),
);
await tester.pumpAndSettle();
expect(find.text(_welcome), findsNothing);
expect(store.offered, isEmpty);
});
testWidgets('the Pipelines page being hidden defers the check', (
tester,
) async {
final store = MemoryWalkthroughStore();
await tester.pumpWidget(_host(store: store, enabled: false));
await tester.pumpAndSettle();
expect(find.text(_welcome), findsNothing);
expect(store.seen, isFalse);
await tester.pumpWidget(_host(store: store, enabled: true));
await tester.pumpAndSettle();
expect(find.text(_welcome), findsOneWidget);
});
testWidgets(
'hiding Pipelines while an offer is pending keeps the walkthrough closed',
(tester) async {
final inner = MemoryWalkthroughStore();
final store = _HeldStore(inner)..hold();
await tester.pumpWidget(_host(store: store));
await tester.pump();
// The Pipelines page is hidden while the offer is still reading the store.
await tester.pumpWidget(_host(store: store, enabled: false));
store.release();
await tester.pumpAndSettle();
expect(find.text(_welcome), findsNothing);
expect(inner.seen, isFalse);
// Showing Pipelines again offers it once, on the same mount.
await tester.pumpWidget(_host(store: store, enabled: true));
await tester.pumpAndSettle();
expect(find.text(_welcome), findsOneWidget);
},
);
test('an unavailable preference store reports seen and offered', () async {
// The opener yields no preferences, as when the platform store is absent:
// every read reports "seen" and every write is quietly dropped.
const store = SharedPreferencesWalkthroughStore(open: _noPreferences);
expect(await store.isSeen(), isTrue);
expect(await store.wasOffered('server-a'), isTrue);
await store.markSeen();
await store.markOffered('server-a');
expect(await store.isSeen(), isTrue);
});
test(
'SharedPreferences store records seen and offered under the keys',
() async {
SharedPreferences.setMockInitialValues(<String, Object>{});
const store = SharedPreferencesWalkthroughStore();
expect(await store.isSeen(), isFalse);
await store.markSeen();
expect(await store.isSeen(), isTrue);
expect(await store.wasOffered('server-a'), isFalse);
await store.markOffered('server-a');
expect(await store.wasOffered('server-a'), isTrue);
expect(await store.wasOffered('server-b'), isFalse);
},
);
}