Complete prompt presets, body-priority panes and clearer chat and stage layouts

This commit is contained in:
2026-10-25 23:11:06 +00:00
parent de1b62791f
commit 121ace1cee
31 changed files with 990 additions and 396 deletions
@@ -17,217 +17,258 @@ void main() {
for (final cupertino in [false, true]) {
for (final brightness in Brightness.values) {
for (final width in [640.0, 840.0, 1280.0]) {
testWidgets('shared equal panes and selected rows: $cupertino '
'$brightness at $width', (tester) async {
SharedPreferences.setMockInitialValues({});
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final fixture = PipelineFixture();
final gateway = FakeGateway(
(type, fields) => switch (type) {
'list_pipelines' => pipelineListReply(fixture.summaries),
'get_pipeline' => pipelineDetailReply(
fixture.detailFor(
fields['pipeline_id'] as int,
fields['version'] as int,
)!,
),
'list_runs' => {
'runs': [
for (final id in [1, 2])
{'id': id, 'title': 'Run item $id', 'status': 'succeeded'},
],
},
'get_run' => {
'run_detail': {
'id': fields['run_id'],
'title': 'Run item ${fields['run_id']}',
'status': 'succeeded',
'input': {'prompt': 'Recorded input'},
for (final scale in [1.0, 2.0]) {
testWidgets('shared body-priority panes and selected rows: $cupertino '
'$brightness at $width @${scale}x', (tester) async {
SharedPreferences.setMockInitialValues({});
tester.view.physicalSize = Size(width, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
tester.platformDispatcher.textScaleFactorTestValue = scale;
addTearDown(
tester.platformDispatcher.clearTextScaleFactorTestValue,
);
final fixture = PipelineFixture();
final gateway = FakeGateway(
(type, fields) => switch (type) {
'list_pipelines' => pipelineListReply(fixture.summaries),
'get_pipeline' => pipelineDetailReply(
fixture.detailFor(
fields['pipeline_id'] as int,
fields['version'] as int,
)!,
),
'list_runs' => {
'runs': [
for (final id in [1, 2])
{
'id': id,
'title': 'Run item $id',
'status': 'succeeded',
},
],
},
},
'chat_sessions' => {
'chat_sessions': [
{
'id': 'a',
'title': 'Chat item a',
'backend': 'claude',
'model': 'claude-opus',
'mode': 'auto',
'mode_name': 'Auto',
'get_run' => {
'run_detail': {
'id': fields['run_id'],
'title': 'Run item ${fields['run_id']}',
'status': 'succeeded',
'input': {'prompt': 'Recorded input'},
},
{
'id': 'b',
'title': 'Chat item b',
'backend': 'claude',
'model': 'claude-opus',
'mode': 'auto',
'mode_name': 'Auto',
},
],
},
'chat_sessions' => {
'chat_sessions': [
{
'id': 'a',
'title': 'Chat item a',
'backend': 'claude',
'model': 'claude-opus',
'mode': 'auto',
'mode_name': 'Auto',
},
{
'id': 'b',
'title': 'Chat item b',
'backend': 'claude',
'model': 'claude-opus',
'mode': 'auto',
'mode_name': 'Auto',
},
],
},
'chat_messages' => {
'chat_history': {'messages': []},
},
_ => {},
},
'chat_messages' => {
'chat_history': {'messages': []},
);
final shell = AdaptiveShell(
cupertino: cupertino,
destinationBodies: {
AppDestination.pipelines: (_) =>
PipelinesScreen(gateway: gateway, embedded: true),
AppDestination.runs: (_) => RunsScreen(gateway: gateway),
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
},
_ => {},
},
);
final shell = AdaptiveShell(
cupertino: cupertino,
destinationBodies: {
AppDestination.pipelines: (_) =>
PipelinesScreen(gateway: gateway, embedded: true),
AppDestination.runs: (_) => RunsScreen(gateway: gateway),
AppDestination.chat: (_) => ChatScreen(gateway: gateway),
},
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
home: shell,
)
: MaterialApp(
theme: brightness == Brightness.dark
? appDarkTheme()
: appLightTheme(),
home: shell,
),
);
await tester.pumpAndSettle();
final paneWidths = <double>[];
for (final destination in ['Pipelines', 'Runs', 'Chat']) {
if (destination != 'Pipelines') {
await tester.tap(find.text(destination).first);
await tester.pumpAndSettle();
expect(
tester.takeException(),
isNull,
reason: '$destination list',
);
}
final list = find.byKey(const ValueKey('list-detail-list'));
final detail = find.byKey(const ValueKey('list-detail-body'));
expect(list, findsOneWidget);
expect(detail, findsOneWidget);
final before = tester.getSize(list).width;
paneWidths.add(before);
expect(before, closeTo(tester.getSize(detail).width, 0.01));
final rowKeys = switch (destination) {
'Pipelines' => ['pipeline-row-1', 'pipeline-row-2'],
'Runs' => ['run-row-1', 'run-row-2'],
_ => ['chat-row-a', 'chat-row-b'],
};
for (final key in rowKeys) {
final target = find.byKey(ValueKey(key));
// In a narrow Cupertino list the row center can be a star/menu
// control. Open the chat through its title, not a trailing action.
await tester.tap(
destination == 'Chat'
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
home: shell,
)
: MaterialApp(
theme: brightness == Brightness.dark
? appDarkTheme()
: appLightTheme(),
home: shell,
),
);
await tester.pumpAndSettle();
final paneWidths = <double>[];
final bodyWidths = <double>[];
for (final destination in ['Pipelines', 'Runs', 'Chat']) {
if (destination != 'Pipelines') {
await tester.tap(find.text(destination).first);
await tester.pumpAndSettle();
expect(
tester.takeException(),
isNull,
reason: '$destination list',
);
}
final list = find.byKey(const ValueKey('list-detail-list'));
final detail = find.byKey(const ValueKey('list-detail-body'));
expect(list, findsOneWidget);
expect(detail, findsOneWidget);
final before = tester.getSize(list).width;
final bodyBefore = tester.getSize(detail).width;
paneWidths.add(before);
bodyWidths.add(bodyBefore);
expect(bodyBefore, greaterThanOrEqualTo(width * 0.5));
expect(bodyBefore, lessThanOrEqualTo(width * 0.6));
expect(bodyBefore, greaterThan(before));
final rowKeys = switch (destination) {
'Pipelines' => ['pipeline-row-1', 'pipeline-row-2'],
'Runs' => ['run-row-1', 'run-row-2'],
_ => ['chat-row-a', 'chat-row-b'],
};
for (final key in rowKeys) {
final target = find.byKey(ValueKey(key));
// In a narrow Cupertino list the row center can be a star/menu
// control. Open the chat through its title, not a trailing action.
final opener = destination == 'Chat'
? find.descendant(
of: target,
matching: find.text('Chat item ${key.split('-').last}'),
)
: target,
);
: target;
await tester.ensureVisible(opener);
await tester.tap(opener);
await tester.pumpAndSettle();
expect(
tester.takeException(),
isNull,
reason: '$destination after opening $key',
);
expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(tester.getSize(detail).width, closeTo(bodyBefore, 0.01));
expect(
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
isFalse,
);
for (final rowKey in rowKeys) {
final row = find.byKey(ValueKey(rowKey));
expect(
row,
findsOneWidget,
reason: 'the list must remain visible',
);
final selected = rowKey == key;
expect(
tester.getSemantics(row).flagsCollection.isSelected ==
Tristate.isTrue,
selected,
reason: '$destination: $rowKey after opening $key',
);
final context = tester.element(row);
if (cupertino) {
final color = destination == 'Runs'
? tester.widget<CupertinoButton>(row).color
: tester.widget<CupertinoListTile>(row).backgroundColor;
expect(
color,
selected
? CupertinoColors.tertiarySystemFill.resolveFrom(
context,
)
: isNull,
);
} else if (destination == 'Runs') {
final id = rowKey.split('-').last;
expect(
tester
.widget<Material>(
find.byKey(ValueKey('run-row-surface-$id')),
)
.color,
selected
? Theme.of(context).colorScheme.secondaryContainer
: Colors.transparent,
);
} else {
final tile = tester.widget<ListTile>(row);
expect(tile.selected, selected);
expect(
tile.selectedTileColor,
Theme.of(context).colorScheme.secondaryContainer,
);
}
}
}
if (destination == 'Chat') {
final star = find.byKey(const Key('chat-star-b'));
await tester.ensureVisible(star);
await tester.tap(star);
await tester.pumpAndSettle();
expect(
gateway
.callsOf('chat_star')
.last
.fields['chat_query']['session_id'],
'b',
);
final actions = find.byKey(const Key('chat-actions-b'));
await tester.ensureVisible(actions);
await tester.tap(actions);
await tester.pumpAndSettle();
expect(find.text('Rename…'), findsOneWidget);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
}
// A phone still uses stock page navigation; returning to a wide
// window must keep the selected item without clearing its route.
tester.view.physicalSize = const Size(390, 900);
await tester.pumpAndSettle();
expect(
tester.takeException(),
isNull,
reason: '$destination after opening $key',
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
isTrue,
reason: '$destination should push its selected item on a phone',
);
expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(tester.getSize(detail).width, closeTo(before, 0.01));
expect(
find.byKey(const ValueKey('list-detail-list')),
findsNothing,
);
tester.view.physicalSize = Size(width, 900);
await tester.pumpAndSettle();
expect(
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
isFalse,
);
for (final rowKey in rowKeys) {
final row = find.byKey(ValueKey(rowKey));
expect(
row,
findsOneWidget,
reason: 'the list must remain visible',
);
final selected = rowKey == key;
expect(
tester.getSemantics(row).flagsCollection.isSelected ==
Tristate.isTrue,
selected,
reason: '$destination: $rowKey after opening $key',
);
final context = tester.element(row);
if (cupertino) {
final color = destination == 'Runs'
? tester.widget<CupertinoButton>(row).color
: tester.widget<CupertinoListTile>(row).backgroundColor;
expect(
color,
selected
? CupertinoColors.tertiarySystemFill.resolveFrom(
context,
)
: isNull,
);
} else if (destination == 'Runs') {
final id = rowKey.split('-').last;
expect(
tester
.widget<Material>(
find.byKey(ValueKey('run-row-surface-$id')),
)
.color,
selected
? Theme.of(context).colorScheme.secondaryContainer
: Colors.transparent,
);
} else {
final tile = tester.widget<ListTile>(row);
expect(tile.selected, selected);
expect(
tile.selectedTileColor,
Theme.of(context).colorScheme.secondaryContainer,
);
}
}
expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(
tester
.getSemantics(find.byKey(ValueKey(rowKeys.last)))
.flagsCollection
.isSelected,
Tristate.isTrue,
);
}
// A phone still uses stock page navigation; returning to a wide
// window must keep the selected item without clearing its route.
tester.view.physicalSize = const Size(390, 900);
await tester.pumpAndSettle();
expect(
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
isTrue,
reason: '$destination should push its selected item on a phone',
paneWidths,
everyElement(closeTo(paneWidths.first, 0.01)),
reason: 'Pipelines, Runs and Chat must use identical pane widths',
);
expect(tester.takeException(), isNull);
expect(
find.byKey(const ValueKey('list-detail-list')),
findsNothing,
bodyWidths,
everyElement(closeTo(bodyWidths.first, 0.01)),
reason:
'Every destination must share the body-priority sizing policy',
);
tester.view.physicalSize = Size(width, 900);
await tester.pumpAndSettle();
expect(
tester.state<NavigatorState>(find.byType(Navigator)).canPop(),
isFalse,
);
expect(tester.getSize(list).width, closeTo(before, 0.01));
expect(
tester
.getSemantics(find.byKey(ValueKey(rowKeys.last)))
.flagsCollection
.isSelected,
Tristate.isTrue,
);
}
expect(
paneWidths,
everyElement(closeTo(paneWidths.first, 0.01)),
reason: 'Pipelines, Runs and Chat must use identical pane widths',
);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox.shrink());
});
await tester.pumpWidget(const SizedBox.shrink());
});
}
}
}
}
+4 -3
View File
@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import '../features/runs/ui/run_detail_finders.dart';
import '../native_back.dart';
import 'package:pipelines_app/application/app_route.dart';
import 'package:pipelines_app/application/app_router.dart';
@@ -335,8 +336,8 @@ void main() {
// The query reached the detail: visit 0 is the earlier plan visit (seq 1),
// not the latest one the pane would show without a visit.
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('plan · visit 1'), findsOneWidget);
expect(find.text('plan · visit 5'), findsNothing);
expectVisitHeading(tester, 'plan', 1);
expect(find.text('Visit 5'), findsNothing);
expect(provider.value.uri.toString(), '/runs/77/stage/plan?visit=0');
// A history entry the app itself writes is parsed back as a query, so
@@ -350,7 +351,7 @@ void main() {
await tester.pump();
await tester.pump(const Duration(milliseconds: 400));
await tester.pump(const Duration(milliseconds: 400));
expect(find.text('plan · visit 5'), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
expect(provider.value.uri.path, '/runs/77/stage/plan');
expect(provider.value.uri.query, 'visit=1');
});
+3 -14
View File
@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import '../features/runs/ui/run_detail_finders.dart';
import '../native_back.dart';
import 'package:pipelines_app/application/app_route.dart';
import 'package:pipelines_app/application/app_router.dart';
@@ -496,13 +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);
expect(
find.descendant(
of: find.byKey(const Key('run-visit-pane')),
matching: find.text('build · visit 2'),
),
findsOneWidget,
);
expectVisitHeading(tester, 'build', 2);
// Leave the visit page (it covers the shell), then a retired field hit
// opens the plain Summary with no visit.
@@ -613,13 +608,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(
find.descendant(
of: find.byKey(const Key('run-visit-pane')),
matching: find.text('build · visit 2'),
),
findsOneWidget,
);
expectVisitHeading(tester, 'build', 2);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
@@ -57,8 +57,7 @@ void main() {
);
expect(
find.text(
"This server has no request for choosing a chat's model, so a new "
"chat uses the server's default.",
"New chats start with the server's default model.",
),
findsOneWidget,
);
@@ -150,17 +149,28 @@ void main() {
findsOneWidget,
);
expect(find.text('Chat harness: OpenCode'), findsOneWidget);
await tester.ensureVisible(
find.byKey(const Key('chat-create-prompt-choice')),
);
await tester.tap(find.byKey(const Key('chat-create-prompt-choice')));
await tester.pumpAndSettle();
await tester.tap(find.text('Careful coding'));
await tester.pumpAndSettle();
expect(
find.textContaining('Act as a careful coding agent.'),
findsOneWidget,
);
await tester.ensureVisible(find.byKey(const Key('chat-create-backend')));
await tester.tap(find.byKey(const Key('chat-create-backend')));
await tester.pumpAndSettle();
await tester.tap(find.text('Codex'));
await tester.pumpAndSettle();
expect(find.text('Chat harness: Codex'), findsOneWidget);
await tester.ensureVisible(
find.byKey(const Key('chat-create-server-directory')),
);
await tester.tap(find.byKey(const Key('chat-create-server-directory')));
await tester.pumpAndSettle();
expect(find.text('/archive'), findsOneWidget);
@@ -68,6 +68,7 @@ Future<ChatDraft?> _create(
find.byKey(const Key('chat-create-instructions')),
prompt,
);
await tester.pump();
}
await tester.ensureVisible(find.byKey(const Key('chat-create-confirm')));
await tester.tap(find.byKey(const Key('chat-create-confirm')));
@@ -95,6 +96,11 @@ void main() {
await tester.pumpWidget(const SizedBox());
final second = await _create(tester, prompts);
expect(second!.instructions, isEmpty);
expect(
prompts.saved.values.single.text,
'Review only.',
reason: 'A promptless chat must not erase the Last used preset',
);
});
testWidgets('a chat starts without a prompt even after a prior choice', (
@@ -103,11 +109,11 @@ void main() {
final prompts = _MemoryPrompts();
final draft = await _create(tester, prompts);
expect(draft!.instructions, isEmpty);
expect(prompts.saved.values.single.send, isFalse);
expect(prompts.saved, isEmpty);
await tester.pumpWidget(const SizedBox());
await _create(tester, prompts);
expect(prompts.saved.values.single.send, isFalse);
expect(prompts.saved, isEmpty);
});
testWidgets('the prompt menu selects a preset and permits custom edits', (
@@ -182,6 +188,62 @@ void main() {
);
});
testWidgets(
'custom starts empty and survives switching to a preset and back',
(tester) async {
await _open(tester, _MemoryPrompts());
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
await tester.pumpAndSettle();
final field = find.byKey(const Key('chat-create-instructions'));
String text() => tester.widget<TextField>(field).controller!.text;
expect(text(), isEmpty);
expect(
tester
.widget<FilledButton>(find.byKey(const Key('chat-create-confirm')))
.onPressed,
isNull,
);
await tester.enterText(field, 'My custom draft');
await tester.pump();
await _pickPrompt(tester, 'Careful coding');
expect(text(), chatDefaultSessionInstructions);
await _pickPrompt(tester, 'Custom');
expect(text(), 'My custom draft');
expect(
tester
.widget<FilledButton>(find.byKey(const Key('chat-create-confirm')))
.onPressed,
isNotNull,
);
},
);
testWidgets('late saved data preserves opt-in and still offers Last used', (
tester,
) async {
final prompts = _DelayedPrompts();
await _open(tester, prompts, settle: false);
await tester.pump(const Duration(milliseconds: 1));
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
await tester.pump();
prompts.result.complete((send: true, text: 'Saved preset'));
await tester.pumpAndSettle();
expect(
tester
.widget<Switch>(find.byKey(const Key('chat-create-send-prompt')))
.value,
isTrue,
);
await _pickPrompt(tester, 'Last used prompt');
expect(
tester
.widget<TextField>(find.byKey(const Key('chat-create-instructions')))
.controller!
.text,
'Saved preset',
);
});
testWidgets('Cupertino prompt chooser has native preset and custom choices', (
tester,
) async {
@@ -213,6 +275,15 @@ void main() {
});
}
Future<void> _pickPrompt(WidgetTester tester, String label) async {
final chooser = find.byKey(const Key('chat-create-prompt-choice'));
await tester.ensureVisible(chooser);
await tester.tap(chooser);
await tester.pumpAndSettle();
await tester.tap(find.text(label).last);
await tester.pumpAndSettle();
}
Future<void> _open(
WidgetTester tester,
ChatCreatePromptStore prompts, {
@@ -185,14 +185,17 @@ void main() {
greaterThan(tester.getCenter(find.text('Starred chat')).dx),
);
// The meta line keeps `CupertinoListTile`'s native 12pt subtitle style; it
// must not be rendered at the title's body size. The colour-only style the
// row passes merges with the tile's own `DefaultTextStyle`.
// Metadata and state use native caption roles, not title-sized text.
final titleStyle = _styleOf(tester, 'Starred chat');
final metaStyle = _styleOf(tester, '5 min ago');
expect(metaStyle.fontSize, lessThan(titleStyle.fontSize!));
expect(metaStyle.fontSize, 12.0);
expect(_styleOf(tester, 'New').fontSize, titleStyle.fontSize);
expect(
metaStyle.fontSize,
CupertinoTheme.of(
tester.element(find.text('5 min ago')),
).textTheme.tabLabelTextStyle.fontSize,
);
expect(_styleOf(tester, 'New').fontSize, metaStyle.fontSize);
// Each session is still its own native tile with its own actions, so the
// inset group draws the separator between them.
@@ -34,6 +34,7 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
await tester.pumpAndSettle();
await _chooseCareful(tester);
await tester.tap(find.byKey(const Key('chat-create-confirm')));
await tester.pumpAndSettle();
@@ -196,6 +197,7 @@ void main() {
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('chat-create-send-prompt')));
await tester.pumpAndSettle();
await _chooseCareful(tester);
await tester.tap(find.byKey(const Key('chat-create-confirm')));
await tester.pumpAndSettle();
@@ -231,3 +233,12 @@ void main() {
expect(find.byKey(const Key('chat-row-error-s2')), findsNothing);
});
}
Future<void> _chooseCareful(WidgetTester tester) async {
final chooser = find.byKey(const Key('chat-create-prompt-choice'));
await tester.ensureVisible(chooser);
await tester.tap(chooser);
await tester.pumpAndSettle();
await tester.tap(find.text('Careful coding').last);
await tester.pumpAndSettle();
}
@@ -62,6 +62,7 @@ void main() {
testWidgets(
'material list keeps closed starred rows once and groups directories once',
(tester) async {
_inventoryViewport(tester);
final gateway = FakeChatGateway()
..sessionsReply = {'chat_sessions': sampleSessions()};
await pumpMaterialChat(tester, gateway);
@@ -101,6 +102,7 @@ void main() {
testWidgets(
'Cupertino app renders standard controls, groups and renames without Material',
(tester) async {
_inventoryViewport(tester);
final gateway = FakeChatGateway()
..sessionsReply = {'chat_sessions': sampleSessions()};
await pumpCupertinoChat(tester, gateway);
@@ -203,6 +205,7 @@ void main() {
testWidgets('closed chats start folded away behind their heading', (
tester,
) async {
_inventoryViewport(tester);
final gateway = FakeChatGateway()
..sessionsReply = {'chat_sessions': sampleSessions()};
await pumpMaterialChat(tester, gateway);
@@ -213,3 +216,10 @@ void main() {
expect(find.byKey(const Key('chat-row-s4')), findsOneWidget);
});
}
void _inventoryViewport(WidgetTester tester) {
// This test inventories every row; separate layout tests cover small screens.
tester.view.physicalSize = const Size(800, 1600);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
@@ -4,7 +4,13 @@ import 'package:flutter_test/flutter_test.dart';
/// Closed chats start folded away; opens that section when it is shown.
Future<void> expandClosedChats(WidgetTester tester) async {
final section = find.byKey(const ValueKey('chat-section-Closed'));
if (section.evaluate().isEmpty) return;
if (section.evaluate().isEmpty) {
await tester.scrollUntilVisible(
section,
200,
scrollable: find.byType(Scrollable).first,
);
}
final heading = find.descendant(of: section, matching: find.text('Closed'));
await tester.ensureVisible(heading.first);
await tester.tap(heading.first);
@@ -0,0 +1,44 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_scope_control.dart';
void main() {
for (final cupertino in [false, true]) {
for (final width in [120.0, 500.0]) {
testWidgets(
'native scope remains usable at $width, Cupertino=$cupertino',
(tester) async {
var scheduled = false;
final control = StatefulBuilder(
builder: (context, setState) => Center(
child: SizedBox(
width: width,
child: PipelineScopeControl(
scheduled: scheduled,
onSelected: (value) => setState(() => scheduled = value),
),
),
),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: control))
: MaterialApp(home: Scaffold(body: control)),
);
await tester.pumpAndSettle();
if (width == 120) {
await tester.tap(find.byKey(const Key('pipeline-scope')));
await tester.pumpAndSettle();
await tester.tap(find.text('Scheduled').last);
} else {
await tester.tap(find.text('Scheduled'));
}
await tester.pumpAndSettle();
expect(scheduled, isTrue);
expect(tester.takeException(), isNull);
},
);
}
}
}
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'run_detail_finders.dart';
import 'package:pipelines_app/features/runs/ui/run_graph_preview.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
@@ -136,8 +137,8 @@ void main() {
await pumpDeepLink(tester, platform, stage: 'plan', visit: 0);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('plan · visit 1'), findsOneWidget);
expect(find.text('plan · visit 5'), findsNothing);
expectVisitHeading(tester, 'plan', 1);
expect(find.text('Visit 5'), findsNothing);
// The visit is its own page over the Timeline tab.
expect(
find.byKey(
@@ -180,7 +181,7 @@ void main() {
await pumpDeepLink(tester, RunDetailTestPlatform.material, stage: 'plan');
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('plan · visit 5'), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
});
testWidgets('a Graph click opens the same latest visit as the stage route', (
@@ -194,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);
expect(find.text('plan · visit 5'), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
});
testWidgets('an out-of-range visit is clamped to the stage last visit', (
@@ -208,7 +209,7 @@ void main() {
);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('plan · visit 5'), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
});
testWidgets('a declared but unvisited stage selects its graph node', (
@@ -258,7 +259,7 @@ void main() {
await tester.pumpAndSettle();
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('plan · visit 5'), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
});
testWidgets('a route change applies its visit and a plain route closes it', (
@@ -296,11 +297,11 @@ void main() {
),
);
await tester.pumpAndSettle();
expect(find.text('plan · visit 1'), findsOneWidget);
expectVisitHeading(tester, 'plan', 1);
rebuild(() => visit = 1);
await tester.pumpAndSettle();
expect(find.text('plan · visit 5'), findsOneWidget);
expectVisitHeading(tester, 'plan', 5);
rebuild(() => stage = null);
await tester.pumpAndSettle();
@@ -1,6 +1,22 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
/// Wide screens deliberately repeat the selected title in the visible list.
Finder runDetailText(String text) =>
find.descendant(of: find.byType(RunDetailView), matching: find.text(text));
/// Stage identity and visit coordinates are separate rendered fields now.
void expectVisitHeading(WidgetTester tester, String stage, num sequence) {
final pane = find.byKey(const Key('run-visit-pane'));
expect(pane, findsOneWidget);
final title = find.descendant(
of: pane,
matching: find.byKey(const Key('run-visit-title')),
);
expect(tester.widget<Text>(title).data, stage);
expect(
find.descendant(of: pane, matching: find.text('Visit $sequence')),
findsOneWidget,
);
}
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'run_detail_finders.dart';
import 'package:pipelines_app/features/graph/widgets/graph_stage_node.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_canvas.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
@@ -65,7 +66,7 @@ void main() {
findsNothing,
);
expect(find.byKey(const Key('run-visit-title')), findsOneWidget);
expect(find.text('plan · visit 1'), findsOneWidget);
expectVisitHeading(tester, 'plan', 1);
expect(find.byKey(const Key('run-visit-facts-grid')), findsOneWidget);
expect(find.textContaining('audit · visit'), findsNothing);
});
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'run_detail_finders.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_gallery_page.dart';
import 'package:pipelines_app/features/graph/widgets/stage_definition_view.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_facts.dart';
@@ -182,7 +183,7 @@ void main() {
});
await openVisit(tester, platform, run: run, sequence: 2);
expect(find.text('plan · visit 2'), findsOneWidget);
expectVisitHeading(tester, 'plan', 2);
await openVisitTab(tester, RunVisitSection.artifacts);
expect(find.text('plan-2.csv'), findsOneWidget);
expect(find.text('public/shared.csv'), findsNothing);
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'run_detail_finders.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/run_detail_view.dart';
@@ -112,7 +113,7 @@ void main() {
);
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
expect(find.text('build · visit 2'), findsOneWidget);
expectVisitHeading(tester, 'build', 2);
});
}
@@ -66,7 +66,13 @@ void main() {
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
// The body keeps the landed viewer's own identity for that visit.
expect(find.text('plan'), findsOneWidget);
expect(
find.descendant(
of: find.byType(ChangesViewer),
matching: find.text('plan'),
),
findsOneWidget,
);
expect(find.text('Visit 1 · completed'), findsOneWidget);
expect(find.text('lib/plan.dart'), findsOneWidget);
expect(find.text('lib/build.dart'), findsNothing);