377ff04aaf
Replace the single glass pill (host NavigationBar/CupertinoTabBar with one gliding highlight) with a row of separate circular GlassPill buttons, 52/50 px with 12/10 px gaps, at the same bottom-right place. The selected button fills with the host selection tint and cross-fades; each button pops in on its own, staggered, only when the bar appears or its tabs change; presses sink like the top bar's. Tab semantics, keys, tooltips and badges are kept; the row shares one BackdropGroup for its blurs.
220 lines
7.9 KiB
Dart
220 lines
7.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/ui/layout/app_list_row.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 'package:pipelines_app/ui/adaptive/floating_destination_bar.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('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);
|
|
// The shared list row, in its Cupertino form.
|
|
expect(
|
|
tester
|
|
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
|
|
.cupertino,
|
|
isTrue,
|
|
);
|
|
expect(find.byType(CupertinoActionSheet), findsNothing);
|
|
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
|
await tester.pumpAndSettle();
|
|
// The tabs are the floating glass Cupertino tab bar.
|
|
expect(
|
|
find.descendant(
|
|
of: find.byKey(const Key('pipeline-detail-tabs')),
|
|
matching: find.byType(FloatingDestinationBar),
|
|
),
|
|
findsOneWidget,
|
|
);
|
|
// Versions are the shared row in its Cupertino form, flat on the page.
|
|
expect(
|
|
tester
|
|
.widget<AppListRow>(find.byKey(const Key('pipeline-version-1')))
|
|
.cupertino,
|
|
isTrue,
|
|
);
|
|
expect(find.byType(CupertinoListSection), findsNothing);
|
|
|
|
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.byKey(const Key('pipeline-detail-tab-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.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),
|
|
);
|
|
});
|
|
}
|