Files
pipelines/app/test/features/pipelines/pipelines_adaptive_test.dart
T
alan d1b05217c9 Remove Cupertino pipeline branches
Keep the pipeline feature on its existing Material path because the app runs under MaterialApp and never selects Cupertino hosts. Preserve public cupertino parameters and required Cupertino icon values for later cleanup and shared controls.
2026-11-11 04:53:12 +00:00

156 lines
5.6 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../native_back.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 '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);
// The open pipeline is its own page: its bar names it and Back closes it.
expect(find.text('Alpha review'), findsWidgets);
await tester.tap(findNativeBack());
await tester.pumpAndSettle();
expect(find.byKey(const Key('pipeline-list')), findsOneWidget);
expect(find.byKey(const Key('pipeline-detail')), findsNothing);
});
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.byKey(const Key('pipeline-detail-tab-source')),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipeline-detail-tab-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('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.byKey(const Key('pipeline-detail-tab-graph')),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipeline-detail-tab-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),
);
});
}