Send artifacts, runs and pipelines to a new or existing chat
One picker offers a new chat (the saved Open in chat harness and model) or any open chat. An existing chat gets the reference appended to its draft and focused, never sent. Artifacts gain the action in their viewer and gallery; the run and pipeline item becomes Send to chat.
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
|
||||
import 'package:pipelines_app/features/artifacts/domain/artifact_chat_context.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_gallery_page.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
|
||||
|
||||
@@ -116,6 +117,98 @@ void main() {
|
||||
expect(_inDialog('Artifacts · 1 recorded'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('artifact details offer Send to chat and pass its reference', (
|
||||
tester,
|
||||
) async {
|
||||
String? draft;
|
||||
final steps = [
|
||||
step(
|
||||
stage: 'build',
|
||||
sequence: 1,
|
||||
visit: 1,
|
||||
artifacts: [
|
||||
_recorded(
|
||||
'build.log',
|
||||
url: '/artifacts/42/1/build.log',
|
||||
contentType: 'text/plain',
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
tester.view.physicalSize = const Size(800, 1000);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: ArtifactGalleryPage(
|
||||
steps: steps,
|
||||
configuredEndpoint: 'http://server.example/connect',
|
||||
artifactChatContext: const ArtifactChatContext(
|
||||
runId: '42',
|
||||
runTitle: 'Build',
|
||||
pipelineName: 'Release',
|
||||
stageKey: 'build',
|
||||
visit: 1,
|
||||
configuredEndpoint: 'http://server.example/connect',
|
||||
),
|
||||
onSendToChat: (value) => draft = value,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.text('build.log'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('artifact-send-to-chat')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(draft, contains('build.log'));
|
||||
expect(draft, contains('pipelines inspect 42'));
|
||||
});
|
||||
|
||||
testWidgets('artifact viewer offers Send to chat', (tester) async {
|
||||
String? draft;
|
||||
final steps = [
|
||||
step(
|
||||
stage: 'build',
|
||||
sequence: 1,
|
||||
visit: 1,
|
||||
artifacts: [
|
||||
_recorded(
|
||||
'build.log',
|
||||
url: '/artifacts/42/1/build.log',
|
||||
contentType: 'text/plain',
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: ArtifactGalleryPage(
|
||||
steps: steps,
|
||||
configuredEndpoint: 'http://server.example/connect',
|
||||
artifactChatContext: const ArtifactChatContext(
|
||||
runId: '42',
|
||||
runTitle: 'Build',
|
||||
pipelineName: 'Release',
|
||||
stageKey: 'build',
|
||||
visit: 1,
|
||||
configuredEndpoint: 'http://server.example/connect',
|
||||
),
|
||||
onSendToChat: (value) => draft = value,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.text('build.log'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(const Key('artifact-send-to-chat')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(draft, contains('build.log'));
|
||||
});
|
||||
|
||||
testWidgets('capture notes and partial label come from the visit step', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -9,11 +9,13 @@ import 'package:pipelines_app/features/artifacts/ui/artifact_video_player.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
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/domain/gallery_navigation.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 ArtifactPreviewBody, artifactPreviewRetryKey;
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_fetch.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_bar.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_page.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||
@@ -44,6 +46,7 @@ Future<void> _pumpViewer(
|
||||
ArtifactFetch? fetch,
|
||||
Widget Function(BuildContext, String)? markdownBuilder,
|
||||
ArtifactExternalOpen? openExternal,
|
||||
ValueChanged<PagedArtifact>? onSendToChat,
|
||||
double bottomClearance = 0,
|
||||
}) async {
|
||||
final page = ArtifactViewerPage(
|
||||
@@ -54,6 +57,7 @@ Future<void> _pumpViewer(
|
||||
markdownBuilder:
|
||||
markdownBuilder ?? (context, value) => SelectableText(value),
|
||||
openExternal: openExternal ?? (_) async => true,
|
||||
onSendToChat: onSendToChat,
|
||||
);
|
||||
final child = MediaQuery(
|
||||
data: MediaQueryData(padding: EdgeInsets.only(bottom: bottomClearance)),
|
||||
@@ -393,10 +397,12 @@ void main() {
|
||||
_group([second], visit: 2),
|
||||
_group([third], visit: 3),
|
||||
];
|
||||
String? sent;
|
||||
await _pumpViewer(
|
||||
tester,
|
||||
groups: groups,
|
||||
selected: artifactVisitIdentity(groups[0], first),
|
||||
onSendToChat: (page) => sent = page.artifact.name,
|
||||
);
|
||||
|
||||
expect(find.text('1 of 3 · image/png'), findsOneWidget);
|
||||
@@ -413,6 +419,8 @@ void main() {
|
||||
await tester.tap(find.byKey(artifactNextKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('2 of 3 · image/png'), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('artifact-send-to-chat')));
|
||||
expect(sent, 'b.png');
|
||||
await showFacts(tester);
|
||||
expect(find.text('review · visit 2'), findsOneWidget);
|
||||
await hideFacts(tester);
|
||||
|
||||
Reference in New Issue
Block a user