fix(app): close the artifact viewer with Escape

This commit is contained in:
2026-10-26 18:41:44 +00:00
parent 41a3be8715
commit 56f18acf78
3 changed files with 44 additions and 0 deletions
@@ -4,6 +4,7 @@ import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_body.dart';
import 'package:pipelines_app/features/artifacts/ui/artifact_video_player.dart';
@@ -616,4 +617,37 @@ void main() {
expect(rect.width, greaterThan(0), reason: label);
}
});
testWidgets('Escape closes the viewer back to the gallery', (tester) async {
await tester.pumpWidget(
MaterialApp(
home: ArtifactGalleryPage(
steps: <JsonMap>[
step(
stage: 'review',
visit: 1,
artifacts: [
artifact(
'shot.png',
url: '/artifacts/1/1/shot.png',
contentType: 'image/png',
sizeBytes: 1024,
),
],
),
],
configuredEndpoint: _endpoint,
fetch: (_) async => ArtifactFetchResult(status: 200, bytes: _png),
),
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('shot.png'));
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byType(ArtifactViewerPage), findsNothing);
});
}