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:
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../changes/changes.dart';
|
||||
|
||||
/// The run detail's action and page label. The viewer itself owns the
|
||||
@@ -46,23 +44,6 @@ class RunChangesButton extends StatelessWidget {
|
||||
// failed run still keeps each visit's own recorded capture.
|
||||
final summary = showRunChangesSummary(run['status']);
|
||||
void open() => showRunChanges(context, steps: steps, showSummary: summary);
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoButton.tinted(
|
||||
key: runChangesButtonKey,
|
||||
onPressed: open,
|
||||
// The label keeps its intrinsic size until scaled text no longer fits
|
||||
// the detail's narrowest pane; then it wraps inside the native button
|
||||
// instead of overflowing the header row.
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(CupertinoIcons.doc_text),
|
||||
SizedBox(width: 6),
|
||||
Flexible(child: Text(runChangesLabel)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return OutlinedButton.icon(
|
||||
key: runChangesButtonKey,
|
||||
onPressed: open,
|
||||
@@ -85,23 +66,14 @@ Future<void> showRunChanges(
|
||||
required bool showSummary,
|
||||
String title = runChangesLabel,
|
||||
}) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return Navigator.of(context).push<void>(
|
||||
cupertino
|
||||
? CupertinoPageRoute<void>(
|
||||
builder: (_) => _CupertinoChangesPage(
|
||||
steps: steps,
|
||||
showSummary: showSummary,
|
||||
title: title,
|
||||
),
|
||||
)
|
||||
: MaterialPageRoute<void>(
|
||||
builder: (_) => _MaterialChangesPage(
|
||||
steps: steps,
|
||||
showSummary: showSummary,
|
||||
title: title,
|
||||
),
|
||||
),
|
||||
MaterialPageRoute<void>(
|
||||
builder: (_) => _MaterialChangesPage(
|
||||
steps: steps,
|
||||
showSummary: showSummary,
|
||||
title: title,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -149,21 +121,6 @@ class RunVisitChangesButton extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
void open() =>
|
||||
showVisitChanges(context, stage: stage, sequence: sequence, step: step);
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoButton(
|
||||
key: runVisitChangesButtonKey,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: open,
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(CupertinoIcons.doc_text),
|
||||
SizedBox(width: 6),
|
||||
Flexible(child: Text(runChangesLabel)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return TextButton.icon(
|
||||
key: runVisitChangesButtonKey,
|
||||
onPressed: open,
|
||||
@@ -191,26 +148,3 @@ class _MaterialChangesPage extends StatelessWidget {
|
||||
body: ChangesViewer(steps: steps, showSummary: showSummary),
|
||||
);
|
||||
}
|
||||
|
||||
class _CupertinoChangesPage extends StatelessWidget {
|
||||
const _CupertinoChangesPage({
|
||||
required this.steps,
|
||||
required this.showSummary,
|
||||
required this.title,
|
||||
});
|
||||
|
||||
final List<JsonMap> steps;
|
||||
final bool showSummary;
|
||||
final String title;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => CupertinoPageScaffold(
|
||||
navigationBar: SegmentedBar(cupertino: true, title: title),
|
||||
child: Theme(
|
||||
// A CupertinoApp supplies no Material theme; follow the host brightness
|
||||
// so the viewer's Material-derived section text stays readable.
|
||||
data: hostTextTheme(context),
|
||||
child: ChangesViewer(steps: steps, showSummary: showSummary),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/cupertino.dart' show CupertinoColors;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../actions/decision_action.dart';
|
||||
import '../actions/decision_wording.dart';
|
||||
import '../domain/run_decisions.dart';
|
||||
@@ -26,25 +25,16 @@ class RunDecisionNotice extends StatelessWidget {
|
||||
// One full-width line of the header strip: the glyph in the waiting
|
||||
// colour, the title over its meta line, and the action on the trailing
|
||||
// edge. The strip is already the frame, so the banner draws no card,
|
||||
// border or tint of its own. The same banner on both hosts.
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
// border or tint of its own.
|
||||
final color = CupertinoColors.systemTeal.resolveFrom(context);
|
||||
final metaStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Theme.of(context).textTheme.bodySmall;
|
||||
final metaStyle = Theme.of(context).textTheme.bodySmall;
|
||||
return Container(
|
||||
key: const Key('run-decision-banner'),
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
cupertino ? CupertinoIcons.clock : Icons.schedule,
|
||||
color: color,
|
||||
size: 18,
|
||||
),
|
||||
Icon(Icons.schedule, color: color, size: 18),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
|
||||
@@ -35,8 +35,8 @@ class RunDetailActions extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Every run action uses one native style, as the web's `.run-action`:
|
||||
// outlined on Material, tinted on Cupertino; Cancel alone is tinted
|
||||
// destructive. Standard native spacing keeps adjacent buttons distinct.
|
||||
// outlined, with Cancel alone tinted destructive. Standard native spacing
|
||||
// keeps adjacent buttons distinct.
|
||||
// Only actions that render are included: a hidden zero-size child still
|
||||
// consumes Wrap spacing and would double the visible gap.
|
||||
Wrap(
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/status/run_status_icon.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import 'run_detail_tabs.dart';
|
||||
|
||||
/// The runs detail with standard Cupertino controls. It has no Material
|
||||
/// ancestor: the top bar carries the run's identity, Back and the more menu;
|
||||
/// this header keeps the status in its colour beside the run actions, and the
|
||||
/// notices. The shared tab body uses native Cupertino expansion tiles and
|
||||
/// grouped list sections. Copy feedback is an inline live-region status.
|
||||
Widget buildCupertinoRunDetail({
|
||||
required BuildContext context,
|
||||
required JsonMap run,
|
||||
required Widget headerActions,
|
||||
required bool detailLoading,
|
||||
required String? error,
|
||||
required bool copying,
|
||||
required String? copyStatus,
|
||||
required VoidCallback onCopy,
|
||||
required ApiGateway gateway,
|
||||
required ValueChanged<JsonMap> onRunChanged,
|
||||
required String configuredEndpoint,
|
||||
String? initialStageKey,
|
||||
int? initialVisit,
|
||||
}) {
|
||||
return RunDetailTabs(
|
||||
run: run,
|
||||
cupertino: true,
|
||||
copying: copying,
|
||||
copyStatus: copyStatus,
|
||||
onCopy: onCopy,
|
||||
gateway: gateway,
|
||||
onRunChanged: onRunChanged,
|
||||
configuredEndpoint: configuredEndpoint,
|
||||
initialStageKey: initialStageKey,
|
||||
initialVisit: initialVisit,
|
||||
// A glass strip under the top bar: as wide as its content.
|
||||
header: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(12, 4, 12, 4),
|
||||
child: Wrap(
|
||||
spacing: 12,
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
RunStatusKicker(
|
||||
state: runStateOf(run['status']),
|
||||
label: runStatusLabel(run),
|
||||
),
|
||||
if (copying) const CupertinoActivityIndicator(),
|
||||
headerActions,
|
||||
],
|
||||
),
|
||||
),
|
||||
if (detailLoading) const _CupertinoNotice('Refreshing run details…'),
|
||||
if (error != null) _CupertinoNotice(error),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class _CupertinoNotice extends StatelessWidget {
|
||||
const _CupertinoNotice(this.text);
|
||||
final String text;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(12, 0, 12, 8),
|
||||
child: Semantics(liveRegion: true, child: Text(text)),
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
@@ -6,7 +5,6 @@ import '../../../core/api_gateway.dart';
|
||||
import 'run_detail_summary_fields.dart';
|
||||
import 'run_detail_visit_facts.dart';
|
||||
import 'run_field_body.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/layout/facts_grid.dart';
|
||||
import '../../../ui/layout/warnings_section.dart';
|
||||
import '../../../ui/layout/sticky_section.dart';
|
||||
@@ -53,17 +51,15 @@ Widget runDetailSummaryTab({
|
||||
const SliverTopBarClearance(),
|
||||
if (graphPreview != null) SliverToBoxAdapter(child: graphPreview),
|
||||
SliverToBoxAdapter(
|
||||
child: cupertino
|
||||
? _cupertinoIdentity(context, identity)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: Text(
|
||||
identity,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: Text(
|
||||
identity,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: WarningsSection(messages: warningMessages(run['warnings'])),
|
||||
@@ -98,9 +94,7 @@ Widget runDetailSummaryTab({
|
||||
_StickyField(
|
||||
key: ValueKey('run-detail-summary-${_slug(row.label)}'),
|
||||
title: row.label,
|
||||
body: cupertino
|
||||
? _cupertinoBlock(context, row)
|
||||
: _materialBlock(context, row),
|
||||
body: _materialBlock(context, row),
|
||||
),
|
||||
_StickyField(
|
||||
key: const ValueKey('run-detail-summary-input'),
|
||||
@@ -110,8 +104,7 @@ Widget runDetailSummaryTab({
|
||||
body: RunFieldBody(
|
||||
value: run['input'],
|
||||
empty: visitEmptyInput,
|
||||
cupertino: cupertino,
|
||||
textBuilder: cupertino ? _CupertinoSelectableText.new : null,
|
||||
cupertino: false,
|
||||
),
|
||||
),
|
||||
_StickyField(
|
||||
@@ -122,8 +115,7 @@ Widget runDetailSummaryTab({
|
||||
body: RunFieldBody(
|
||||
value: run['output'],
|
||||
empty: visitEmptyOutput,
|
||||
cupertino: cupertino,
|
||||
textBuilder: cupertino ? _CupertinoSelectableText.new : null,
|
||||
cupertino: false,
|
||||
),
|
||||
),
|
||||
const SliverToBoxAdapter(child: SizedBox(height: 16)),
|
||||
@@ -172,7 +164,6 @@ class _StickyFieldState extends State<_StickyField> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final copyText = widget.copyText;
|
||||
return ListenableBuilder(
|
||||
listenable: _controller,
|
||||
@@ -184,22 +175,11 @@ class _StickyFieldState extends State<_StickyField> {
|
||||
: _controller.expand(),
|
||||
trailing: [
|
||||
if (copyText != null && copyText.isNotEmpty)
|
||||
cupertino
|
||||
? CupertinoButton(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
onPressed: _copy,
|
||||
child: Icon(
|
||||
_copied
|
||||
? CupertinoIcons.checkmark_alt
|
||||
: CupertinoIcons.doc_on_doc,
|
||||
semanticLabel: 'Copy ${widget.title}',
|
||||
),
|
||||
)
|
||||
: IconButton(
|
||||
tooltip: 'Copy ${widget.title}',
|
||||
onPressed: _copy,
|
||||
icon: Icon(_copied ? Icons.check : Icons.copy),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: 'Copy ${widget.title}',
|
||||
onPressed: _copy,
|
||||
icon: Icon(_copied ? Icons.check : Icons.copy),
|
||||
),
|
||||
],
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||
@@ -218,12 +198,7 @@ Widget runDetailFieldTab({
|
||||
required bool cupertino,
|
||||
}) {
|
||||
// The recorded fields by name, as values, never raw JSON.
|
||||
final body = RunFieldBody(
|
||||
value: value,
|
||||
empty: empty,
|
||||
cupertino: cupertino,
|
||||
textBuilder: cupertino ? _CupertinoSelectableText.new : null,
|
||||
);
|
||||
final body = RunFieldBody(value: value, empty: empty, cupertino: false);
|
||||
// Flat on the page on both hosts, like the Summary.
|
||||
return Builder(
|
||||
builder: (context) => ListView(
|
||||
@@ -255,75 +230,4 @@ Widget _materialBlock(BuildContext context, DetailSummaryRow row) {
|
||||
);
|
||||
}
|
||||
|
||||
// --- Cupertino -------------------------------------------------------------
|
||||
|
||||
Widget _cupertinoIdentity(BuildContext context, String identity) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 8),
|
||||
child: Text(
|
||||
identity,
|
||||
style: theme.textTheme.tabLabelTextStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// A long recorded block (the Diagnostic) starts collapsed under its label.
|
||||
Widget _cupertinoBlock(BuildContext context, DetailSummaryRow row) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.tertiarySystemFill.resolveFrom(context),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Text(
|
||||
row.value,
|
||||
style: theme.textTheme.textStyle.copyWith(fontFamily: appMonospaceFamily),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _slug(String label) => label.toLowerCase().replaceAll(' ', '-');
|
||||
|
||||
/// A read-only Cupertino text control: plain, selectable text without a
|
||||
/// Material dependency, while keeping native selection and copy affordances.
|
||||
class _CupertinoSelectableText extends StatefulWidget {
|
||||
const _CupertinoSelectableText(this.text);
|
||||
final String text;
|
||||
|
||||
@override
|
||||
State<_CupertinoSelectableText> createState() =>
|
||||
_CupertinoSelectableTextState();
|
||||
}
|
||||
|
||||
class _CupertinoSelectableTextState extends State<_CupertinoSelectableText> {
|
||||
late final TextEditingController _controller = TextEditingController(
|
||||
text: widget.text,
|
||||
);
|
||||
|
||||
@override
|
||||
void didUpdateWidget(_CupertinoSelectableText oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.text != oldWidget.text) _controller.text = widget.text;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => CupertinoTextField(
|
||||
controller: _controller,
|
||||
readOnly: true,
|
||||
maxLines: null,
|
||||
padding: EdgeInsets.zero,
|
||||
decoration: const BoxDecoration(),
|
||||
style: CupertinoTheme.of(context).textTheme.textStyle,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/floating_destination_bar.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import 'run_detail_tab.dart';
|
||||
|
||||
/// The tabs the strip renders, in the web's order: Summary first so it is the
|
||||
@@ -43,12 +42,11 @@ class RunDetailTabStrip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final index = tabs.indexOf(selected);
|
||||
return KeyedSubtree(
|
||||
key: const Key('run-detail-tabs'),
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
currentIndex: index < 0 ? 0 : index,
|
||||
edge: edge,
|
||||
onTap: (value) => onSelected(tabs[value]),
|
||||
@@ -56,7 +54,7 @@ class RunDetailTabStrip extends StatelessWidget {
|
||||
for (final tab in tabs)
|
||||
FloatingDestinationItem(
|
||||
key: ValueKey('run-detail-tab-${tab.name}'),
|
||||
icon: Icon(cupertino ? tab.cupertinoIcon : tab.icon),
|
||||
icon: Icon(tab.icon),
|
||||
label: tab.label,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -6,7 +6,6 @@ import '../../../ui/adaptive/top_glass_strip.dart';
|
||||
import '../../../ui/motion/fade_through_stack.dart';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
@@ -271,24 +270,8 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
}
|
||||
|
||||
void _showSearchArtifactMissingNotice() {
|
||||
final messenger = ScaffoldMessenger.maybeOf(context);
|
||||
if (messenger != null) {
|
||||
messenger.showSnackBar(
|
||||
const SnackBar(content: Text('That artifact is no longer available.')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
showCupertinoDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoAlertDialog(
|
||||
content: const Text('That artifact is no longer available.'),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
ScaffoldMessenger.maybeOf(context)?.showSnackBar(
|
||||
const SnackBar(content: Text('That artifact is no longer available.')),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -331,7 +314,6 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
/// a visit still running keeps updating; leaving it returns to the timeline.
|
||||
Future<void> _pushVisit(int index) async {
|
||||
_shownVisit = index;
|
||||
final cupertino = widget.cupertino;
|
||||
Widget page(BuildContext pageContext) => ValueListenableBuilder<JsonMap>(
|
||||
valueListenable: _liveRun,
|
||||
builder: (context, run, _) {
|
||||
@@ -347,7 +329,7 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.onRunChanged,
|
||||
configuredEndpoint: widget.configuredEndpoint,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onClose: () => Navigator.of(pageContext).pop(),
|
||||
)
|
||||
: const Center(child: Text('This visit is no longer recorded.'));
|
||||
@@ -355,10 +337,10 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
// repeats neither; the sections scroll behind it.
|
||||
final known = index < visits.length;
|
||||
final bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
leading: SegmentedBackButton(
|
||||
key: const Key('run-visit-back'),
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onPressed: () => Navigator.of(pageContext).pop(),
|
||||
),
|
||||
title: known ? visits[index].stage : detailTitle(run),
|
||||
@@ -366,15 +348,10 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
subtitle: known ? runVisitSubtitle(run, visits[index]) : null,
|
||||
);
|
||||
final body = SafeArea(top: false, bottom: false, child: pane);
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(navigationBar: bar, child: body);
|
||||
}
|
||||
return Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: body);
|
||||
},
|
||||
);
|
||||
final route = cupertino
|
||||
? CupertinoPageRoute<void>(builder: page)
|
||||
: MaterialPageRoute<void>(builder: page);
|
||||
final route = MaterialPageRoute<void>(builder: page);
|
||||
_visitRoute = route;
|
||||
await Navigator.of(context).push<void>(route);
|
||||
// Only the page the operator left clears the selection; one replaced by
|
||||
@@ -441,7 +418,7 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
return FloatingBarOverlay(
|
||||
edge: FloatingBarEdge.top,
|
||||
bar: RunDetailWideChrome(
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
tabs: tabStrip,
|
||||
header: header,
|
||||
),
|
||||
@@ -460,7 +437,7 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
edge: FloatingBarEdge.top,
|
||||
bar: TopGlassStrip(
|
||||
key: const Key('run-detail-header'),
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: header,
|
||||
),
|
||||
@@ -476,7 +453,7 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
return runDetailSummaryTab(
|
||||
context: context,
|
||||
run: widget.run,
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
copying: widget.copying,
|
||||
copyStatus: widget.copyStatus,
|
||||
onCopy: widget.onCopy,
|
||||
@@ -505,14 +482,14 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
tabKey: 'input',
|
||||
value: widget.run['input'],
|
||||
empty: 'No input recorded.',
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
);
|
||||
case RunDetailTab.output:
|
||||
return runDetailFieldTab(
|
||||
tabKey: 'output',
|
||||
value: widget.run['output'],
|
||||
empty: 'No output recorded.',
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
);
|
||||
case RunDetailTab.artifacts:
|
||||
return ArtifactGalleryPage(
|
||||
@@ -533,14 +510,8 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
showSummary: true,
|
||||
finalOnly: true,
|
||||
);
|
||||
// A CupertinoApp supplies no Material theme; follow the host so the
|
||||
// viewer's section text stays readable. Its summary heads the tab, so
|
||||
// the tab starts below a pane's top tabs.
|
||||
return BelowTopBar(
|
||||
child: widget.cupertino
|
||||
? Theme(data: hostTextTheme(context), child: viewer)
|
||||
: viewer,
|
||||
);
|
||||
// Its summary heads the tab, so the tab starts below a pane's top tabs.
|
||||
return BelowTopBar(child: viewer);
|
||||
case RunDetailTab.timeline:
|
||||
final visits = detailTimeline(widget.run['steps']);
|
||||
final index = _selectedVisit;
|
||||
@@ -549,7 +520,7 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
|
||||
selectedSequence: index != null && index >= 0 && index < visits.length
|
||||
? visits[index].sequence
|
||||
: null,
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
onSelected: _openVisit,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class RunTimelineList extends StatelessWidget {
|
||||
),
|
||||
visit: visits[index],
|
||||
selected: visits[index].sequence == selectedSequence,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
divider: index < visits.length - 1,
|
||||
palette: palette,
|
||||
onTap: onSelected == null ? null : () => onSelected!(index),
|
||||
@@ -140,7 +140,7 @@ class RunTimelineRow extends StatelessWidget {
|
||||
// The outcome chip leads the second line, then where the visit went and
|
||||
// the tokens it reported; the duration is the row's time.
|
||||
return AppListRow(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
selected: selected,
|
||||
divider: divider,
|
||||
onTap: onTap,
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import '../../../core/servers/server_context.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../core/transport/pipelines_client.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../shell/shell_bar.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/adaptive/segmented_bar_overlay.dart';
|
||||
@@ -13,7 +11,6 @@ import 'run_detail_actions.dart';
|
||||
import 'run_more_menu.dart';
|
||||
import 'run_pipeline_link.dart';
|
||||
import 'run_detail_content.dart';
|
||||
import 'run_detail_cupertino.dart';
|
||||
import 'run_detail_material.dart';
|
||||
import 'runs_controller.dart';
|
||||
|
||||
@@ -60,9 +57,8 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
Widget build(BuildContext context) => AnimatedBuilder(
|
||||
animation: widget.controller,
|
||||
builder: (context, _) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final run = widget.controller.detail;
|
||||
if (run == null) return _placeholder(context, cupertino: cupertino);
|
||||
if (run == null) return _placeholder(context);
|
||||
final prompt = detailPrompt(run);
|
||||
final endpoint = configuredGatewayEndpoint(widget.gateway);
|
||||
final headerActions = RunDetailActions(
|
||||
@@ -73,37 +69,21 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
retry: false,
|
||||
);
|
||||
final inShellBar = ShellBar.available(context);
|
||||
final detail = cupertino
|
||||
? buildCupertinoRunDetail(
|
||||
context: context,
|
||||
run: run,
|
||||
headerActions: headerActions,
|
||||
detailLoading: widget.controller.detailLoading,
|
||||
error: widget.controller.error,
|
||||
copying: _copying,
|
||||
copyStatus: _copyStatus,
|
||||
onCopy: () => _copyPrompt(prompt ?? '', cupertino: true),
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.controller.acceptRunDetail,
|
||||
configuredEndpoint: endpoint,
|
||||
initialStageKey: widget.initialStageKey,
|
||||
initialVisit: widget.initialVisit,
|
||||
)
|
||||
: buildMaterialRunDetail(
|
||||
context: context,
|
||||
run: run,
|
||||
headerActions: headerActions,
|
||||
detailLoading: widget.controller.detailLoading,
|
||||
error: widget.controller.error,
|
||||
copying: _copying,
|
||||
copyStatus: _copyStatus,
|
||||
onCopy: () => _copyPrompt(prompt ?? '', cupertino: false),
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.controller.acceptRunDetail,
|
||||
configuredEndpoint: endpoint,
|
||||
initialStageKey: widget.initialStageKey,
|
||||
initialVisit: widget.initialVisit,
|
||||
);
|
||||
final detail = buildMaterialRunDetail(
|
||||
context: context,
|
||||
run: run,
|
||||
headerActions: headerActions,
|
||||
detailLoading: widget.controller.detailLoading,
|
||||
error: widget.controller.error,
|
||||
copying: _copying,
|
||||
copyStatus: _copyStatus,
|
||||
onCopy: () => _copyPrompt(prompt ?? ''),
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.controller.acceptRunDetail,
|
||||
configuredEndpoint: endpoint,
|
||||
initialStageKey: widget.initialStageKey,
|
||||
initialVisit: widget.initialVisit,
|
||||
);
|
||||
// The top bar becomes the run's: Back to the list, its title over its
|
||||
// number, pipeline and version (a link to that pipeline when the host
|
||||
// can open it) and its more menu, so the body repeats none of them.
|
||||
@@ -114,37 +94,25 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
final pipelineName = detailPipeline(run);
|
||||
final pipelineAction = openPipeline == null
|
||||
? null
|
||||
: (cupertino
|
||||
? Semantics(
|
||||
button: true,
|
||||
label: 'Open pipeline $pipelineName',
|
||||
child: CupertinoButton(
|
||||
key: runPipelineLinkKey,
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: Size.zero,
|
||||
onPressed: openPipeline,
|
||||
child: const Icon(CupertinoIcons.arrow_branch),
|
||||
),
|
||||
)
|
||||
: Semantics(
|
||||
button: true,
|
||||
label: 'Open pipeline $pipelineName',
|
||||
excludeSemantics: true,
|
||||
child: GestureDetector(
|
||||
key: runPipelineLinkKey,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: openPipeline,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(12),
|
||||
child: Icon(Icons.account_tree_outlined),
|
||||
),
|
||||
),
|
||||
));
|
||||
: Semantics(
|
||||
button: true,
|
||||
label: 'Open pipeline $pipelineName',
|
||||
excludeSemantics: true,
|
||||
child: GestureDetector(
|
||||
key: runPipelineLinkKey,
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: openPipeline,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(12),
|
||||
child: Icon(Icons.account_tree_outlined),
|
||||
),
|
||||
),
|
||||
);
|
||||
final more = RunMoreMenu(
|
||||
run: run,
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.controller.acceptRunDetail,
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onRunOpened: widget.onRunOpened,
|
||||
onDeleted: widget.controller.applyDeletion,
|
||||
);
|
||||
@@ -164,10 +132,10 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
// On its own the run draws the same bar over its content.
|
||||
return SegmentedBarOverlay(
|
||||
bar: SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
leading: SegmentedBackButton(
|
||||
key: const Key('run-detail-back'),
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
onPressed: widget.onBack,
|
||||
),
|
||||
title: title,
|
||||
@@ -193,7 +161,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
return () => open(id, version is num ? version.toInt() : 0);
|
||||
}
|
||||
|
||||
Widget _placeholder(BuildContext context, {required bool cupertino}) {
|
||||
Widget _placeholder(BuildContext context) {
|
||||
final loading = widget.controller.detailLoading;
|
||||
final message = loading
|
||||
? 'Loading run details…'
|
||||
@@ -203,20 +171,17 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
return ShellBar(
|
||||
title: 'Run',
|
||||
onBack: widget.onBack,
|
||||
child: _placeholderBody(cupertino, loading, message),
|
||||
child: _placeholderBody(loading, message),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _placeholderBody(bool cupertino, bool loading, String message) {
|
||||
Widget _placeholderBody(bool loading, String message) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (loading) ...[
|
||||
if (cupertino)
|
||||
const CupertinoActivityIndicator()
|
||||
else
|
||||
const CircularProgressIndicator(),
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
Padding(
|
||||
@@ -224,16 +189,10 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
child: Text(message, textAlign: TextAlign.center),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
if (cupertino)
|
||||
CupertinoButton(
|
||||
onPressed: widget.onBack,
|
||||
child: const Text('Back to list'),
|
||||
)
|
||||
else
|
||||
FilledButton(
|
||||
onPressed: widget.onBack,
|
||||
child: const Text('Back to list'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: widget.onBack,
|
||||
child: const Text('Back to list'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -241,7 +200,7 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
|
||||
/// Copies the stored prompt byte-for-byte. A refusal is surfaced, never
|
||||
/// replaced by copying a title or the formatted detail.
|
||||
Future<void> _copyPrompt(String prompt, {required bool cupertino}) async {
|
||||
Future<void> _copyPrompt(String prompt) async {
|
||||
if (_copying) return;
|
||||
setState(() => _copying = true);
|
||||
String message;
|
||||
@@ -252,13 +211,12 @@ class _RunDetailViewState extends State<RunDetailView> {
|
||||
message = 'Could not copy prompt to clipboard.';
|
||||
}
|
||||
if (!mounted) return;
|
||||
final scaffold = cupertino ? null : Scaffold.maybeOf(context);
|
||||
final inline = cupertino || scaffold == null;
|
||||
final scaffold = Scaffold.maybeOf(context);
|
||||
setState(() {
|
||||
_copying = false;
|
||||
_copyStatus = inline ? message : null;
|
||||
_copyStatus = scaffold == null ? message : null;
|
||||
});
|
||||
if (!cupertino && scaffold != null) {
|
||||
if (scaffold != null) {
|
||||
ScaffoldMessenger.maybeOf(
|
||||
context,
|
||||
)?.showSnackBar(SnackBar(content: Text(message)));
|
||||
|
||||
@@ -88,7 +88,7 @@ class _RunVisitPaneState extends State<RunVisitPane> {
|
||||
gateway: widget.gateway,
|
||||
onRunChanged: widget.onRunChanged,
|
||||
configuredEndpoint: widget.configuredEndpoint,
|
||||
cupertino: widget.cupertino,
|
||||
cupertino: false,
|
||||
facts: RunVisitFactsView(step: widget.step),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../artifacts/domain/artifact_capture.dart';
|
||||
import '../../artifacts/domain/artifact_document.dart';
|
||||
import '../../artifacts/domain/artifact_groups.dart';
|
||||
@@ -83,11 +81,9 @@ class RunVisitDocuments extends StatelessWidget {
|
||||
selectedIdentity: artifactVisitIdentityOf(group, artifact),
|
||||
configuredEndpoint: configuredEndpoint,
|
||||
);
|
||||
Navigator.of(context).push<void>(
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoPageRoute<void>(builder: (_) => page)
|
||||
: MaterialPageRoute<void>(builder: (_) => page),
|
||||
);
|
||||
Navigator.of(
|
||||
context,
|
||||
).push<void>(MaterialPageRoute<void>(builder: (_) => page));
|
||||
}
|
||||
|
||||
return ArtifactDocumentSection(group: group, onSelected: select);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/status/run_status_icon.dart';
|
||||
import '../../graph/widgets/graph_stage_node.dart' show graphStatusState;
|
||||
import 'run_detail_visit_facts.dart';
|
||||
@@ -125,15 +123,6 @@ class _VisitStyle {
|
||||
});
|
||||
|
||||
factory _VisitStyle.of(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final secondary = CupertinoColors.secondaryLabel.resolveFrom(context);
|
||||
return _VisitStyle(
|
||||
value: theme.textTheme.textStyle,
|
||||
muted: theme.textTheme.textStyle.copyWith(color: secondary),
|
||||
heading: theme.textTheme.navTitleTextStyle,
|
||||
);
|
||||
}
|
||||
final theme = Theme.of(context);
|
||||
return _VisitStyle(
|
||||
value: theme.textTheme.bodyMedium ?? const TextStyle(),
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:ui' show SemanticsRole;
|
||||
|
||||
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_tabs.dart';
|
||||
@@ -15,12 +14,11 @@ import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
/// test key; the icons within a bar, and against the shell's tabs a detail's
|
||||
/// bar floats above, are distinct.
|
||||
void main() {
|
||||
Widget host(bool cupertino, Widget bar) {
|
||||
final body = Align(alignment: Alignment.bottomCenter, child: bar);
|
||||
return cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
||||
: MaterialApp(home: Scaffold(body: body));
|
||||
}
|
||||
Widget host(Widget bar) => MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Align(alignment: Alignment.bottomCenter, child: bar),
|
||||
),
|
||||
);
|
||||
|
||||
final bars = <String, (Widget, List<(String, String)>)>{
|
||||
'run detail': (
|
||||
@@ -52,82 +50,69 @@ void main() {
|
||||
),
|
||||
};
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final name = cupertino ? 'Cupertino' : 'Material';
|
||||
for (final MapEntry(key: label, value: (bar, tabs)) in bars.entries) {
|
||||
testWidgets('$name $label tabs are icons named for assistive '
|
||||
'technology', (tester) async {
|
||||
final semantics = tester.ensureSemantics();
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(host(cupertino, bar));
|
||||
await tester.pumpAndSettle();
|
||||
for (final MapEntry(key: label, value: (bar, tabs)) in bars.entries) {
|
||||
testWidgets('$label tabs are icons named for assistive '
|
||||
'technology', (tester) async {
|
||||
final semantics = tester.ensureSemantics();
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(host(bar));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final floating = find.byType(FloatingDestinationBar);
|
||||
// No label is drawn at all.
|
||||
final floating = find.byType(FloatingDestinationBar);
|
||||
// No label is drawn at all.
|
||||
expect(
|
||||
find.descendant(of: floating, matching: find.byType(Text)),
|
||||
findsNothing,
|
||||
);
|
||||
for (final (index, (key, tabLabel)) in tabs.indexed) {
|
||||
final finder = find.byKey(ValueKey(key));
|
||||
final node = tester.getSemantics(finder);
|
||||
expect(node.label, startsWith(tabLabel), reason: key);
|
||||
expect(
|
||||
find.descendant(of: floating, matching: find.byType(Text)),
|
||||
findsNothing,
|
||||
node,
|
||||
isSemantics(
|
||||
isSelected: index == 0,
|
||||
hasSelectedState: true,
|
||||
isButton: true,
|
||||
hasTapAction: true,
|
||||
),
|
||||
reason: key,
|
||||
);
|
||||
for (final (index, (key, tabLabel)) in tabs.indexed) {
|
||||
final finder = find.byKey(ValueKey(key));
|
||||
final node = tester.getSemantics(finder);
|
||||
expect(node.label, startsWith(tabLabel), reason: key);
|
||||
expect(
|
||||
node,
|
||||
isSemantics(
|
||||
isSelected: index == 0,
|
||||
hasSelectedState: true,
|
||||
isButton: true,
|
||||
hasTapAction: true,
|
||||
expect(node.role, SemanticsRole.tab, reason: key);
|
||||
// "Tab n of m", as the host navigation controls announce it.
|
||||
final position = 'Tab ${index + 1} of ${tabs.length}';
|
||||
expect(node.label, contains(position), reason: key);
|
||||
// Material names the tab in its tooltip too.
|
||||
expect(
|
||||
find.descendant(
|
||||
of: finder,
|
||||
matching: find.byWidgetPredicate(
|
||||
(widget) => widget is Tooltip && widget.message == tabLabel,
|
||||
),
|
||||
reason: key,
|
||||
);
|
||||
expect(node.role, SemanticsRole.tab, reason: key);
|
||||
// "Tab n of m", as the host navigation controls announce it: in the
|
||||
// Material label, the Cupertino hint.
|
||||
final position = 'Tab ${index + 1} of ${tabs.length}';
|
||||
expect(
|
||||
cupertino ? node.hint : node.label,
|
||||
contains(position),
|
||||
reason: key,
|
||||
);
|
||||
// Material names the tab in its tooltip too.
|
||||
if (!cupertino) {
|
||||
expect(
|
||||
find.descendant(
|
||||
of: finder,
|
||||
matching: find.byWidgetPredicate(
|
||||
(widget) => widget is Tooltip && widget.message == tabLabel,
|
||||
),
|
||||
),
|
||||
findsOneWidget,
|
||||
reason: key,
|
||||
);
|
||||
}
|
||||
// A hit target at least the platform minimum.
|
||||
expect(
|
||||
tester.getSize(finder).shortestSide,
|
||||
greaterThanOrEqualTo(cupertino ? 44 : 48),
|
||||
);
|
||||
}
|
||||
// The tabs make up one tab bar.
|
||||
final tabBar = tester.getSemantics(
|
||||
find.byKey(FloatingDestinationBar.rowKey),
|
||||
),
|
||||
findsOneWidget,
|
||||
reason: key,
|
||||
);
|
||||
expect(tabBar.role, SemanticsRole.tabBar);
|
||||
// Distinct glyphs within the bar.
|
||||
final icons = tester
|
||||
.widgetList<Icon>(
|
||||
find.descendant(of: floating, matching: find.byType(Icon)),
|
||||
)
|
||||
.map((icon) => icon.icon)
|
||||
.toSet();
|
||||
expect(icons.length, greaterThanOrEqualTo(tabs.length));
|
||||
semantics.dispose();
|
||||
});
|
||||
}
|
||||
// A hit target at least the platform minimum.
|
||||
expect(tester.getSize(finder).shortestSide, greaterThanOrEqualTo(48));
|
||||
}
|
||||
// The tabs make up one tab bar.
|
||||
final tabBar = tester.getSemantics(
|
||||
find.byKey(FloatingDestinationBar.rowKey),
|
||||
);
|
||||
expect(tabBar.role, SemanticsRole.tabBar);
|
||||
// Distinct glyphs within the bar.
|
||||
final icons = tester
|
||||
.widgetList<Icon>(
|
||||
find.descendant(of: floating, matching: find.byType(Icon)),
|
||||
)
|
||||
.map((icon) => icon.icon)
|
||||
.toSet();
|
||||
expect(icons.length, greaterThanOrEqualTo(tabs.length));
|
||||
semantics.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
test('detail tab icons differ from the shell tabs they float above', () {
|
||||
|
||||
Reference in New Issue
Block a user