merge(app): land changes-paging
This commit is contained in:
@@ -180,5 +180,6 @@ List<FileChange> filterFileChanges(Iterable<FileChange> files, String query) {
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
/// The `N of M` position label a viewer can show for its open file.
|
||||
/// The `N of M` position label a viewer can show for its open file or for the
|
||||
/// Changes visit on screen.
|
||||
String changePositionLabel(int index, int count) => '${index + 1} of $count';
|
||||
|
||||
@@ -8,11 +8,17 @@ import '../domain/run_changes.dart';
|
||||
import 'capture_section.dart';
|
||||
import 'change_style.dart';
|
||||
import 'file_diff_viewer.dart';
|
||||
import 'visit_pager.dart';
|
||||
|
||||
/// The run's Changes surface: an honest final-state summary followed by one
|
||||
/// section per stage/visit capture, with changed-filename filtering and the
|
||||
/// The run's Changes surface: an honest final-state summary followed by the
|
||||
/// recorded stage/visit captures, with changed-filename filtering and the
|
||||
/// reusable single-file diff viewer.
|
||||
///
|
||||
/// The run-wide header and filter always describe the whole run. Below them the
|
||||
/// viewer shows one recorded visit at a time and offers Previous/Next paging
|
||||
/// through the rest in run order, so a long run stays readable without changing
|
||||
/// the aggregate. The shown visit keeps its own stage/visit heading.
|
||||
///
|
||||
/// The viewer fills the available height, so give it a bounded parent (a
|
||||
/// Scaffold body, tab body or Expanded child). It never opens its own socket or
|
||||
/// requests data; the caller passes the run detail's `steps`.
|
||||
@@ -45,6 +51,10 @@ class _ChangesViewerState extends State<ChangesViewer> {
|
||||
late List<StageCapture> _captures;
|
||||
late RunChanges _run;
|
||||
|
||||
/// The zero-based position of the shown visit in [_captures] (run order).
|
||||
/// The page opens at the first recorded visit; Previous/Next never wrap.
|
||||
int _visitIndex = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -62,6 +72,19 @@ class _ChangesViewerState extends State<ChangesViewer> {
|
||||
void _derive() {
|
||||
_captures = stageCaptures(widget.steps);
|
||||
_run = runChangesFor(_captures);
|
||||
// A fresh reply may have fewer recorded visits; never point past the end.
|
||||
_visitIndex = _clampVisit(_visitIndex, _captures.length);
|
||||
}
|
||||
|
||||
static int _clampVisit(int index, int count) {
|
||||
if (count <= 0 || index < 0) return 0;
|
||||
return index >= count ? count - 1 : index;
|
||||
}
|
||||
|
||||
void _stepVisit(int delta) {
|
||||
final next = _clampVisit(_visitIndex + delta, _captures.length);
|
||||
if (next == _visitIndex) return;
|
||||
setState(() => _visitIndex = next);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -81,6 +104,7 @@ class _ChangesViewerState extends State<ChangesViewer> {
|
||||
(visit) => visit.capture?.files.isNotEmpty ?? false,
|
||||
);
|
||||
final note = showSummary ? runChangesNote(run) : '';
|
||||
final visit = captures.isEmpty ? null : captures[_visitIndex];
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
@@ -107,8 +131,8 @@ class _ChangesViewerState extends State<ChangesViewer> {
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(
|
||||
'The summary counts each path once, as the last recorded '
|
||||
'visit left it. Each stage/visit below lists what its own '
|
||||
'capture recorded.',
|
||||
'visit left it. Each stage/visit page below lists what '
|
||||
'its own capture recorded.',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
),
|
||||
@@ -122,27 +146,33 @@ class _ChangesViewerState extends State<ChangesViewer> {
|
||||
),
|
||||
if (showSummary) const Divider(height: 1),
|
||||
Expanded(
|
||||
child: captures.isEmpty
|
||||
child: visit == null
|
||||
? SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(noChangeDetail(run)),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: captures.length,
|
||||
itemBuilder: (context, index) {
|
||||
final visit = captures[index];
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
StageCaptureSection(
|
||||
stage: visit,
|
||||
query: _query,
|
||||
onOpen: (file) => showFileDiffViewer(context, file),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
],
|
||||
);
|
||||
},
|
||||
: SingleChildScrollView(
|
||||
// Keying the body by visit keeps each page's pager and heading
|
||||
// at the top instead of inheriting the previous scroll offset.
|
||||
key: ValueKey<String>(
|
||||
'changes-visit-${visit.stage}-${visit.sequence}',
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
ChangesVisitPager(
|
||||
index: _visitIndex,
|
||||
count: captures.length,
|
||||
onPrevious: () => _stepVisit(-1),
|
||||
onNext: () => _stepVisit(1),
|
||||
),
|
||||
StageCaptureSection(
|
||||
stage: visit,
|
||||
query: _query,
|
||||
onOpen: (file) => showFileDiffViewer(context, file),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../domain/change_wording.dart';
|
||||
import 'change_style.dart';
|
||||
|
||||
/// The Changes page's Previous/Next pager over the run's recorded stage visits.
|
||||
///
|
||||
/// It only moves between the captures the viewer already holds and never wraps:
|
||||
/// the first recorded visit has no previous page and the last none after it.
|
||||
/// The shown visit's own heading (its stage and visit number) stays with the
|
||||
/// capture section below, so paging never loses which visit is on screen.
|
||||
class ChangesVisitPager extends StatelessWidget {
|
||||
const ChangesVisitPager({
|
||||
super.key,
|
||||
required this.index,
|
||||
required this.count,
|
||||
required this.onPrevious,
|
||||
required this.onNext,
|
||||
});
|
||||
|
||||
static const previousKey = ValueKey<String>('changes-previous-visit');
|
||||
static const nextKey = ValueKey<String>('changes-next-visit');
|
||||
|
||||
/// The shown visit's zero-based position in the run's recorded visits.
|
||||
final int index;
|
||||
final int count;
|
||||
final VoidCallback onPrevious;
|
||||
final VoidCallback onNext;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (count <= 1) return const SizedBox.shrink();
|
||||
final hasPrevious = index > 0;
|
||||
final hasNext = index < count - 1;
|
||||
return Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(
|
||||
'${changePositionLabel(index, count)} recorded visits',
|
||||
key: const ValueKey<String>('changes-visit-position'),
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
// A `Wrap` keeps both controls whole and lets them take separate
|
||||
// lines at large text sizes or on a narrow page.
|
||||
Wrap(
|
||||
alignment: WrapAlignment.spaceBetween,
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
_button(
|
||||
context,
|
||||
key: previousKey,
|
||||
label: 'Previous visit',
|
||||
enabled: hasPrevious,
|
||||
onPressed: onPrevious,
|
||||
previous: true,
|
||||
),
|
||||
_button(
|
||||
context,
|
||||
key: nextKey,
|
||||
label: 'Next visit',
|
||||
enabled: hasNext,
|
||||
onPressed: onNext,
|
||||
previous: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _button(
|
||||
BuildContext context, {
|
||||
required Key key,
|
||||
required String label,
|
||||
required bool enabled,
|
||||
required VoidCallback onPressed,
|
||||
required bool previous,
|
||||
}) {
|
||||
if (usesCupertino(context)) {
|
||||
return CupertinoButton(
|
||||
key: key,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: enabled ? onPressed : null,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
previous ? CupertinoIcons.back : CupertinoIcons.forward,
|
||||
size: 20,
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Text(label),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return TextButton.icon(
|
||||
key: key,
|
||||
onPressed: enabled ? onPressed : null,
|
||||
icon: Icon(previous ? Icons.arrow_back : Icons.arrow_forward),
|
||||
label: Text(label),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/changes/changes.dart';
|
||||
import 'package:pipelines_app/features/changes/widgets/visit_pager.dart';
|
||||
|
||||
import 'fixtures.dart';
|
||||
import 'widget_hosts.dart';
|
||||
@@ -91,7 +92,7 @@ void main() {
|
||||
expect(find.text(emptyCaptureDetail), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('stage/visit sections keep partial status, counters and scope', (
|
||||
testWidgets('stage/visit pages keep partial status, counters and scope', (
|
||||
tester,
|
||||
) async {
|
||||
final diagnostic = 'Excluded protected files.';
|
||||
@@ -121,11 +122,10 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
// The run-wide aggregate still counts the file this visit recorded.
|
||||
expect(find.textContaining('1 file changed'), findsOneWidget);
|
||||
expect(find.text('implementer'), findsOneWidget);
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
// The reviewer's first visit is Visit 1, not the run-wide step ordinal 2.
|
||||
expect(find.text('Visit 1 · failed'), findsOneWidget);
|
||||
expect(find.text('Visit 2 · failed'), findsNothing);
|
||||
expect(
|
||||
find.text(
|
||||
'partial (1 files), 1 skipped, 2 omitted · Excluded protected files.',
|
||||
@@ -136,18 +136,24 @@ void main() {
|
||||
find.text('Scope: Git tracked and nonignored files in the run directory'),
|
||||
findsOneWidget,
|
||||
);
|
||||
// The second visit is its own page, not a second section.
|
||||
expect(find.text('reviewer'), findsNothing);
|
||||
expect(find.text(missingCaptureDetail), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('implementer'), findsNothing);
|
||||
expect(find.text('reviewer'), findsOneWidget);
|
||||
// The reviewer's first visit is Visit 1, not the run-wide step ordinal 2.
|
||||
expect(find.text('Visit 1 · failed'), findsOneWidget);
|
||||
expect(find.text('Visit 2 · failed'), findsNothing);
|
||||
expect(find.text(missingCaptureDetail), findsOneWidget);
|
||||
expect(find.textContaining('partial capture'), findsWidgets);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'repeated stages number their own visits and honour control.visit',
|
||||
(tester) async {
|
||||
// Tall enough that the lazy list builds every section.
|
||||
tester.view.physicalSize = const Size(800, 1400);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(
|
||||
materialHost(
|
||||
ChangesViewer(
|
||||
@@ -177,11 +183,27 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
// Both stages' first recorded visits are Visit 1; the run-wide step
|
||||
// ordinals (1-4) must not leak into the label.
|
||||
expect(find.text('Visit 1 · completed'), findsNWidgets(2));
|
||||
// Pages are in run order; each stage numbers its own visits, so the
|
||||
// run-wide step ordinals (1-4) must not leak into the label.
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
expect(find.text('Visit 2 · completed'), findsNothing);
|
||||
expect(find.text('Visit 6 · completed'), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||
await tester.pump();
|
||||
// The reviewer's first recorded visit is Visit 1 too.
|
||||
expect(find.text('reviewer'), findsOneWidget);
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||
await tester.pump();
|
||||
expect(find.text('implementer'), findsOneWidget);
|
||||
expect(find.text('Visit 2 · completed'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||
await tester.pump();
|
||||
// The resumed reviewer visit records control.visit 6.
|
||||
expect(find.text('reviewer'), findsOneWidget);
|
||||
expect(find.text('Visit 6 · completed'), findsOneWidget);
|
||||
expect(find.text('Visit 3 · completed'), findsNothing);
|
||||
expect(find.text('Visit 4 · completed'), findsNothing);
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/changes/changes.dart';
|
||||
import 'package:pipelines_app/features/changes/widgets/visit_pager.dart';
|
||||
|
||||
import 'fixtures.dart';
|
||||
import 'widget_hosts.dart';
|
||||
|
||||
List<JsonMap> twoVisitRun() => [
|
||||
stepFixture(
|
||||
stage: 'implementer',
|
||||
sequence: 1,
|
||||
fileChanges: captureFixture(
|
||||
files: [
|
||||
fileChangeFixture(path: 'lib/a.dart'),
|
||||
fileChangeFixture(path: 'lib/b.dart'),
|
||||
],
|
||||
),
|
||||
),
|
||||
stepFixture(
|
||||
stage: 'reviewer',
|
||||
sequence: 2,
|
||||
fileChanges: captureFixture(
|
||||
files: [
|
||||
fileChangeFixture(path: 'lib/b.dart'),
|
||||
fileChangeFixture(path: 'lib/c.dart'),
|
||||
],
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'Previous/Next page recorded visits while the aggregate stays run-wide',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(
|
||||
materialHost(ChangesViewer(steps: twoVisitRun())),
|
||||
);
|
||||
|
||||
// The aggregate counts each path once across both visits, and does not
|
||||
// change as the operator pages.
|
||||
expect(find.text('3 files changed'), findsOneWidget);
|
||||
expect(find.text('1 of 2 recorded visits'), findsOneWidget);
|
||||
expect(find.text('implementer'), findsOneWidget);
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
expect(find.text('lib/a.dart'), findsOneWidget);
|
||||
expect(find.text('lib/c.dart'), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||
await tester.pump();
|
||||
|
||||
// The shown page keeps its own visit identity in the heading.
|
||||
expect(find.text('reviewer'), findsOneWidget);
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
expect(find.text('lib/c.dart'), findsOneWidget);
|
||||
expect(find.text('lib/a.dart'), findsNothing);
|
||||
expect(find.text('3 files changed'), findsOneWidget);
|
||||
expect(find.text('2 of 2 recorded visits'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(ChangesVisitPager.previousKey));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('implementer'), findsOneWidget);
|
||||
expect(find.text('lib/a.dart'), findsOneWidget);
|
||||
expect(find.text('lib/c.dart'), findsNothing);
|
||||
expect(find.text('1 of 2 recorded visits'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('paging stops at both ends instead of wrapping', (tester) async {
|
||||
await tester.pumpWidget(materialHost(ChangesViewer(steps: twoVisitRun())));
|
||||
|
||||
TextButton previous() =>
|
||||
tester.widget<TextButton>(find.byKey(ChangesVisitPager.previousKey));
|
||||
TextButton next() =>
|
||||
tester.widget<TextButton>(find.byKey(ChangesVisitPager.nextKey));
|
||||
|
||||
expect(previous().onPressed, isNull);
|
||||
expect(next().onPressed, isNotNull);
|
||||
|
||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||
await tester.pump();
|
||||
expect(previous().onPressed, isNotNull);
|
||||
expect(next().onPressed, isNull);
|
||||
|
||||
// The disabled Next is inert; the page stays on the last visit.
|
||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||
await tester.pump();
|
||||
expect(find.text('reviewer'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(ChangesVisitPager.previousKey));
|
||||
await tester.pump();
|
||||
expect(find.text('implementer'), findsOneWidget);
|
||||
expect(previous().onPressed, isNull);
|
||||
});
|
||||
|
||||
testWidgets('a run with one recorded visit offers no pager', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
materialHost(
|
||||
ChangesViewer(
|
||||
steps: [
|
||||
stepFixture(
|
||||
fileChanges: captureFixture(
|
||||
files: [fileChangeFixture(path: 'lib/only.dart')],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(find.text('Previous visit'), findsNothing);
|
||||
expect(find.text('Next visit'), findsNothing);
|
||||
expect(find.textContaining('recorded visits'), findsNothing);
|
||||
// The single visit still keeps its identity heading.
|
||||
expect(find.text('implementer'), findsOneWidget);
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
expect(find.text('lib/only.dart'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('the filter and its aggregate counter survive paging', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(materialHost(ChangesViewer(steps: twoVisitRun())));
|
||||
|
||||
await tester.enterText(find.byType(TextField), 'a.dart');
|
||||
await tester.pump();
|
||||
expect(find.text('1 of 3 changed paths match'), findsOneWidget);
|
||||
expect(find.text('lib/a.dart'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||
await tester.pump();
|
||||
// The filter still applies to the shown visit, and the counter still
|
||||
// describes the whole run's changed paths.
|
||||
expect(find.text('1 of 3 changed paths match'), findsOneWidget);
|
||||
expect(find.text('No changed filenames match "a.dart".'), findsOneWidget);
|
||||
expect(find.text('lib/c.dart'), findsNothing);
|
||||
expect(find.text('reviewer'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a shorter reply clamps the shown visit instead of overflowing', (
|
||||
tester,
|
||||
) async {
|
||||
final first = twoVisitRun();
|
||||
final second = [
|
||||
stepFixture(
|
||||
stage: 'implementer',
|
||||
sequence: 1,
|
||||
fileChanges: captureFixture(
|
||||
files: [fileChangeFixture(path: 'lib/a.dart')],
|
||||
),
|
||||
),
|
||||
];
|
||||
await tester.pumpWidget(materialHost(ChangesViewer(steps: first)));
|
||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||
await tester.pump();
|
||||
expect(find.text('reviewer'), findsOneWidget);
|
||||
|
||||
await tester.pumpWidget(materialHost(ChangesViewer(steps: second)));
|
||||
await tester.pump();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.text('implementer'), findsOneWidget);
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
expect(find.text('Previous visit'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('the pager stays reachable at 320x720 with 2x text', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(320, 720);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(
|
||||
materialHost(
|
||||
ChangesViewer(steps: twoVisitRun()),
|
||||
scaler: const TextScaler.linear(2),
|
||||
),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.text('Previous visit'), findsOneWidget);
|
||||
expect(find.text('Next visit'), findsOneWidget);
|
||||
|
||||
// At 2x text the fixed summary and filter leave a short scroll viewport;
|
||||
// the pager is still reachable by scrolling the visit body.
|
||||
await tester.ensureVisible(find.text('Next visit'));
|
||||
await tester.pump();
|
||||
await tester.tap(find.text('Next visit'));
|
||||
await tester.pump();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.text('reviewer'), findsOneWidget);
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
expect(find.text('lib/c.dart'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino pages with native buttons at both ends', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(cupertinoHost(ChangesViewer(steps: twoVisitRun())));
|
||||
|
||||
final previous = tester.widget<CupertinoButton>(
|
||||
find.byKey(ChangesVisitPager.previousKey),
|
||||
);
|
||||
final next = tester.widget<CupertinoButton>(
|
||||
find.byKey(ChangesVisitPager.nextKey),
|
||||
);
|
||||
expect(previous.onPressed, isNull);
|
||||
expect(next.onPressed, isNotNull);
|
||||
expect(find.text('Previous visit'), findsOneWidget);
|
||||
expect(find.text('Next visit'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(ChangesVisitPager.nextKey));
|
||||
await tester.pump();
|
||||
expect(find.text('reviewer'), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<CupertinoButton>(find.byKey(ChangesVisitPager.nextKey))
|
||||
.onPressed,
|
||||
isNull,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -112,8 +112,19 @@ void main() {
|
||||
find.text('1 file changed · +2 -2 · capture incomplete'),
|
||||
findsOneWidget,
|
||||
);
|
||||
// Visit numbers are per stage, so both stages' first visits say Visit 1.
|
||||
expect(find.text('Visit 1 · completed'), findsNWidgets(2));
|
||||
// The page opens on the run's first recorded visit; its stage/visit
|
||||
// heading identifies the evidence, and Next reaches the second visit.
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
expect(find.text('implementer'), findsOneWidget);
|
||||
expect(find.text('Next visit'), findsOneWidget);
|
||||
await tester.tap(find.text('Next visit'));
|
||||
await tester.pump();
|
||||
expect(find.text('reviewer'), findsOneWidget);
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
expect(find.text('lib/feature.dart'), findsNothing);
|
||||
await tester.tap(find.text('Previous visit'));
|
||||
await tester.pump();
|
||||
expect(find.text('lib/feature.dart'), findsOneWidget);
|
||||
|
||||
await tester.tap(
|
||||
find.byKey(const ValueKey('change-1-lib/feature.dart')),
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/changes/changes.dart';
|
||||
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_changes_action.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
|
||||
@@ -138,9 +139,15 @@ void main() {
|
||||
find.textContaining('The summary counts each path once'),
|
||||
findsNothing,
|
||||
);
|
||||
// The visit's own recorded capture stays reachable.
|
||||
// The visit's own recorded capture stays reachable, one visit page at
|
||||
// a time; the second visit's gap is reachable with Next.
|
||||
expect(find.text('lib/feature.dart'), findsOneWidget);
|
||||
expect(find.text('Visit 1 · completed'), findsNWidgets(2));
|
||||
expect(find.text('implementer'), findsOneWidget);
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
await tester.tap(find.text('Next visit'));
|
||||
await tester.pump();
|
||||
expect(find.text('reviewer'), findsOneWidget);
|
||||
expect(find.text(missingCaptureDetail), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
|
||||
+195
-27
@@ -8,6 +8,10 @@
|
||||
// headless Chrome through the Chrome DevTools Protocol, enables Flutter
|
||||
// semantics, clicks exact labels, verifies the body/labels change, copies the
|
||||
// raw patch and writes real PNG captures at phone and desktop widths.
|
||||
//
|
||||
// The Changes page shows one recorded visit at a time, so visit-only evidence
|
||||
// (capture states, visit numbers) is collected by paging with Previous/Next
|
||||
// rather than from a single body snapshot.
|
||||
import { createServer } from 'node:http';
|
||||
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
||||
import { spawn } from 'node:child_process';
|
||||
@@ -181,6 +185,36 @@ try {
|
||||
if (!clicked) throw new Error(`No semantics label starting ${JSON.stringify(prefix)}: ${JSON.stringify(await labels())}`);
|
||||
await delay(450);
|
||||
};
|
||||
// The disabled Previous/Next is a semantics button with aria-disabled; the
|
||||
// pager must stop at both ends instead of wrapping.
|
||||
const buttonDisabled = (label) => evaluate(`(() => {
|
||||
const wanted = ${JSON.stringify(label)};
|
||||
const node = [...document.querySelectorAll('flt-semantics[role="button"]')]
|
||||
.find(x => (x.getAttribute('aria-label') || (x.innerText || '').trim()) === wanted);
|
||||
return node ? node.getAttribute('aria-disabled') === 'true' : null;
|
||||
})()`);
|
||||
// Clipboard writes need a trusted user gesture, which a scripted semantics
|
||||
// `.click()` is not; dispatch real mouse events at the control's centre.
|
||||
const tapExact = async (label) => {
|
||||
const point = await evaluate(`(() => {
|
||||
const wanted = ${JSON.stringify(label)};
|
||||
const nodes = [...document.querySelectorAll('flt-semantics')];
|
||||
const node = nodes.find(x => x.getAttribute('aria-label') === wanted)
|
||||
|| nodes.find(x => (x.innerText || '').trim() === wanted);
|
||||
if (!node) return null;
|
||||
const rect = node.getBoundingClientRect();
|
||||
return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };
|
||||
})()`);
|
||||
if (!point) throw new Error(`No semantics node for ${JSON.stringify(label)}: ${JSON.stringify(await labels())}`);
|
||||
for (const type of ['mousePressed', 'mouseReleased']) {
|
||||
await send('Input.dispatchMouseEvent', { type, x: point.x, y: point.y, button: 'left', clickCount: 1 }, session);
|
||||
}
|
||||
await delay(450);
|
||||
};
|
||||
const visitPage = (text) => text.match(/\d+ of \d+ recorded visits/)?.[0] ?? null;
|
||||
const visitStage = (text, stage) => text.includes(`\n${stage}\n`);
|
||||
const headerLine = (text) =>
|
||||
text.split('\n').find((line) => line.startsWith('Changes · ')) ?? null;
|
||||
const activate = async () => {
|
||||
await delay(3500);
|
||||
await evaluate("document.querySelector('flt-semantics-placeholder')?.click()");
|
||||
@@ -233,19 +267,127 @@ try {
|
||||
const firstBody = await bodyText();
|
||||
const firstRow = 'Open diff for lib/features/changes/domain/unified_patch.dart';
|
||||
const firstRowPresent = firstLabels.some((label) => label.startsWith(firstRow));
|
||||
const firstStates = ['Changes probe', 'Capture unavailable'].filter((label) =>
|
||||
firstBody.includes(label),
|
||||
);
|
||||
// The run-wide aggregate header and the pager describe different scopes: the
|
||||
// header covers every visit, the pager position scopes the shown visit.
|
||||
const firstPage = {
|
||||
header: headerLine(firstBody),
|
||||
page: visitPage(firstBody),
|
||||
stage: visitStage(firstBody, 'implementer'),
|
||||
visit: firstBody.includes('Visit 1 · completed'),
|
||||
previousDisabled: await buttonDisabled('Previous visit'),
|
||||
nextDisabled: await buttonDisabled('Next visit'),
|
||||
};
|
||||
evidence.checks.push({
|
||||
check: 'run summary and capture states are present',
|
||||
value: firstStates,
|
||||
check: 'page 1 opens on the first recorded visit',
|
||||
...firstPage,
|
||||
fileRow: firstRowPresent,
|
||||
});
|
||||
if (firstStates.length !== 2 || !firstRowPresent) {
|
||||
throw new Error(`Run summary or capture states missing: ${JSON.stringify(firstBody)}`);
|
||||
if (
|
||||
firstPage.header !== 'Changes · capture unavailable' ||
|
||||
firstPage.page !== '1 of 5 recorded visits' ||
|
||||
!firstPage.stage ||
|
||||
!firstPage.visit
|
||||
) {
|
||||
throw new Error(`Run summary or first visit missing: ${JSON.stringify(firstBody)}`);
|
||||
}
|
||||
if (firstPage.previousDisabled !== true || firstPage.nextDisabled !== false) {
|
||||
throw new Error(`Page 1 pager did not clamp at the start: ${JSON.stringify(firstPage)}`);
|
||||
}
|
||||
if (!firstRowPresent) throw new Error('Page 1 is missing the implementer file row');
|
||||
await capture('d1-changes-phone-list', 390, 844);
|
||||
|
||||
// Page through every recorded visit. Each page keeps its own stage/visit
|
||||
// heading and the run-wide header, and Next/Previous clamp at both ends.
|
||||
await clickExact('Next visit');
|
||||
const secondBody = await bodyText();
|
||||
const secondPage = {
|
||||
page: visitPage(secondBody),
|
||||
stage: visitStage(secondBody, 'reviewer'),
|
||||
visit: secondBody.includes('Visit 1 · completed'),
|
||||
headerUnchanged: headerLine(secondBody) === firstPage.header,
|
||||
previousDisabled: await buttonDisabled('Previous visit'),
|
||||
rowPresent: (await labels()).some((label) =>
|
||||
label.startsWith('Open diff for lib/features/changes/widgets/file_diff_viewer.dart'),
|
||||
),
|
||||
};
|
||||
evidence.checks.push({ check: 'Next opens the next recorded visit', ...secondPage });
|
||||
if (
|
||||
secondPage.page !== '2 of 5 recorded visits' ||
|
||||
!secondPage.stage ||
|
||||
!secondPage.visit ||
|
||||
!secondPage.headerUnchanged ||
|
||||
secondPage.previousDisabled !== false ||
|
||||
!secondPage.rowPresent
|
||||
) {
|
||||
throw new Error(`Second visit page is wrong: ${JSON.stringify(secondBody)}`);
|
||||
}
|
||||
await capture('d1-changes-phone-page2', 390, 844);
|
||||
|
||||
await clickExact('Next visit');
|
||||
const missingBody = await bodyText();
|
||||
evidence.checks.push({
|
||||
check: 'a later visit reports a missing capture',
|
||||
page: visitPage(missingBody),
|
||||
stage: visitStage(missingBody, 'ui_reviewer'),
|
||||
captureUnavailable: missingBody.includes('Capture unavailable'),
|
||||
});
|
||||
if (
|
||||
visitPage(missingBody) !== '3 of 5 recorded visits' ||
|
||||
!visitStage(missingBody, 'ui_reviewer') ||
|
||||
!missingBody.includes('Capture unavailable')
|
||||
) {
|
||||
throw new Error(`Missing-capture visit page is wrong: ${JSON.stringify(missingBody)}`);
|
||||
}
|
||||
await capture('d1-changes-phone-page3-missing', 390, 844);
|
||||
|
||||
await clickExact('Next visit');
|
||||
const unavailableBody = await bodyText();
|
||||
evidence.checks.push({
|
||||
check: 'a later visit reports an unavailable capture',
|
||||
page: visitPage(unavailableBody),
|
||||
stage: visitStage(unavailableBody, 'committer'),
|
||||
diagnostic: unavailableBody.includes('Workspace snapshot unavailable'),
|
||||
});
|
||||
if (
|
||||
visitPage(unavailableBody) !== '4 of 5 recorded visits' ||
|
||||
!visitStage(unavailableBody, 'committer') ||
|
||||
!unavailableBody.includes('Workspace snapshot unavailable')
|
||||
) {
|
||||
throw new Error(`Unavailable-capture visit page is wrong: ${JSON.stringify(unavailableBody)}`);
|
||||
}
|
||||
await capture('d1-changes-phone-page4-unavailable', 390, 844);
|
||||
|
||||
await clickExact('Next visit');
|
||||
const lastBody = await bodyText();
|
||||
evidence.checks.push({
|
||||
check: 'the last visit is a recorded no-change and Next is disabled',
|
||||
page: visitPage(lastBody),
|
||||
stage: visitStage(lastBody, 'verifier'),
|
||||
empty: lastBody.includes('No changes observed'),
|
||||
nextDisabled: await buttonDisabled('Next visit'),
|
||||
});
|
||||
if (
|
||||
visitPage(lastBody) !== '5 of 5 recorded visits' ||
|
||||
!visitStage(lastBody, 'verifier') ||
|
||||
!lastBody.includes('No changes observed') ||
|
||||
(await buttonDisabled('Next visit')) !== true
|
||||
) {
|
||||
throw new Error(`Last visit page is wrong: ${JSON.stringify(lastBody)}`);
|
||||
}
|
||||
await capture('d1-changes-phone-page5-last', 390, 844);
|
||||
|
||||
await clickExact('Previous visit');
|
||||
const previousBody = await bodyText();
|
||||
evidence.checks.push({
|
||||
check: 'Previous returns to the prior visit',
|
||||
page: visitPage(previousBody),
|
||||
stage: visitStage(previousBody, 'committer'),
|
||||
});
|
||||
if (visitPage(previousBody) !== '4 of 5 recorded visits') {
|
||||
throw new Error(`Previous lost the visit: ${JSON.stringify(previousBody)}`);
|
||||
}
|
||||
|
||||
await navigate(`${origin}/`);
|
||||
const before = await bodyText();
|
||||
await clickPrefix('Open diff for lib/features/changes/domain/unified_patch.dart');
|
||||
const after = await bodyText();
|
||||
@@ -284,7 +426,7 @@ try {
|
||||
origin,
|
||||
permissions: ['clipboardReadWrite', 'clipboardSanitizedWrite'],
|
||||
});
|
||||
await clickExact('Copy patch');
|
||||
await tapExact('Copy patch');
|
||||
let clipboard = null;
|
||||
try {
|
||||
clipboard = await evaluate('navigator.clipboard.readText()');
|
||||
@@ -344,34 +486,45 @@ try {
|
||||
evidence.checks.push({ check: 'filter field not exposed as a semantics input', value: false });
|
||||
}
|
||||
|
||||
// Visit numbering: two stages appear twice in this compact fixture. The
|
||||
// implementer's visits are position-derived (1, 2); the resumed reviewer
|
||||
// visit records control.visit 6, which must win over its position.
|
||||
// Visit numbering: two stages appear twice in this compact fixture. Each
|
||||
// stage numbers its own visits, so paging must collect one number per page:
|
||||
// the implementer's visits are position-derived (1, 2) and the resumed
|
||||
// reviewer visit records control.visit 6, which must win over its position.
|
||||
await navigate(`${origin}/?visits=1`);
|
||||
const visitText = await bodyText();
|
||||
const visitsFor = (stage) => [
|
||||
...visitText.matchAll(new RegExp(`${stage}\\s+Visit (\\d+)`, 'g')),
|
||||
].map((match) => match[1]);
|
||||
const implementerVisits = visitsFor('implementer');
|
||||
const reviewerVisits = visitsFor('reviewer');
|
||||
evidence.checks.push({
|
||||
check: 'repeated stages show their own visit numbers',
|
||||
implementerVisits,
|
||||
reviewerVisits,
|
||||
});
|
||||
if (implementerVisits.join(',') !== '1,2') {
|
||||
throw new Error(`implementer visits are not 1,2: ${JSON.stringify(visitText)}`);
|
||||
const visitSequence = [];
|
||||
for (let step = 0; step < 4; step++) {
|
||||
const current = await bodyText();
|
||||
const stage = visitStage(current, 'implementer')
|
||||
? 'implementer'
|
||||
: visitStage(current, 'reviewer')
|
||||
? 'reviewer'
|
||||
: '?';
|
||||
visitSequence.push(`${stage}:${current.match(/Visit (\d+) ·/)?.[1] ?? '?'}`);
|
||||
if (step < 3) await clickExact('Next visit');
|
||||
}
|
||||
if (reviewerVisits.join(',') !== '1,6') {
|
||||
throw new Error(`reviewer visits are not 1,6 (control.visit): ${JSON.stringify(visitText)}`);
|
||||
const lastVisitBody = await bodyText();
|
||||
evidence.checks.push({
|
||||
check: 'paged visit numbering keeps per-stage numbers and control.visit',
|
||||
sequence: visitSequence,
|
||||
page: visitPage(lastVisitBody),
|
||||
nextDisabled: await buttonDisabled('Next visit'),
|
||||
});
|
||||
if (visitSequence.join(',') !== 'implementer:1,reviewer:1,implementer:2,reviewer:6') {
|
||||
throw new Error(`Visit numbers are not paged per stage: ${JSON.stringify(visitSequence)}`);
|
||||
}
|
||||
if (visitPage(lastVisitBody) !== '4 of 4 recorded visits') {
|
||||
throw new Error(`Visit fixture did not reach its last page: ${JSON.stringify(lastVisitBody)}`);
|
||||
}
|
||||
const visitFile = await capture('d1-changes-phone-visits', 390, 844);
|
||||
|
||||
await navigate(`${origin}/`);
|
||||
await capture('d1-changes-desktop-list', 1280, 800);
|
||||
// The reviewer's file row lives on the second visit page.
|
||||
await clickExact('Next visit');
|
||||
await capture('d1-changes-desktop-page2', 1280, 800);
|
||||
await clickPrefix('Open diff for lib/features/changes/widgets/file_diff_viewer.dart');
|
||||
await capture('d1-changes-desktop-diff', 1280, 800);
|
||||
await clickExact('Close diff');
|
||||
await capture('d1-changes-desktop-list', 1280, 800);
|
||||
|
||||
// Presentation revision: the light theme and a narrow Cupertino surface, at
|
||||
// 2x so glyph advance, line tints and the popup inset are inspectable.
|
||||
@@ -389,12 +542,27 @@ try {
|
||||
|
||||
await navigate(`${origin}/?theme=light`);
|
||||
await capture('d1-changes-desktop-light-list', 1280, 800);
|
||||
// The reviewer's row is on the second visit page in the light theme too.
|
||||
await clickExact('Next visit');
|
||||
await clickPrefix('Open diff for lib/features/changes/widgets/file_diff_viewer.dart');
|
||||
await capture('d1-changes-desktop-light-diff', 1280, 800);
|
||||
await clickExact('Close diff');
|
||||
|
||||
await navigate(`${origin}/?platform=cupertino&theme=light`);
|
||||
await capture('d1-changes-cupertino-light-list', 390, 844);
|
||||
// The Cupertino pager uses native buttons; paging keeps the visit heading.
|
||||
await clickExact('Next visit');
|
||||
const cupertinoSecond = await bodyText();
|
||||
evidence.checks.push({
|
||||
check: 'Cupertino pages to the second visit',
|
||||
page: visitPage(cupertinoSecond),
|
||||
stage: visitStage(cupertinoSecond, 'reviewer'),
|
||||
});
|
||||
if (visitPage(cupertinoSecond) !== '2 of 5 recorded visits') {
|
||||
throw new Error(`Cupertino pager did not advance: ${JSON.stringify(cupertinoSecond)}`);
|
||||
}
|
||||
await capture('d1-changes-cupertino-light-page2', 390, 844);
|
||||
await clickExact('Previous visit');
|
||||
await clickPrefix('Open diff for lib/features/changes/domain/unified_patch.dart');
|
||||
await capture('d1-changes-cupertino-light-diff', 390, 844);
|
||||
await capture('d1-changes-cupertino-light-diff-2x', 390, 844, 2);
|
||||
|
||||
Reference in New Issue
Block a user