feat(app): open Changes for the selected visit from its pane
The opened recorded-visit pane gains one native Changes action next to Back to timeline. It reuses showRunChanges with only that visit's step, so the pushed page shows that visit's own capture and no run-wide summary, and a visit without a capture reaches the honest missing-capture state. The run-level Changes action and its title are unchanged.
This commit is contained in:
@@ -0,0 +1,128 @@
|
||||
import 'package:flutter/cupertino.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/ui/run_changes_action.dart';
|
||||
|
||||
import '../../changes/fixtures.dart';
|
||||
import 'run_detail_graph_support.dart';
|
||||
import 'run_detail_visit_support.dart';
|
||||
|
||||
/// plan and build each recorded a capture with a different file, so a page that
|
||||
/// showed the run's steps would leak the other visit's path.
|
||||
JsonMap _run({JsonMap? planChanges, JsonMap? buildChanges}) =>
|
||||
<String, dynamic>{
|
||||
'id': 77,
|
||||
'title': 'Visit changes',
|
||||
'name': 'release',
|
||||
'status': 'succeeded',
|
||||
'steps': <dynamic>[
|
||||
stepFixture(stage: 'plan', sequence: 1, fileChanges: planChanges),
|
||||
stepFixture(stage: 'build', sequence: 2, fileChanges: buildChanges),
|
||||
],
|
||||
};
|
||||
|
||||
JsonMap _capture(String path) => captureFixture(
|
||||
files: <JsonMap>[fileChangeFixture(path: path, patch: multiHunkPatch)],
|
||||
);
|
||||
|
||||
Future<void> _openVisitChanges(WidgetTester tester) async {
|
||||
await tester.tap(find.byKey(runVisitChangesButtonKey));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
void main() {
|
||||
group('visitChangesTitle', () {
|
||||
test('names the stage and visit the timeline row shows', () {
|
||||
expect(visitChangesTitle('plan', 1), 'Changes · plan · visit 1');
|
||||
});
|
||||
|
||||
test('omits a stage the server did not record', () {
|
||||
expect(visitChangesTitle(' ', 3), 'Changes · visit 3');
|
||||
});
|
||||
|
||||
test('does not invent a visit number when none was recorded', () {
|
||||
expect(
|
||||
visitChangesTitle('plan', null),
|
||||
'Changes · plan · visit unavailable',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
for (final platform in RunDetailTestPlatform.values) {
|
||||
testWidgets('${platform.name}: visit Changes opens that visit only', (
|
||||
tester,
|
||||
) async {
|
||||
await openVisit(
|
||||
tester,
|
||||
platform,
|
||||
run: _run(
|
||||
planChanges: _capture('lib/plan.dart'),
|
||||
buildChanges: _capture('lib/build.dart'),
|
||||
),
|
||||
);
|
||||
|
||||
await _openVisitChanges(tester);
|
||||
|
||||
expect(find.text('Changes · plan · visit 1'), findsOneWidget);
|
||||
// The body keeps the landed viewer's own identity for that visit.
|
||||
expect(find.text('plan'), findsOneWidget);
|
||||
expect(find.text('Visit 1 · completed'), findsOneWidget);
|
||||
expect(find.text('lib/plan.dart'), findsOneWidget);
|
||||
expect(find.text('lib/build.dart'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('${platform.name}: visit without a capture is honest', (
|
||||
tester,
|
||||
) async {
|
||||
await openVisit(
|
||||
tester,
|
||||
platform,
|
||||
run: _run(buildChanges: _capture('lib/build.dart')),
|
||||
);
|
||||
|
||||
await _openVisitChanges(tester);
|
||||
|
||||
expect(find.text('Changes · plan · visit 1'), findsOneWidget);
|
||||
expect(find.text(missingCaptureDetail), findsOneWidget);
|
||||
// A missing capture is evidence, never an observed no-change.
|
||||
expect(find.text('No changes observed'), findsNothing);
|
||||
expect(find.text(emptyCaptureDetail), findsNothing);
|
||||
expect(find.text('lib/build.dart'), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('material: visit Changes returns to the opened pane', (
|
||||
tester,
|
||||
) async {
|
||||
await openVisit(
|
||||
tester,
|
||||
RunDetailTestPlatform.material,
|
||||
run: _run(planChanges: _capture('lib/plan.dart')),
|
||||
);
|
||||
|
||||
await _openVisitChanges(tester);
|
||||
await tester.tap(find.byTooltip('Back'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||
expect(find.byKey(runVisitChangesButtonKey), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('cupertino: visit Changes returns to the opened pane', (
|
||||
tester,
|
||||
) async {
|
||||
await openVisit(
|
||||
tester,
|
||||
RunDetailTestPlatform.cupertino,
|
||||
run: _run(planChanges: _capture('lib/plan.dart')),
|
||||
);
|
||||
|
||||
await _openVisitChanges(tester);
|
||||
await tester.tap(find.byType(CupertinoNavigationBarBackButton));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('run-visit-pane')), findsOneWidget);
|
||||
expect(find.byKey(runVisitChangesButtonKey), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user