feat(app): artifact viewer controls float over the content and hide when idle
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_body.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('controls float over the content, hide when idle and return on '
|
||||
'touch', (tester) async {
|
||||
var opened = 0;
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ArtifactControlsOverlay(
|
||||
controls: [
|
||||
TextButton(onPressed: () => opened++, child: const Text('Open')),
|
||||
],
|
||||
child: const SizedBox.expand(child: Text('content')),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
double opacity() => tester
|
||||
.widget<AnimatedOpacity>(
|
||||
find.byKey(const Key('artifact-viewer-controls')),
|
||||
)
|
||||
.opacity;
|
||||
|
||||
// Shown on open, on top of the content without scrolling.
|
||||
expect(opacity(), 1);
|
||||
await tester.tap(find.text('Open'));
|
||||
expect(opened, 1);
|
||||
|
||||
await tester.pump(const Duration(seconds: 4));
|
||||
await tester.pumpAndSettle();
|
||||
expect(opacity(), 0);
|
||||
// Hidden controls take no taps.
|
||||
await tester.tap(find.text('Open'), warnIfMissed: false);
|
||||
expect(opened, 1);
|
||||
|
||||
await tester.tap(find.text('content'));
|
||||
await tester.pump();
|
||||
expect(opacity(), 1);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user