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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user