Open Search artifact hits in the viewer over the run's Artifacts tab
On a phone-width window the open run is its own page pushed on the app navigator, so RunDetailTabs was not a descendant of the shell's RunSearchSelectionScope (which wraps only the Runs tab body). The field or artifact selection was never seen and the run opened at its plain Summary. The previous widget tests injected the scope directly above RunDetailView at 900 px, where the detail is an inline pane, so they could not catch it. - RunsScreen relays the shell's search scope into the detail it builds, so the pushed page sees the selection too (also fixes field hits on phones). - An artifact hit now opens the run's Artifacts tab and the gallery opens that artifact exactly as a tap there does: selected, scrolled into view (ArtifactVisitReveal) and in the viewer. Back returns to the tab with the artifact highlighted. An unknown URL leaves the tab open with the existing "That artifact is no longer available." notice. - New test/application/search_artifact_open_test.dart drives the real Search tab -> typed query -> result tap -> run read -> viewer on a 390x844 phone, Material and Cupertino; it fails without the scope relay.
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'run_detail_finders.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_tile.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_page.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
|
||||
@@ -103,6 +104,8 @@ void _expectSummarySection(RunSearchTarget target, RunSummarySection? section) {
|
||||
expect((target as RunSummaryTarget).section, section);
|
||||
}
|
||||
|
||||
const _origin = 'http://127.0.0.1:8096';
|
||||
|
||||
void main() {
|
||||
for (final platform in RunDetailTestPlatform.values) {
|
||||
testWidgets('${platform.name} artifact hit opens its recorded visit', (
|
||||
@@ -120,6 +123,11 @@ void main() {
|
||||
}
|
||||
|
||||
/// The search fixture with one recorded artifact on build (sequence 2).
|
||||
///
|
||||
/// The fake gateway configures no server, so the recorded URLs are absolute:
|
||||
/// a relative one would not resolve and the gallery would show its facts
|
||||
/// dialog instead of the viewer. The app-level search wiring test covers the
|
||||
/// server-relative URLs a real server records.
|
||||
JsonMap runWithArtifact() {
|
||||
final run = searchSelectionRun();
|
||||
final steps = [
|
||||
@@ -131,33 +139,40 @@ void main() {
|
||||
'name': 'release-report.txt',
|
||||
'content_type': 'text/plain',
|
||||
'size_bytes': 12,
|
||||
'url': '/artifacts/77/2/release-report.txt',
|
||||
'url': '$_origin/artifacts/77/2/release-report.txt',
|
||||
},
|
||||
];
|
||||
return {...run, 'steps': steps};
|
||||
}
|
||||
|
||||
for (final platform in RunDetailTestPlatform.values) {
|
||||
testWidgets('${platform.name} artifact hit opens that artifact, and the '
|
||||
'timeline keeps working afterwards', (tester) async {
|
||||
testWidgets('${platform.name} artifact hit opens that artifact over the '
|
||||
'Artifacts tab, and the timeline keeps working afterwards', (
|
||||
tester,
|
||||
) async {
|
||||
final pending = await pumpLiveSelection(
|
||||
tester,
|
||||
platform,
|
||||
const RunSearchSelection(
|
||||
runId: 77,
|
||||
sequence: 2,
|
||||
artifactUrl: '/artifacts/77/2/release-report.txt',
|
||||
artifactUrl: '$_origin/artifacts/77/2/release-report.txt',
|
||||
),
|
||||
run: runWithArtifact(),
|
||||
);
|
||||
expect(find.byType(ArtifactViewerPage), findsOneWidget);
|
||||
expect(find.text('release-report.txt'), findsWidgets);
|
||||
|
||||
// Back from the viewer lands on the artifact's visit.
|
||||
// Back from the viewer lands on the run's Artifacts tab, the artifact
|
||||
// shown there selected, exactly as after tapping it in the gallery.
|
||||
Navigator.of(tester.element(find.byType(ArtifactViewerPage))).pop();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(ArtifactViewerPage), findsNothing);
|
||||
expectVisitHeading(tester, 'build', 1);
|
||||
expect(find.byKey(const Key('run-visit-pane')), findsNothing);
|
||||
expect(find.byKey(const ValueKey('run-detail-artifacts-77')), findsOne);
|
||||
final tile = tester.widget<ArtifactTile>(find.byType(ArtifactTile));
|
||||
expect(tile.artifact.url, '$_origin/artifacts/77/2/release-report.txt');
|
||||
expect(tile.selected, isTrue);
|
||||
|
||||
// Selecting another visit afterwards still opens it.
|
||||
pending.value = const RunSearchSelection(runId: 77, sequence: 5);
|
||||
@@ -166,20 +181,78 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('a missing artifact opens the run with a notice', (tester) async {
|
||||
await pumpSelection(
|
||||
testWidgets('a missing artifact opens the Artifacts tab with a notice', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpLiveSelection(
|
||||
tester,
|
||||
RunDetailTestPlatform.material,
|
||||
const RunSearchSelection(
|
||||
runId: 77,
|
||||
sequence: 2,
|
||||
artifactUrl: '/artifacts/77/2/gone.txt',
|
||||
artifactUrl: '$_origin/artifacts/77/2/gone.txt',
|
||||
),
|
||||
run: runWithArtifact(),
|
||||
);
|
||||
expect(find.byType(ArtifactViewerPage), findsNothing);
|
||||
expect(find.byKey(const ValueKey('run-detail-artifacts-77')), findsOne);
|
||||
expect(find.text('That artifact is no longer available.'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('an artifact far down the gallery is scrolled into view', (
|
||||
tester,
|
||||
) async {
|
||||
final run = runWithArtifact();
|
||||
final steps = [
|
||||
for (final step in run['steps'] as List)
|
||||
Map<String, dynamic>.from(step as Map),
|
||||
];
|
||||
// Both plan visits list many files ahead of the build visit's, which
|
||||
// pushes the requested build artifact well below the fold.
|
||||
for (final index in [0, 2]) {
|
||||
final sequence = steps[index]['sequence'];
|
||||
steps[index]['artifacts'] = <dynamic>[
|
||||
for (var i = 0; i < 30; i++)
|
||||
<String, dynamic>{
|
||||
'name': 'filler-$i.bin',
|
||||
'content_type': 'application/octet-stream',
|
||||
'size_bytes': 1,
|
||||
'url': '$_origin/artifacts/77/$sequence/filler-$i.bin',
|
||||
},
|
||||
];
|
||||
}
|
||||
(steps[1]['artifacts'] as List).add(<String, dynamic>{
|
||||
'name': 'late-notes.txt',
|
||||
'content_type': 'text/plain',
|
||||
'size_bytes': 3,
|
||||
'url': '$_origin/artifacts/77/2/late-notes.txt',
|
||||
});
|
||||
await pumpLiveSelection(
|
||||
tester,
|
||||
RunDetailTestPlatform.material,
|
||||
const RunSearchSelection(
|
||||
runId: 77,
|
||||
sequence: 2,
|
||||
artifactUrl: '$_origin/artifacts/77/2/late-notes.txt',
|
||||
),
|
||||
run: {...run, 'steps': steps},
|
||||
);
|
||||
expect(find.byType(ArtifactViewerPage), findsOneWidget);
|
||||
Navigator.of(tester.element(find.byType(ArtifactViewerPage))).pop();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final late = find.byWidgetPredicate(
|
||||
(widget) =>
|
||||
widget is ArtifactTile &&
|
||||
widget.artifact.url == '$_origin/artifacts/77/2/late-notes.txt',
|
||||
);
|
||||
expect(late, findsOneWidget);
|
||||
expect(tester.widget<ArtifactTile>(late).selected, isTrue);
|
||||
final rect = tester.getRect(late);
|
||||
expect(rect.top, greaterThanOrEqualTo(0));
|
||||
expect(rect.bottom, lessThanOrEqualTo(1000));
|
||||
});
|
||||
|
||||
testWidgets('an unknown artifact sequence opens the plain run', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -333,21 +406,19 @@ void main() {
|
||||
expect(target.timelineIndex, 1);
|
||||
});
|
||||
|
||||
test('an artifact selection keeps its URL while naming the visit', () {
|
||||
test('an artifact selection names its recorded URL', () {
|
||||
final target = resolveRunSearchSelection(
|
||||
const RunSearchSelection(
|
||||
runId: 77,
|
||||
sequence: 2,
|
||||
artifactUrl: '/artifacts/77/2/release-report.txt',
|
||||
artifactUrl: '$_origin/artifacts/77/2/release-report.txt',
|
||||
),
|
||||
searchSelectionRun(),
|
||||
);
|
||||
|
||||
expect(target, isA<RunArtifactTarget>());
|
||||
final artifact = target as RunArtifactTarget;
|
||||
expect(artifact.url, '/artifacts/77/2/release-report.txt');
|
||||
expect(artifact.visit.stageKey, 'build');
|
||||
expect(artifact.visit.timelineIndex, 1);
|
||||
expect(artifact.url, '$_origin/artifacts/77/2/release-report.txt');
|
||||
});
|
||||
|
||||
test('an unrecorded sequence falls back to the plain Summary', () {
|
||||
|
||||
Reference in New Issue
Block a user