Open the run's artifact from notifications

Phone and browser notifications that carry an artifact open it full
screen in the artifact viewer, with an Open run action and the preview as
expanded text; pipelines://artifact deep links route to the viewer.
This commit is contained in:
2026-11-12 18:56:26 +00:00
parent d42d7a3534
commit 767643d991
17 changed files with 487 additions and 35 deletions
+7
View File
@@ -2,6 +2,13 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/app_route.dart';
void main() {
test('parses artifact deep links and preserves escaped path', () {
final route = AppRoute.parse(
'pipelines://artifact/42/3/reports%2Ffinal.md',
);
expect(route, AppRoute.artifact(42, 3, 'reports/final.md'));
expect(route.path, '/artifact/42/3/reports%2Ffinal.md');
});
test('parses each destination, detail and stage pane', () {
expect(AppRoute.parse('/pipelines'), AppRoute.pipelines);
expect(AppRoute.parse('/pipelines/5'), AppRoute.pipeline(5));
@@ -1,6 +1,7 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/attention/notify/notification_controller.dart';
import 'package:pipelines_app/features/attention/notify/notification_store.dart';
import 'package:pipelines_app/features/attention/notify/notification_models.dart';
import 'notification_test_support.dart';
@@ -63,6 +64,46 @@ void main() {
expect(message.runId, 1);
});
test(
'an artifact transition opens the artifact and carries its metadata',
() async {
final attention = attentionController();
final bridge = FakeNotificationBridge(permission: 'granted');
final notify = NotificationController(
store: MemoryNotificationStore(),
bridge: bridge,
);
addTearDown(attention.dispose);
addTearDown(notify.dispose);
await attention.load();
await notify.load();
NotificationArtifact? opened;
notify.onOpenArtifact = (artifact) => opened = artifact;
attention.seedRows([runSummary(1, 'running')]);
attention.observeFrame(
runFrame(
1,
'failed',
extra: {
'artifact': {
'run_id': 1,
'sequence': 2,
'path': 'docs/a%2Fb.md',
'name': 'a/b.md',
'url': '/artifacts/1/2/public/docs/a%252Fb.md',
'media_type': 'text/markdown',
},
'preview': 'A short preview',
},
),
);
expect(publish(notify, attention), 1);
expect(bridge.shown.single.artifact?.mediaType, 'text/markdown');
bridge.taps.single!.call();
expect(opened?.url, '/artifacts/1/2/public/docs/a%252Fb.md');
},
);
test('a duplicate frame and a republished list stay silent', () async {
final attention = attentionController();
final bridge = FakeNotificationBridge(permission: 'granted');
@@ -49,6 +49,7 @@ Map<String, dynamic> runFrame(
String? title,
String diagnostic = '',
String? finishedAt,
Map<String, dynamic> extra = const {},
}) => {
'type': 'run_event',
'run_id': id,
@@ -62,6 +63,7 @@ Map<String, dynamic> runFrame(
(status == 'waiting' || status == 'running'
? ''
: at(const Duration(minutes: 1))),
...extra,
};
/// One transition for a run that just entered [status], for batch tests.