2da375ccce
Use the shared anchored choices and bounded details dialogs for diff form and artifact facts while preserving narrow Material sheets. Cover both width branches and dismissal behavior.
75 lines
2.5 KiB
Dart
75 lines
2.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_body.dart';
|
|
import 'package:pipelines_app/features/changes/widgets/diff_form_control.dart';
|
|
|
|
void main() {
|
|
for (final width in [400.0, 1000.0]) {
|
|
testWidgets('diff choices adapt to app width $width', (tester) async {
|
|
tester.view.physicalSize = Size(width, 900);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
DiffForm? selected;
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: Scaffold(
|
|
body: Align(
|
|
alignment: Alignment.topLeft,
|
|
child: Builder(
|
|
builder: (context) => diffFormMenu(
|
|
context,
|
|
form: DiffForm.rendered,
|
|
onChanged: (value) => selected = value,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.tap(find.byTooltip('Diff form'));
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
find.byType(BottomSheet),
|
|
width < 600 ? findsOneWidget : findsNothing,
|
|
);
|
|
expect(
|
|
find.byKey(const ValueKey('app-choice-menu')),
|
|
width >= 600 ? findsOneWidget : findsNothing,
|
|
);
|
|
await tester.tap(find.text('Raw patch'));
|
|
await tester.pumpAndSettle();
|
|
expect(selected, DiffForm.raw);
|
|
expect(find.text('Raw patch'), findsNothing);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
|
|
testWidgets('artifact details adapt to app width $width', (tester) async {
|
|
tester.view.physicalSize = Size(width, 900);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
await tester.pumpWidget(
|
|
const MaterialApp(
|
|
home: Scaffold(
|
|
body: ArtifactViewerInfoAction(
|
|
facts: Text('Recorded artifact facts'),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.tap(find.byTooltip('Details'));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Recorded artifact facts'), findsOneWidget);
|
|
expect(find.byType(Dialog), width >= 600 ? findsOneWidget : findsNothing);
|
|
expect(
|
|
find.byType(BottomSheet),
|
|
width < 600 ? findsOneWidget : findsNothing,
|
|
);
|
|
final context = tester.element(find.text('Recorded artifact facts'));
|
|
Navigator.of(context).pop();
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Recorded artifact facts'), findsNothing);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
}
|
|
}
|