Remove Cupertino branches from runs UI

Keep the Material-only run detail implementation while preserving public parameters for callers. Narrow the corresponding widget tests to the supported Material host and remove unused Cupertino-only code.
This commit is contained in:
2026-11-11 05:11:26 +00:00
parent 591e1eec3a
commit 75929a0a41
26 changed files with 568 additions and 1121 deletions
@@ -1,4 +1,3 @@
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';
@@ -10,8 +9,6 @@ import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
import '../../changes/fixtures.dart';
enum _Platform { material, cupertino }
class _FakeGateway implements ApiGateway {
_FakeGateway(this.detail);
final JsonMap detail;
@@ -53,7 +50,6 @@ JsonMap _run({
Future<void> _pumpDetail(
WidgetTester tester,
_Platform platform,
RunsController controller,
ApiGateway gateway,
) async {
@@ -65,126 +61,105 @@ Future<void> _pumpDetail(
gateway: gateway,
onBack: () {},
);
await tester.pumpWidget(
platform == _Platform.material
? MaterialApp(home: Scaffold(body: view))
: CupertinoApp(
// The real host chooses Cupertino on iOS/macOS; state that platform
// without mutating the global debug override, as the Changes tests do.
builder: (context, app) => Theme(
data: ThemeData(platform: TargetPlatform.iOS),
child: app!,
),
home: CupertinoPageScaffold(child: view),
),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: view)));
await tester.pumpAndSettle();
}
void main() {
for (final platform in _Platform.values) {
testWidgets(
'${platform.name}: Changes opens the recorded files, diff and returns',
(tester) async {
final gateway = _FakeGateway(
_run(
fileChanges: captureFixture(
files: [
fileChangeFixture(
path: 'lib/feature.dart',
patch: multiHunkPatch,
),
],
),
),
);
final controller = RunsController(RunsRepository(gateway));
addTearDown(controller.dispose);
await controller.select(9);
await _pumpDetail(tester, platform, controller, gateway);
testWidgets('Changes opens the recorded files, diff and returns', (
tester,
) async {
final gateway = _FakeGateway(
_run(
fileChanges: captureFixture(
files: [
fileChangeFixture(path: 'lib/feature.dart', patch: multiHunkPatch),
],
),
),
);
final controller = RunsController(RunsRepository(gateway));
addTearDown(controller.dispose);
await controller.select(9);
await _pumpDetail(tester, controller, gateway);
await tester.ensureVisible(
find.byKey(const ValueKey('run-detail-tab-changes')),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('run-detail-tab-changes')));
await tester.pumpAndSettle();
expect(
find.byKey(const ValueKey('run-detail-tab-changes')),
findsOneWidget,
);
expect(find.text('lib/feature.dart'), findsOneWidget);
expect(
find.text('1 file changed · +2 -2 · capture incomplete'),
findsOneWidget,
);
// The tab is the final state: each path once, no visit pages.
expect(find.byKey(ChangesVisitPager.nextKey), findsNothing);
await tester.tap(
find.byKey(const ValueKey('change-final-lib/feature.dart')),
);
await tester.pumpAndSettle();
final rendered = tester
.widgetList<RichText>(find.byType(RichText))
.map((rich) => rich.text.toPlainText())
.join('\n');
expect(rendered, contains('+ added line'));
expect(rendered, contains('- removed line'));
await tester.pageBack();
await tester.pumpAndSettle();
expect(find.text('lib/feature.dart'), findsOneWidget);
// Changes is a tab: Summary is one tap away and the run stays open.
final summaryTab = find.byKey(const ValueKey('run-detail-tab-summary'));
await tester.ensureVisible(summaryTab);
await tester.pumpAndSettle();
await tester.tap(summaryTab);
await tester.pumpAndSettle();
expect(find.text('Wiring run'), findsOneWidget);
expect(
find.byKey(const ValueKey('run-detail-tab-changes')),
findsOneWidget,
);
expect(find.text('lib/feature.dart'), findsNothing);
},
await tester.ensureVisible(
find.byKey(const ValueKey('run-detail-tab-changes')),
);
testWidgets(
'${platform.name}: an unavailable capture keeps its gap wording',
(tester) async {
final diagnostic =
'Workspace snapshot unavailable; changes could not be compared.';
final gateway = _FakeGateway(
_run(
fileChanges: captureFixture(
status: 'unavailable',
diagnostic: diagnostic,
),
),
);
final controller = RunsController(RunsRepository(gateway));
addTearDown(controller.dispose);
await controller.select(9);
await _pumpDetail(tester, platform, controller, gateway);
await tester.pumpAndSettle();
await tester.ensureVisible(
find.byKey(const ValueKey('run-detail-tab-changes')),
);
await tester.tap(find.byKey(const ValueKey('run-detail-tab-changes')));
await tester.pumpAndSettle();
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('run-detail-tab-changes')));
await tester.pumpAndSettle();
expect(find.text('Changes · capture unavailable'), findsOneWidget);
expect(find.text(diagnostic), findsWidgets);
expect(find.text(emptyCaptureDetail), findsNothing);
expect(find.text('No changes observed'), findsNothing);
},
expect(
find.byKey(const ValueKey('run-detail-tab-changes')),
findsOneWidget,
);
}
expect(find.text('lib/feature.dart'), findsOneWidget);
expect(
find.text('1 file changed · +2 -2 · capture incomplete'),
findsOneWidget,
);
// The tab is the final state: each path once, no visit pages.
expect(find.byKey(ChangesVisitPager.nextKey), findsNothing);
await tester.tap(
find.byKey(const ValueKey('change-final-lib/feature.dart')),
);
await tester.pumpAndSettle();
final rendered = tester
.widgetList<RichText>(find.byType(RichText))
.map((rich) => rich.text.toPlainText())
.join('\n');
expect(rendered, contains('+ added line'));
expect(rendered, contains('- removed line'));
await tester.pageBack();
await tester.pumpAndSettle();
expect(find.text('lib/feature.dart'), findsOneWidget);
// Changes is a tab: Summary is one tap away and the run stays open.
final summaryTab = find.byKey(const ValueKey('run-detail-tab-summary'));
await tester.ensureVisible(summaryTab);
await tester.pumpAndSettle();
await tester.tap(summaryTab);
await tester.pumpAndSettle();
expect(find.text('Wiring run'), findsOneWidget);
expect(
find.byKey(const ValueKey('run-detail-tab-changes')),
findsOneWidget,
);
expect(find.text('lib/feature.dart'), findsNothing);
});
testWidgets('an unavailable capture keeps its gap wording', (tester) async {
final diagnostic =
'Workspace snapshot unavailable; changes could not be compared.';
final gateway = _FakeGateway(
_run(
fileChanges: captureFixture(
status: 'unavailable',
diagnostic: diagnostic,
),
),
);
final controller = RunsController(RunsRepository(gateway));
addTearDown(controller.dispose);
await controller.select(9);
await _pumpDetail(tester, controller, gateway);
await tester.ensureVisible(
find.byKey(const ValueKey('run-detail-tab-changes')),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const ValueKey('run-detail-tab-changes')));
await tester.pumpAndSettle();
expect(find.text('Changes · capture unavailable'), findsOneWidget);
expect(find.text(diagnostic), findsWidgets);
expect(find.text(emptyCaptureDetail), findsNothing);
expect(find.text('No changes observed'), findsNothing);
});
}
@@ -1,4 +1,3 @@
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';
@@ -10,8 +9,6 @@ import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
import '../../changes/fixtures.dart';
enum _Platform { material, cupertino }
class _FakeGateway implements ApiGateway {
_FakeGateway(this.detail);
final JsonMap detail;
@@ -53,7 +50,6 @@ JsonMap _run({
Future<void> _pumpDetail(
WidgetTester tester,
_Platform platform,
JsonMap run, {
Brightness brightness = Brightness.light,
}) async {
@@ -70,30 +66,20 @@ Future<void> _pumpDetail(
onBack: () {},
);
await tester.pumpWidget(
platform == _Platform.material
? MaterialApp(
theme: ThemeData(brightness: brightness),
home: Scaffold(body: view),
)
: CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
builder: (context, app) => Theme(
data: ThemeData(platform: TargetPlatform.iOS),
child: app!,
),
home: CupertinoPageScaffold(child: view),
),
MaterialApp(
theme: ThemeData(brightness: brightness),
home: Scaffold(body: view),
),
);
await tester.pumpAndSettle();
}
Future<void> _openChanges(
WidgetTester tester,
_Platform platform,
JsonMap run, {
Brightness brightness = Brightness.light,
}) async {
await _pumpDetail(tester, platform, run, brightness: brightness);
await _pumpDetail(tester, run, brightness: brightness);
await tester.ensureVisible(
find.byKey(const ValueKey('run-detail-tab-changes')),
);
@@ -122,93 +108,72 @@ void main() {
);
});
for (final platform in _Platform.values) {
testWidgets('${platform.name}: a failed run tab shows its final changes', (
testWidgets('a failed run tab shows its final changes', (tester) async {
await _openChanges(
tester,
) async {
await _openChanges(
tester,
platform,
_run(
status: 'failed',
fileChanges: captureFixture(
files: [fileChangeFixture(path: 'lib/feature.dart')],
),
_run(
status: 'failed',
fileChanges: captureFixture(
files: [fileChangeFixture(path: 'lib/feature.dart')],
),
);
// The tab is the end state: each changed path once, no visit pages.
expect(find.byKey(const ValueKey('changes-final')), findsOneWidget);
expect(
find.byKey(const ValueKey('change-final-lib/feature.dart')),
findsOneWidget,
);
expect(find.byKey(ChangesVisitPager.nextKey), findsNothing);
expect(tester.takeException(), isNull);
});
testWidgets(
'${platform.name}: an active run offers no snapshot Changes page',
(tester) async {
await _pumpDetail(
tester,
platform,
_run(status: 'running', stepStatus: 'running'),
);
// The opened page would not follow live captures, so an executing run
// has no action until the live visit pane can show them.
expect(
find.byKey(const ValueKey('run-detail-tab-changes')),
findsNothing,
);
expect(find.text('Changes'), findsNothing);
expect(tester.takeException(), isNull);
},
),
);
testWidgets(
'${platform.name}: the Changes page follows a dark host theme',
(tester) async {
await _openChanges(
tester,
platform,
_run(
status: 'succeeded',
fileChanges: captureFixture(
files: [fileChangeFixture(path: 'lib/feature.dart')],
),
),
brightness: Brightness.dark,
);
final header = tester.widget<Text>(
find.textContaining('1 file changed'),
);
final color = header.style?.color;
expect(color, isNotNull);
expect(
color!.computeLuminance(),
greaterThan(0.5),
reason: 'section text must be light on a dark host: $color',
);
// The diff opens on the app Navigator, above the page's theme, so its
// own header must follow the host brightness too.
await tester.tap(
find.byKey(const ValueKey('change-final-lib/feature.dart')),
);
await tester.pumpAndSettle();
final title = tester.widget<Text>(find.text('Modified'));
final titleColor = title.style?.color;
expect(titleColor, isNotNull);
expect(
titleColor!.computeLuminance(),
greaterThan(0.5),
reason: 'diff header must be light on a dark host: $titleColor',
);
expect(tester.takeException(), isNull);
},
// The tab is the end state: each changed path once, no visit pages.
expect(find.byKey(const ValueKey('changes-final')), findsOneWidget);
expect(
find.byKey(const ValueKey('change-final-lib/feature.dart')),
findsOneWidget,
);
}
expect(find.byKey(ChangesVisitPager.nextKey), findsNothing);
expect(tester.takeException(), isNull);
});
testWidgets('an active run offers no snapshot Changes page', (tester) async {
await _pumpDetail(tester, _run(status: 'running', stepStatus: 'running'));
// The opened page would not follow live captures, so an executing run
// has no action until the live visit pane can show them.
expect(find.byKey(const ValueKey('run-detail-tab-changes')), findsNothing);
expect(find.text('Changes'), findsNothing);
expect(tester.takeException(), isNull);
});
testWidgets('the Changes page follows a dark host theme', (tester) async {
await _openChanges(
tester,
_run(
status: 'succeeded',
fileChanges: captureFixture(
files: [fileChangeFixture(path: 'lib/feature.dart')],
),
),
brightness: Brightness.dark,
);
final header = tester.widget<Text>(find.textContaining('1 file changed'));
final color = header.style?.color;
expect(color, isNotNull);
expect(
color!.computeLuminance(),
greaterThan(0.5),
reason: 'section text must be light on a dark host: $color',
);
// The diff opens on the app Navigator, above the page's theme, so its
// own header must follow the host brightness too.
await tester.tap(
find.byKey(const ValueKey('change-final-lib/feature.dart')),
);
await tester.pumpAndSettle();
final title = tester.widget<Text>(find.text('Modified'));
final titleColor = title.style?.color;
expect(titleColor, isNotNull);
expect(
titleColor!.computeLuminance(),
greaterThan(0.5),
reason: 'diff header must be light on a dark host: $titleColor',
);
expect(tester.takeException(), isNull);
});
}
@@ -1,6 +1,5 @@
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';
@@ -93,13 +92,7 @@ Future<void> pumpDeepLink(
child: view,
);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pumpWidget(
platform == RunDetailTestPlatform.material
? MaterialApp(home: Scaffold(body: page))
: CupertinoApp(
home: CupertinoPageScaffold(child: SafeArea(child: page)),
),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: page)));
await tester.pumpAndSettle();
}
@@ -1,4 +1,3 @@
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';
@@ -7,87 +6,56 @@ 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.
/// The run and stage detail bodies are flat on the page, 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('Summary and Timeline show their bodies', (tester) async {
await pumpRunDetail(tester, RunDetailTestPlatform.material);
expect(find.text('Input'), findsOneWidget);
await openRunDetailTab(tester, RunDetailTab.timeline);
expect(find.byKey(const ValueKey('run-timeline-visit-1')), findsOneWidget);
expect(tester.takeException(), isNull);
});
if (platform == RunDetailTestPlatform.material) {
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('the stage Session shows its documents', (tester) async {
await openVisit(tester, RunDetailTestPlatform.material);
await openVisitTab(tester, RunVisitSection.session);
expect(find.text('Turn documents'), findsOneWidget);
expect(tester.takeException(), isNull);
});
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();
testWidgets('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(MaterialApp(home: Scaffold(body: 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');
}
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);
});
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/ui/run_graph_preview.dart';
@@ -10,7 +9,7 @@ import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
/// Shared run-detail Graph fixtures and host helpers for the tab tests.
enum RunDetailTestPlatform { material, cupertino }
enum RunDetailTestPlatform { material }
class RunDetailFakeGateway implements ApiGateway {
RunDetailFakeGateway(this.detail);
@@ -106,18 +105,13 @@ Future<RunsController> pumpRunDetail(
// detail's open tab or pane, so start from an empty tree.
await tester.pumpWidget(const SizedBox.shrink());
await tester.pumpWidget(
platform == RunDetailTestPlatform.material
? MaterialApp(
theme: ThemeData(
brightness: brightness,
platform: TargetPlatform.android,
),
home: Scaffold(body: page),
)
: CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
home: CupertinoPageScaffold(child: SafeArea(child: page)),
),
MaterialApp(
theme: ThemeData(
brightness: brightness,
platform: TargetPlatform.android,
),
home: Scaffold(body: page),
),
);
await tester.pumpAndSettle();
return controller;
@@ -1,4 +1,3 @@
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';
@@ -24,8 +23,7 @@ class _FakeGateway implements ApiGateway {
Future<void> _pump(
WidgetTester tester,
String status,
bool cupertino, {
String status, {
OpenPipeline? onOpenPipeline,
}) async {
tester.view.physicalSize = const Size(390, 900);
@@ -51,11 +49,7 @@ Future<void> _pump(
onBack: () {},
onOpenPipeline: onOpenPipeline,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: view))
: MaterialApp(home: Scaffold(body: view)),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: view)));
await tester.pumpAndSettle();
}
@@ -66,43 +60,37 @@ Future<bool> _menuOffersRetry(WidgetTester tester) async {
}
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'cupertino' : 'material';
testWidgets('$host: Retry is a more-menu option for a failed run', (
testWidgets('Retry is a more-menu option for a failed run', (tester) async {
await _pump(tester, 'failed');
// Not in the header itself.
expect(find.text('Retry'), findsNothing);
expect(await _menuOffersRetry(tester), isTrue);
});
testWidgets('the pipeline name opens that pipeline at the run\'s '
'version', (tester) async {
final opened = <(int, int)>[];
await _pump(
tester,
) async {
await _pump(tester, 'failed', cupertino);
// Not in the header itself.
expect(find.text('Retry'), findsNothing);
expect(await _menuOffersRetry(tester), isTrue);
});
'succeeded',
onOpenPipeline: (id, version) => opened.add((id, version)),
);
// The title expands first; the pipeline action is intentionally only
// available in that expanded state.
await tester.tap(find.text('Nightly build').first);
await tester.pump();
await tester.tap(find.byKey(runPipelineLinkKey));
await tester.pump();
expect(opened, [(10, 3)]);
// The run's title pill is the link, announced as opening the pipeline.
expect(
find.bySemanticsLabel(RegExp('Open pipeline nightly')),
findsOneWidget,
);
});
testWidgets('$host: the pipeline name opens that pipeline at the run\'s '
'version', (tester) async {
final opened = <(int, int)>[];
await _pump(
tester,
'succeeded',
cupertino,
onOpenPipeline: (id, version) => opened.add((id, version)),
);
// The title expands first; the pipeline action is intentionally only
// available in that expanded state.
await tester.tap(find.text('Nightly build').first);
await tester.pump();
await tester.tap(find.byKey(runPipelineLinkKey));
await tester.pump();
expect(opened, [(10, 3)]);
// The run's title pill is the link, announced as opening the pipeline.
expect(
find.bySemanticsLabel(RegExp('Open pipeline nightly')),
findsOneWidget,
);
});
testWidgets('$host: a succeeded run offers no Retry', (tester) async {
await _pump(tester, 'succeeded', cupertino);
expect(await _menuOffersRetry(tester), isFalse);
});
}
testWidgets('a succeeded run offers no Retry', (tester) async {
await _pump(tester, 'succeeded');
expect(await _menuOffersRetry(tester), isFalse);
});
}
@@ -1,4 +1,3 @@
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';
@@ -173,20 +172,10 @@ void main() {
// The prompt is part of Input, shown as data, not a block of its own.
expect(find.text('Original prompt'), findsNothing);
if (platform == RunDetailTestPlatform.material) {
final hash = tester.widget<SelectableText>(
find.widgetWithText(SelectableText, 'abc123def456'),
);
expect(hash.style?.fontFamily, appMonospaceFamily);
} else {
final hash = tester.widget<Text>(
find.descendant(
of: find.byKey(const ValueKey('run-detail-summary-content-hash')),
matching: find.text('abc123def456'),
),
);
expect(hash.style?.fontFamily, appMonospaceFamily);
}
final hash = tester.widget<SelectableText>(
find.widgetWithText(SelectableText, 'abc123def456'),
);
expect(hash.style?.fontFamily, appMonospaceFamily);
});
testWidgets('${platform.name} short summary facts share a line on a '
@@ -232,7 +221,6 @@ void main() {
expect(grid.width, moreOrLessEquals(900));
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 '
@@ -101,7 +101,7 @@ void main() {
expect(
pill.width,
FloatingDestinationBar.rowWidth(
cupertino: platform != RunDetailTestPlatform.material,
cupertino: false,
tabs: renderedRunDetailTabs.length,
),
);
@@ -42,14 +42,7 @@ void main() {
for (final section in shownVisitSections) {
final tab = find.byKey(ValueKey('run-visit-tab-${section.name}'));
expect(
find.descendant(
of: tab,
matching: find.byIcon(
platform == RunDetailTestPlatform.cupertino
? section.cupertinoIcon
: section.icon,
),
),
find.descendant(of: tab, matching: find.byIcon(section.icon)),
findsOneWidget,
reason: section.name,
);
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -9,8 +8,6 @@ import 'package:pipelines_app/features/runs/data/runs_repository.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
enum AppPlatform { material, cupertino }
class FakeGateway implements ApiGateway {
FakeGateway(this.detail);
JsonMap detail;
@@ -63,7 +60,6 @@ JsonMap runFixture({int steps = 2}) {
Future<void> pumpDetail(
WidgetTester tester,
AppPlatform platform,
RunsController controller,
FakeGateway gateway, {
VoidCallback? onBack,
@@ -85,13 +81,7 @@ Future<void> pumpDetail(
).copyWith(textScaler: const TextScaler.linear(2)),
child: view,
);
await tester.pumpWidget(
platform == AppPlatform.material
? MaterialApp(home: Scaffold(body: page))
: CupertinoApp(
home: CupertinoPageScaffold(child: SafeArea(child: page)),
),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: page)));
if (settle) {
await tester.pumpAndSettle();
} else {
@@ -133,140 +123,110 @@ void main() {
});
tearDown(() => controller.dispose());
// The run's More menu is Material only.
for (final platform in [AppPlatform.material]) {
testWidgets('${platform.name} detail at 390 with 2x text', (tester) async {
gateway.detail = runFixture(steps: 12);
await controller.select(1);
await pumpDetail(
tester,
platform,
controller,
gateway,
size: const Size(390, 1200),
);
expect(tester.takeException(), isNull);
expect(find.text('Nightly build'), findsOneWidget);
expect(find.textContaining('Original prompt'), findsNothing);
// The title is the top bar's; the status kicker leads the body below
// it, and the body does not repeat the title.
expect(find.byKey(const Key('run-status-kicker')), findsOneWidget);
expect(
tester.getTopLeft(find.byKey(const Key('run-status-kicker'))).dy,
greaterThan(tester.getBottomLeft(find.text('Nightly build')).dy),
);
// Input and Output are sticky collapsibles on both hosts.
expect(
find.byKey(const ValueKey('run-detail-summary-input')),
findsOneWidget,
);
if (platform == AppPlatform.cupertino) {
expect(find.byType(Material), findsNothing);
expect(find.byType(Chip), findsNothing);
}
testWidgets('detail at 390 with 2x text', (tester) async {
gateway.detail = runFixture(steps: 12);
await controller.select(1);
await pumpDetail(tester, controller, gateway, size: const Size(390, 1200));
expect(tester.takeException(), isNull);
expect(find.text('Nightly build'), findsOneWidget);
expect(find.textContaining('Original prompt'), findsNothing);
// The title is the top bar's; the status kicker leads the body below
// it, and the body does not repeat the title.
expect(find.byKey(const Key('run-status-kicker')), findsOneWidget);
expect(
tester.getTopLeft(find.byKey(const Key('run-status-kicker'))).dy,
greaterThan(tester.getBottomLeft(find.text('Nightly build')).dy),
);
// Input and Output are sticky collapsibles.
expect(
find.byKey(const ValueKey('run-detail-summary-input')),
findsOneWidget,
);
Future<void> tapTab(String label) async {
final tab = find.byKey(
ValueKey('run-detail-tab-${label.toLowerCase()}'),
);
await tester.ensureVisible(tab);
await tester.pumpAndSettle();
await tester.tap(tab);
await tester.pumpAndSettle();
}
Future<void> tapTab(String label) async {
final tab = find.byKey(ValueKey('run-detail-tab-${label.toLowerCase()}'));
await tester.ensureVisible(tab);
await tester.pumpAndSettle();
await tester.tap(tab);
await tester.pumpAndSettle();
}
Future<void> openSummarySection(String label) async {
final summaryScroll = find.descendant(
of: find.byKey(const Key('run-detail-tab-body-summary')),
matching: find.byType(Scrollable),
);
await tester.scrollUntilVisible(
find.text(label),
200,
scrollable: summaryScroll.first,
);
await tester.pumpAndSettle();
await tester.tap(find.text(label));
await tester.pumpAndSettle();
}
await openSummarySection('Input');
// Each field reads under its own name as data, never as JSON.
expect(find.text('nested'), findsOneWidget);
expect(find.text('alpha=1, items=1, 2'), findsOneWidget);
expect(find.textContaining('"alpha"'), findsNothing);
await openSummarySection('Output');
expect(find.text('ok=true'), findsOneWidget);
await tapTab('Timeline');
final timelineScroll = find.descendant(
of: find.byKey(const Key('run-detail-tab-body-timeline')),
Future<void> openSummarySection(String label) async {
final summaryScroll = find.descendant(
of: find.byKey(const Key('run-detail-tab-body-summary')),
matching: find.byType(Scrollable),
);
await tester.scrollUntilVisible(
find.textContaining('build · Visit 1').last,
find.text(label),
200,
scrollable: timelineScroll,
scrollable: summaryScroll.first,
);
expect(find.textContaining('build · Visit 1').last, findsOneWidget);
await tester.scrollUntilVisible(
find.textContaining('test · Visit 1').last,
200,
scrollable: timelineScroll,
);
expect(find.textContaining('test · Visit 1').last, findsOneWidget);
final before = tester
.state<ScrollableState>(timelineScroll)
.position
.pixels;
expect(before, greaterThan(0));
gateway.detail = runFixture(steps: 13);
await controller.select(1);
await tester.pumpAndSettle();
expect(
tester.state<ScrollableState>(timelineScroll).position.pixels,
closeTo(before, 0.1),
);
});
testWidgets('${platform.name} loading and error stay honest', (
tester,
) async {
gateway.hold = Completer<JsonMap>();
final pending = controller.select(1);
await pumpDetail(tester, platform, controller, gateway, settle: false);
expect(find.text('Loading run details…'), findsOneWidget);
expect(
find.byType(
platform == AppPlatform.material
? CircularProgressIndicator
: CupertinoActivityIndicator,
),
findsOneWidget,
);
gateway.hold!.complete({'run_detail': runFixture()});
await pending;
await tester.tap(find.text(label));
await tester.pumpAndSettle();
expect(find.text('Nightly build'), findsOneWidget);
}
controller.dispose();
gateway = FakeGateway(runFixture())
..failure = StateError('server unavailable');
controller = RunsController(RunsRepository(gateway));
await controller.select(1);
var backs = 0;
await pumpDetail(
tester,
platform,
controller,
gateway,
onBack: () => backs++,
);
expect(find.textContaining('server unavailable'), findsOneWidget);
await tester.tap(find.text('Back to list'));
expect(backs, 1);
});
}
await openSummarySection('Input');
// Each field reads under its own name as data, never as JSON.
expect(find.text('nested'), findsOneWidget);
expect(find.text('alpha=1, items=1, 2'), findsOneWidget);
expect(find.textContaining('"alpha"'), findsNothing);
await openSummarySection('Output');
expect(find.text('ok=true'), findsOneWidget);
await tapTab('Timeline');
final timelineScroll = find.descendant(
of: find.byKey(const Key('run-detail-tab-body-timeline')),
matching: find.byType(Scrollable),
);
await tester.scrollUntilVisible(
find.textContaining('build · Visit 1').last,
200,
scrollable: timelineScroll,
);
expect(find.textContaining('build · Visit 1').last, findsOneWidget);
await tester.scrollUntilVisible(
find.textContaining('test · Visit 1').last,
200,
scrollable: timelineScroll,
);
expect(find.textContaining('test · Visit 1').last, findsOneWidget);
final before = tester
.state<ScrollableState>(timelineScroll)
.position
.pixels;
expect(before, greaterThan(0));
gateway.detail = runFixture(steps: 13);
await controller.select(1);
await tester.pumpAndSettle();
expect(
tester.state<ScrollableState>(timelineScroll).position.pixels,
closeTo(before, 0.1),
);
});
testWidgets('loading and error stay honest', (tester) async {
gateway.hold = Completer<JsonMap>();
final pending = controller.select(1);
await pumpDetail(tester, controller, gateway, settle: false);
expect(find.text('Loading run details…'), findsOneWidget);
expect(find.byType(CircularProgressIndicator), findsOneWidget);
gateway.hold!.complete({'run_detail': runFixture()});
await pending;
await tester.pumpAndSettle();
expect(find.text('Nightly build'), findsOneWidget);
controller.dispose();
gateway = FakeGateway(runFixture())
..failure = StateError('server unavailable');
controller = RunsController(RunsRepository(gateway));
await controller.select(1);
var backs = 0;
await pumpDetail(tester, controller, gateway, onBack: () => backs++);
expect(find.textContaining('server unavailable'), findsOneWidget);
await tester.tap(find.text('Back to list'));
expect(backs, 1);
});
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'run_detail_finders.dart';
@@ -77,13 +76,7 @@ Future<ValueNotifier<RunSearchSelection?>> pumpLiveSelection(
),
);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pumpWidget(
platform == RunDetailTestPlatform.material
? MaterialApp(home: Scaffold(body: page))
: CupertinoApp(
home: CupertinoPageScaffold(child: SafeArea(child: page)),
),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: page)));
await tester.pumpAndSettle();
return pending;
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_content.dart';
@@ -27,75 +26,61 @@ final _steps = [
];
void main() {
for (final cupertino in [false, true]) {
testWidgets('timeline rows lead with their real status '
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
final list = RunTimelineList(
visits: detailTimeline(_steps),
cupertino: cupertino,
onSelected: (_) {},
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: list))
: MaterialApp(home: Scaffold(body: list)),
);
testWidgets('timeline rows lead with their real status', (tester) async {
final list = RunTimelineList(
visits: detailTimeline(_steps),
cupertino: false,
onSelected: (_) {},
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: list)));
// No placeholder circles: every row has the state's own glyph.
expect(find.byIcon(Icons.circle_outlined), findsNothing);
expect(find.byIcon(CupertinoIcons.circle), findsNothing);
final states = tester
.widgetList<RunStatusIcon>(find.byType(RunStatusIcon))
.map((icon) => icon.state)
.toList();
// A completed step whose outcome is an error reads as failed.
expect(states, ['succeeded', 'failed', 'running']);
// No placeholder circles: every row has the state's own glyph.
expect(find.byIcon(Icons.circle_outlined), findsNothing);
final states = tester
.widgetList<RunStatusIcon>(find.byType(RunStatusIcon))
.map((icon) => icon.state)
.toList();
// A completed step whose outcome is an error reads as failed.
expect(states, ['succeeded', 'failed', 'running']);
expect(find.text('success'), findsOneWidget);
expect(find.text('error'), 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);
});
}
expect(find.text('success'), findsOneWidget);
expect(find.text('error'), 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.
expect(find.byType(AppListRow), findsNWidgets(3));
});
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')));
});
}
testWidgets('outcome chips are coloured by name, not by status', (
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: false,
);
await tester.pumpWidget(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')));
});
}
@@ -1,6 +1,5 @@
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';
@@ -36,7 +35,7 @@ void main() {
await gateway.framesController.close();
});
Future<void> mount(WidgetTester tester, {required bool cupertino}) async {
Future<void> mount(WidgetTester tester) async {
gateway.reply = {
'runs': [
{
@@ -62,11 +61,7 @@ void main() {
builder: (context, _) =>
RunsList(controller: controller, onSelected: (_) {}),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: list))
: MaterialApp(home: Scaffold(body: list)),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: list)));
await tester.pumpAndSettle();
}
@@ -95,7 +90,7 @@ void main() {
testWidgets(
'material: filter and sort are icons; the filter sheet holds the search',
(tester) async {
await mount(tester, cupertino: false);
await mount(tester);
expect(find.byType(TextField), findsNothing);
expect(find.byKey(const ValueKey('runs.filter')), findsOneWidget);
expect(find.byKey(const ValueKey('runs.sort')), findsOneWidget);
@@ -148,7 +143,7 @@ void main() {
testWidgets(
'the filter sheet filters and its chip clears the facet',
(tester) async {
await mount(tester, cupertino: false);
await mount(tester);
await tester.tap(find.byKey(const ValueKey('runs.filter')));
await tester.pumpAndSettle();
expect(find.byType(TextField), findsOneWidget);
@@ -176,7 +171,7 @@ void main() {
testWidgets('the stats page shows usage, status pie and runs per day', (
tester,
) async {
await mount(tester, cupertino: false);
await mount(tester);
await tester.tap(find.byKey(const ValueKey('runs.stats')));
await tester.pumpAndSettle();
expect(find.byKey(const ValueKey('runs.stats.page')), findsOneWidget);