194 lines
6.9 KiB
Dart
194 lines
6.9 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/features/graph/widgets/definition_graph_view.dart';
|
|
import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
|
|
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
|
|
import 'package:pipelines_app/features/pipelines/screen.dart';
|
|
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_panel.dart';
|
|
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
|
|
|
|
import 'fixtures.dart';
|
|
import 'test_helpers.dart';
|
|
|
|
void main() {
|
|
testWidgets('narrow layout is list then detail with a native back', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
final fixture = PipelineFixture();
|
|
await tester.pumpWidget(
|
|
MaterialApp(home: PipelinesScreen(gateway: gatewayFor(fixture))),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byKey(const Key('pipeline-list')), findsOneWidget);
|
|
expect(find.byKey(const Key('pipeline-detail')), findsNothing);
|
|
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
|
await tester.pumpAndSettle();
|
|
expect(find.byKey(const Key('pipeline-list')), findsNothing);
|
|
expect(find.byKey(const Key('pipeline-detail')), findsOneWidget);
|
|
|
|
await tester.tap(find.byTooltip('Back to pipelines'));
|
|
await tester.pumpAndSettle();
|
|
expect(find.byKey(const Key('pipeline-list')), findsOneWidget);
|
|
});
|
|
|
|
testWidgets(
|
|
'2x text at 390px keeps list and detail scrollable without overflow',
|
|
(tester) async {
|
|
tester.view.physicalSize = const Size(390, 844);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
final fixture = PipelineFixture();
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
builder: (context, child) => MediaQuery(
|
|
data: MediaQuery.of(
|
|
context,
|
|
).copyWith(textScaler: const TextScaler.linear(2)),
|
|
child: child!,
|
|
),
|
|
home: PipelinesScreen(gateway: gatewayFor(fixture)),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(tester.takeException(), isNull);
|
|
expect(find.text('Alpha review'), findsOneWidget);
|
|
|
|
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
|
await tester.pumpAndSettle();
|
|
expect(tester.takeException(), isNull);
|
|
await tester.ensureVisible(find.text('Source'));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Source'));
|
|
await tester.pumpAndSettle();
|
|
expect(tester.takeException(), isNull);
|
|
expect(
|
|
selectableText(
|
|
'name: Alpha review\nstages:\n review:\n type: model',
|
|
),
|
|
findsOneWidget,
|
|
);
|
|
},
|
|
);
|
|
|
|
testWidgets('wide layout at 2x text renders both panes', (tester) async {
|
|
tester.view.physicalSize = const Size(1100, 900);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
final fixture = PipelineFixture();
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
builder: (context, child) => MediaQuery(
|
|
data: MediaQuery.of(
|
|
context,
|
|
).copyWith(textScaler: const TextScaler.linear(2)),
|
|
child: child!,
|
|
),
|
|
home: PipelinesScreen(gateway: gatewayFor(fixture)),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
|
await tester.pumpAndSettle();
|
|
expect(tester.takeException(), isNull);
|
|
expect(find.byKey(const Key('pipeline-list')), findsOneWidget);
|
|
expect(find.byKey(const Key('pipeline-detail')), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('iOS uses Cupertino scaffolds, list tiles and segmented tabs', (
|
|
tester,
|
|
) async {
|
|
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
|
tester.view.physicalSize = const Size(1100, 900);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
final fixture = PipelineFixture();
|
|
try {
|
|
await tester.pumpWidget(
|
|
CupertinoApp(home: PipelinesScreen(gateway: gatewayFor(fixture))),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
|
|
expect(find.byType(CupertinoListTile), findsWidgets);
|
|
expect(find.byType(CupertinoActionSheet), findsNothing);
|
|
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
|
await tester.pumpAndSettle();
|
|
expect(
|
|
find.byType(CupertinoSegmentedControl<PipelineDetailTab>),
|
|
findsOneWidget,
|
|
);
|
|
expect(find.byType(CupertinoListTile), findsWidgets);
|
|
|
|
await tester.tap(find.byKey(const Key('pipeline-version-1')));
|
|
await tester.pumpAndSettle();
|
|
expect(find.text('Viewing v1 (latest v2).'), findsOneWidget);
|
|
await tester.tap(find.text('Source'));
|
|
await tester.pump();
|
|
expect(
|
|
selectableText(
|
|
'name: Alpha review\nstages:\n review:\n type: model\n'
|
|
'# selected version 1',
|
|
),
|
|
findsOneWidget,
|
|
);
|
|
} finally {
|
|
debugDefaultTargetPlatformOverride = null;
|
|
}
|
|
});
|
|
|
|
testWidgets('3x text in a very short panel keeps the tabs reachable', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(390, 300);
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
final gateway = gatewayFor(PipelineFixture());
|
|
final controller = PipelinesController(PipelinesRepository(gateway));
|
|
addTearDown(controller.dispose);
|
|
await controller.openPipeline(1);
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
builder: (context, child) => MediaQuery(
|
|
data: MediaQuery.of(
|
|
context,
|
|
).copyWith(textScaler: const TextScaler.linear(3)),
|
|
child: child!,
|
|
),
|
|
home: Scaffold(
|
|
body: PipelineDetailPanel(
|
|
controller: controller,
|
|
gateway: gateway,
|
|
showBack: true,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
// The header scrolls instead of squeezing the tab out; the tabs stay
|
|
// reachable inside it and the tab keeps a bounded slot.
|
|
expect(tester.takeException(), isNull);
|
|
await tester.ensureVisible(find.text('Graph'));
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(find.text('Graph'));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
expect(tester.takeException(), isNull);
|
|
expect(find.byType(DefinitionGraphView), findsOneWidget);
|
|
expect(
|
|
tester.getSize(find.byType(DefinitionGraphView)).height,
|
|
greaterThan(0),
|
|
);
|
|
});
|
|
}
|