Remove Cupertino schedules branches
Keep the Material-only schedules implementation while preserving public Cupertino parameters for callers. Remove Cupertino-only test hosts and variants because the app runs every schedule screen under MaterialApp.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -31,7 +30,6 @@ Future<void> pumpScheduleEditor(
|
||||
WidgetTester tester, {
|
||||
required ScheduleDraft draft,
|
||||
required Future<void> Function(JsonMap record) onSubmit,
|
||||
bool cupertino = false,
|
||||
bool dark = false,
|
||||
double width = 390,
|
||||
double height = 1600,
|
||||
@@ -57,21 +55,11 @@ Future<void> pumpScheduleEditor(
|
||||
child: app!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
theme: CupertinoThemeData(
|
||||
brightness: dark ? Brightness.dark : Brightness.light,
|
||||
),
|
||||
builder: scaled,
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: form)),
|
||||
)
|
||||
: MaterialApp(
|
||||
theme: ThemeData(
|
||||
brightness: dark ? Brightness.dark : Brightness.light,
|
||||
),
|
||||
builder: scaled,
|
||||
home: Scaffold(body: SafeArea(child: form)),
|
||||
),
|
||||
MaterialApp(
|
||||
theme: ThemeData(brightness: dark ? Brightness.dark : Brightness.light),
|
||||
builder: scaled,
|
||||
home: Scaffold(body: SafeArea(child: form)),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/schedules/ui/editor/schedule_editor_selectors.dart';
|
||||
import 'package:pipelines_app/features/schedules/ui/editor/schedule_editor_wording.dart';
|
||||
|
||||
import 'schedule_editor_harness.dart';
|
||||
@@ -101,49 +99,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino form uses native fields and action sheets', (
|
||||
tester,
|
||||
) async {
|
||||
final calls = <JsonMap>[];
|
||||
await pumpScheduleEditor(
|
||||
tester,
|
||||
cupertino: true,
|
||||
draft: createDraft(name: 'Cupertino schedule', prompt: 'Native fields'),
|
||||
onSubmit: (record) async => calls.add(record),
|
||||
);
|
||||
expect(find.byType(CupertinoTextField), findsNWidgets(6));
|
||||
expect(find.byType(TextField), findsNothing);
|
||||
expect(find.byType(CupertinoSwitch), findsOneWidget);
|
||||
expect(find.byType(Switch), findsNothing);
|
||||
expect(find.byType(CupertinoCheckbox), findsNWidgets(7));
|
||||
expect(find.byType(Checkbox), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(scheduleEditorTimerKey));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Clock times').last);
|
||||
await tester.pumpAndSettle();
|
||||
await enterField(tester, scheduleEditorTimesKey, '06:30');
|
||||
await tester.tap(find.byKey(scheduleEditorDayKey('mon')));
|
||||
await tester.pump();
|
||||
expect(
|
||||
tester
|
||||
.widget<CupertinoCheckbox>(find.byKey(scheduleEditorDayKey('mon')))
|
||||
.value,
|
||||
isTrue,
|
||||
);
|
||||
await tester.tap(find.byKey(scheduleEditorEnabledKey));
|
||||
await tester.pump();
|
||||
await tester.tap(find.byKey(scheduleEditorSubmitKey));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(calls.single['enabled'], isFalse);
|
||||
expect(calls.single['rule'], {
|
||||
'times': ['06:30'],
|
||||
'days': ['mon'],
|
||||
'timezone': 'Europe/London',
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('Cancel calls the injected callback and sends nothing', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -44,37 +43,4 @@ void main() {
|
||||
);
|
||||
expect(note.size.width, lessThanOrEqualTo(320 - 32));
|
||||
});
|
||||
|
||||
testWidgets('Cupertino dark uses native controls and the native palette', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpScheduleEditor(
|
||||
tester,
|
||||
cupertino: true,
|
||||
dark: true,
|
||||
width: 320,
|
||||
height: 1800,
|
||||
textScale: 2,
|
||||
draft: createDraft(),
|
||||
onSubmit: (JsonMap record) async {},
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
for (final label in _labels) {
|
||||
expect(find.text(label), findsOneWidget, reason: label);
|
||||
}
|
||||
expect(find.byType(CupertinoTextField), findsNWidgets(6));
|
||||
expect(find.byType(CupertinoSwitch), findsOneWidget);
|
||||
expect(find.byType(CupertinoCheckbox), findsNWidgets(7));
|
||||
expect(find.byType(Material), findsNothing);
|
||||
expect(find.byType(TextField), findsNothing);
|
||||
expect(find.byType(Switch), findsNothing);
|
||||
expect(find.byType(Checkbox), findsNothing);
|
||||
|
||||
final context = tester.element(find.byKey(scheduleEditorNameKey));
|
||||
expect(CupertinoTheme.of(context).brightness, Brightness.dark);
|
||||
expect(
|
||||
CupertinoColors.label.resolveFrom(context).toARGB32(),
|
||||
CupertinoColors.label.darkColor.toARGB32(),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
|
||||
@@ -119,23 +118,13 @@ List<JsonMap> longScheduleList(int count) => [
|
||||
),
|
||||
];
|
||||
|
||||
Widget schedulesApp(
|
||||
Widget child, {
|
||||
required bool cupertino,
|
||||
double textScale = 1,
|
||||
}) {
|
||||
Widget schedulesApp(Widget child, {double textScale = 1}) {
|
||||
Widget media(BuildContext context, Widget? app) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: TextScaler.linear(textScale)),
|
||||
child: app!,
|
||||
);
|
||||
if (cupertino) {
|
||||
return CupertinoApp(
|
||||
builder: media,
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: child)),
|
||||
);
|
||||
}
|
||||
return MaterialApp(
|
||||
builder: media,
|
||||
home: Scaffold(body: child),
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'schedule_list_test_support.dart';
|
||||
|
||||
Future<void> pumpSchedules(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
required ApiGateway gateway,
|
||||
ValueChanged<SavedSchedule>? onOpen,
|
||||
double textScale = 1,
|
||||
@@ -22,7 +21,6 @@ Future<void> pumpSchedules(
|
||||
await tester.pumpWidget(
|
||||
schedulesApp(
|
||||
SchedulesScreen(gateway: gateway, onOpen: onOpen ?? (_) {}),
|
||||
cupertino: cupertino,
|
||||
textScale: textScale,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -17,12 +17,7 @@ void main() {
|
||||
pausedRecord(),
|
||||
]),
|
||||
);
|
||||
await pumpSchedules(
|
||||
tester,
|
||||
cupertino: false,
|
||||
gateway: gateway,
|
||||
textScale: textScale,
|
||||
);
|
||||
await pumpSchedules(tester, gateway: gateway, textScale: textScale);
|
||||
|
||||
expect(find.text('2 schedules'), findsOneWidget);
|
||||
// The strip carries the count only; the helper line lives in the
|
||||
@@ -51,10 +46,7 @@ void main() {
|
||||
expect(find.text('Paused'), findsOneWidget);
|
||||
|
||||
expect(find.byKey(scheduleSearchFieldKey), findsOneWidget);
|
||||
expect(
|
||||
find.byType(SegmentedButton<ScheduleListFilter>),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(SegmentedButton<ScheduleListFilter>), findsOneWidget);
|
||||
expect(find.byType(TextField), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
@@ -14,7 +14,7 @@ void main() {
|
||||
(type, fields) async =>
|
||||
schedulesReply([scheduleRecord(), pausedRecord()]),
|
||||
);
|
||||
await pumpSchedules(tester, cupertino: false, gateway: gateway);
|
||||
await pumpSchedules(tester, gateway: gateway);
|
||||
|
||||
await tester.enterText(
|
||||
find.byKey(scheduleSearchFieldKey),
|
||||
@@ -42,7 +42,7 @@ void main() {
|
||||
final gateway = FakeSchedulesGateway(
|
||||
(type, fields) async => schedulesReply(longScheduleList(30)),
|
||||
);
|
||||
await pumpSchedules(tester, cupertino: false, gateway: gateway);
|
||||
await pumpSchedules(tester, gateway: gateway);
|
||||
|
||||
final list = find.byKey(scheduleListKey);
|
||||
await tester.drag(list, const Offset(0, -700));
|
||||
@@ -66,7 +66,7 @@ void main() {
|
||||
if (fail) throw StateError('refresh failed');
|
||||
return schedulesReply(longScheduleList(30));
|
||||
});
|
||||
await pumpSchedules(tester, cupertino: false, gateway: gateway);
|
||||
await pumpSchedules(tester, gateway: gateway);
|
||||
|
||||
final list = find.byKey(scheduleListKey);
|
||||
await tester.drag(list, const Offset(0, -700));
|
||||
@@ -104,7 +104,7 @@ void main() {
|
||||
if (fail) throw StateError('refresh failed');
|
||||
return schedulesReply([scheduleRecord(), pausedRecord()]);
|
||||
});
|
||||
await pumpSchedules(tester, cupertino: false, gateway: gateway);
|
||||
await pumpSchedules(tester, gateway: gateway);
|
||||
|
||||
fail = true;
|
||||
await tester.tap(find.byKey(scheduleRefreshKey));
|
||||
|
||||
@@ -14,7 +14,7 @@ void main() {
|
||||
(type, fields) async =>
|
||||
schedulesReply([scheduleRecord(), pausedRecord()]),
|
||||
);
|
||||
await pumpSchedules(tester, cupertino: false, gateway: gateway);
|
||||
await pumpSchedules(tester, gateway: gateway);
|
||||
|
||||
await tester.enterText(find.byKey(scheduleSearchFieldKey), 'pipeline 7');
|
||||
await tester.pump();
|
||||
@@ -41,7 +41,7 @@ void main() {
|
||||
(type, fields) async =>
|
||||
schedulesReply([scheduleRecord(), pausedRecord()]),
|
||||
);
|
||||
await pumpSchedules(tester, cupertino: false, gateway: gateway);
|
||||
await pumpSchedules(tester, gateway: gateway);
|
||||
|
||||
await tester.tap(
|
||||
find.descendant(
|
||||
@@ -65,12 +65,7 @@ void main() {
|
||||
(type, fields) async => schedulesReply([record]),
|
||||
);
|
||||
final opened = <SavedSchedule>[];
|
||||
await pumpSchedules(
|
||||
tester,
|
||||
cupertino: false,
|
||||
gateway: gateway,
|
||||
onOpen: opened.add,
|
||||
);
|
||||
await pumpSchedules(tester, gateway: gateway, onOpen: opened.add);
|
||||
|
||||
expect(opened, isEmpty);
|
||||
expect(find.text('Add schedule'), findsNothing);
|
||||
@@ -92,14 +87,14 @@ void main() {
|
||||
final empty = FakeSchedulesGateway(
|
||||
(type, fields) async => {'type': 'schedules'},
|
||||
);
|
||||
await pumpSchedules(tester, cupertino: false, gateway: empty);
|
||||
await pumpSchedules(tester, gateway: empty);
|
||||
expect(find.text('No schedules yet.'), findsOneWidget);
|
||||
expect(find.byKey(scheduleRetryKey), findsNothing);
|
||||
|
||||
final unsupported = FakeSchedulesGateway(
|
||||
(type, fields) async => {'type': 'runs'},
|
||||
);
|
||||
await pumpSchedules(tester, cupertino: false, gateway: unsupported);
|
||||
await pumpSchedules(tester, gateway: unsupported);
|
||||
expect(
|
||||
find.textContaining('does not support saved schedules'),
|
||||
findsOneWidget,
|
||||
@@ -110,7 +105,7 @@ void main() {
|
||||
final failed = FakeSchedulesGateway(
|
||||
(type, fields) async => throw StateError('socket closed'),
|
||||
);
|
||||
await pumpSchedules(tester, cupertino: false, gateway: failed);
|
||||
await pumpSchedules(tester, gateway: failed);
|
||||
expect(find.textContaining('socket closed'), findsOneWidget);
|
||||
expect(find.byKey(scheduleRetryKey), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
@@ -122,7 +117,7 @@ void main() {
|
||||
final gateway = FakeSchedulesGateway(
|
||||
(type, fields) async => schedulesReply([pausedRecord()]),
|
||||
);
|
||||
await pumpSchedules(tester, cupertino: false, gateway: gateway);
|
||||
await pumpSchedules(tester, gateway: gateway);
|
||||
|
||||
await tester.tap(
|
||||
find.descendant(
|
||||
@@ -147,12 +142,7 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
final gateway = ControlledSchedulesGateway();
|
||||
await pumpSchedules(
|
||||
tester,
|
||||
cupertino: false,
|
||||
gateway: gateway,
|
||||
settle: false,
|
||||
);
|
||||
await pumpSchedules(tester, gateway: gateway, settle: false);
|
||||
expect(find.byKey(scheduleRefreshKey), findsNothing);
|
||||
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
|
||||
@@ -14,7 +14,6 @@ void main() {
|
||||
'row', (tester) async {
|
||||
await pumpSchedules(
|
||||
tester,
|
||||
cupertino: false,
|
||||
size: const Size(1200, 800),
|
||||
gateway: FakeSchedulesGateway(
|
||||
(type, fields) async => schedulesReply([
|
||||
|
||||
@@ -378,37 +378,31 @@ void main() {
|
||||
expect(find.text('socket closed'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('320px at 2x text stays usable on both native hosts', (
|
||||
tester,
|
||||
) async {
|
||||
for (final cupertino in [false, true]) {
|
||||
final gateway = SectionGateway(
|
||||
(type, fields) async => schedulesReply([
|
||||
sectionRecord(
|
||||
name: 'A very long schedule name that must wrap without overflow',
|
||||
prompt:
|
||||
'A long prompt that also wraps instead of forcing a fixed row '
|
||||
'height or a horizontal scroll.',
|
||||
),
|
||||
]),
|
||||
);
|
||||
await pumpScheduleSection(
|
||||
tester,
|
||||
gateway: gateway,
|
||||
cupertino: cupertino,
|
||||
dark: cupertino,
|
||||
width: 320,
|
||||
height: 844,
|
||||
textScale: 2,
|
||||
);
|
||||
testWidgets('320px at 2x text stays usable', (tester) async {
|
||||
final gateway = SectionGateway(
|
||||
(type, fields) async => schedulesReply([
|
||||
sectionRecord(
|
||||
name: 'A very long schedule name that must wrap without overflow',
|
||||
prompt:
|
||||
'A long prompt that also wraps instead of forcing a fixed row '
|
||||
'height or a horizontal scroll.',
|
||||
),
|
||||
]),
|
||||
);
|
||||
await pumpScheduleSection(
|
||||
tester,
|
||||
gateway: gateway,
|
||||
width: 320,
|
||||
height: 844,
|
||||
textScale: 2,
|
||||
);
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.byKey(scheduleAddKey), findsOneWidget);
|
||||
await _openMenu(tester, 8);
|
||||
expect(find.byKey(scheduleRowEditKey(8)), findsOneWidget);
|
||||
expect(find.byKey(scheduleRowToggleKey(8)), findsOneWidget);
|
||||
expect(find.byKey(scheduleRowDeleteKey(8)), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.byKey(scheduleAddKey), findsOneWidget);
|
||||
await _openMenu(tester, 8);
|
||||
expect(find.byKey(scheduleRowEditKey(8)), findsOneWidget);
|
||||
expect(find.byKey(scheduleRowToggleKey(8)), findsOneWidget);
|
||||
expect(find.byKey(scheduleRowDeleteKey(8)), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -83,12 +82,7 @@ JsonMap sectionRecord({
|
||||
},
|
||||
};
|
||||
|
||||
Widget sectionApp(
|
||||
Widget section, {
|
||||
required bool cupertino,
|
||||
bool dark = false,
|
||||
double textScale = 1,
|
||||
}) {
|
||||
Widget sectionApp(Widget section, {bool dark = false, double textScale = 1}) {
|
||||
Widget media(BuildContext context, Widget? app) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
@@ -98,16 +92,6 @@ Widget sectionApp(
|
||||
final body = SafeArea(
|
||||
child: ListView(children: [section, const SizedBox(height: 24)]),
|
||||
);
|
||||
if (cupertino) {
|
||||
return CupertinoApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: CupertinoThemeData(
|
||||
brightness: dark ? Brightness.dark : Brightness.light,
|
||||
),
|
||||
builder: media,
|
||||
home: CupertinoPageScaffold(child: body),
|
||||
);
|
||||
}
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: ThemeData(brightness: dark ? Brightness.dark : Brightness.light),
|
||||
@@ -119,7 +103,6 @@ Widget sectionApp(
|
||||
Future<void> pumpScheduleSection(
|
||||
WidgetTester tester, {
|
||||
required SectionGateway gateway,
|
||||
bool cupertino = false,
|
||||
bool dark = false,
|
||||
double width = 390,
|
||||
double height = 844,
|
||||
@@ -137,7 +120,7 @@ Future<void> pumpScheduleSection(
|
||||
settingsStore: MemorySettingsStore(workspace: '/srv/research'),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
sectionApp(section, cupertino: cupertino, dark: dark, textScale: textScale),
|
||||
sectionApp(section, dark: dark, textScale: textScale),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
@@ -68,23 +67,15 @@ JsonMap restrictedRunFixture() => {
|
||||
'output_format': 'json',
|
||||
};
|
||||
|
||||
Future<void> pumpAction(
|
||||
WidgetTester tester,
|
||||
Widget child, {
|
||||
bool cupertino = false,
|
||||
}) async {
|
||||
Future<void> pumpAction(WidgetTester tester, Widget child) async {
|
||||
tester.view.physicalSize = const Size(390, 1600);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: child)),
|
||||
)
|
||||
: MaterialApp(
|
||||
home: Scaffold(body: SafeArea(child: child)),
|
||||
),
|
||||
MaterialApp(
|
||||
home: Scaffold(body: SafeArea(child: child)),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
@@ -225,38 +216,4 @@ void main() {
|
||||
await openMenu(runFixture(pipelineId: null));
|
||||
expect(find.text(scheduleRunActionLabel), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino uses the native action and fields', (tester) async {
|
||||
final gateway = SaveGateway();
|
||||
await pumpAction(
|
||||
tester,
|
||||
ScheduleRunAction(run: runFixture(), gateway: gateway),
|
||||
cupertino: true,
|
||||
);
|
||||
|
||||
final action = find.byKey(scheduleRunActionKey);
|
||||
expect(
|
||||
find.widgetWithText(CupertinoButton, scheduleRunActionLabel),
|
||||
findsOne,
|
||||
);
|
||||
await tester.tap(action);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(gateway.calls, isEmpty);
|
||||
expect(find.byKey(scheduleEditorSubmitKey), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<CupertinoTextField>(find.byKey(scheduleEditorVersionKey))
|
||||
.controller
|
||||
?.text,
|
||||
'5',
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<CupertinoTextField>(find.byKey(scheduleEditorWorkspaceKey))
|
||||
.controller
|
||||
?.text,
|
||||
'/srv/run-workspace',
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user