Merge branch 'main' into run/artifacts-split

This commit is contained in:
2026-10-31 12:56:19 +00:00
137 changed files with 5916 additions and 1382 deletions
@@ -0,0 +1,27 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_preview_failure.dart';
void main() {
test('fetch failures read as plain language, never raw errors', () {
expect(
artifactPreviewFailureMessage(),
'The preview could not be loaded. Check the connection and try again.',
);
expect(
artifactPreviewFailureMessage(status: 404),
'This file is no longer on the server.',
);
expect(
artifactPreviewFailureMessage(status: 403),
'The server did not allow this file to be opened.',
);
expect(
artifactPreviewFailureMessage(status: 502),
'The server could not send this file right now.',
);
expect(
artifactPreviewFailureMessage(status: 418),
'The preview could not be loaded (status 418).',
);
});
}
@@ -12,6 +12,8 @@ import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
import 'package:pipelines_app/features/artifacts/domain/artifact_record.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_external_open.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_gallery_page.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_content.dart'
show artifactPreviewRetryKey;
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_fetch.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_page.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
@@ -464,8 +466,39 @@ void main() {
pending.complete(ArtifactFetchResult(status: 404, bytes: Uint8List(0)));
await tester.pumpAndSettle();
expect(find.text('The server answered 404.'), findsOneWidget);
expect(find.text('This file is no longer on the server.'), findsOneWidget);
expect(find.textContaining('answered'), findsNothing);
expect(find.byType(SelectableText), findsNothing);
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
});
testWidgets('Retry fetches a failed preview again', (tester) async {
final text = recordedArtifact(
'notes.txt',
url: '/artifacts/1/1/notes.txt',
contentType: 'text/plain',
);
final group = _group([text]);
var calls = 0;
await _pumpViewer(
tester,
groups: [group],
selected: artifactVisitIdentity(group, text),
fetch: (_) async {
calls++;
if (calls == 1) throw const ArtifactFetchException('network down');
return ArtifactFetchResult(
status: 200,
bytes: Uint8List.fromList('hello'.codeUnits),
);
},
);
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
await tester.tap(find.byKey(artifactPreviewRetryKey));
await tester.pumpAndSettle();
expect(calls, 2);
expect(find.byKey(artifactPreviewRetryKey), findsNothing);
expect(find.text('hello'), findsOneWidget);
});
testWidgets('a network failure is reported instead of an empty preview', (
@@ -483,8 +516,15 @@ void main() {
selected: artifactVisitIdentity(group, text),
fetch: (_) async => throw const ArtifactFetchException('network down'),
);
expect(find.textContaining('Could not load preview'), findsOneWidget);
expect(find.textContaining('network down'), findsOneWidget);
// A friendly line with Retry, never the raw exception text.
expect(
find.text(
'The preview could not be loaded. Check the connection and try again.',
),
findsOneWidget,
);
expect(find.textContaining('network down'), findsNothing);
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
});
testWidgets('Cupertino draws the same text preview and controls', (