Remove Cupertino branches from Settings
Keep the Material-only settings implementation and its focused tests while preserving public cupertino parameters for later cleanup. This removes unreachable platform-specific widgets and test variants without changing the Material path.
This commit is contained in:
@@ -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/servers/server_catalog.dart';
|
||||
@@ -26,20 +25,13 @@ class _ControlledStore extends MemoryServerCatalogStore {
|
||||
|
||||
Future<void> _openEditor(
|
||||
WidgetTester tester,
|
||||
ServerConnections connections,
|
||||
bool cupertino, {
|
||||
ServerConnections connections, {
|
||||
bool edit = false,
|
||||
}) async {
|
||||
final body = SingleChildScrollView(
|
||||
child: SavedServersSection(connections: connections),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: body)),
|
||||
)
|
||||
: MaterialApp(home: Scaffold(body: body)),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: body)));
|
||||
if (edit) await openSavedServerMenu(tester);
|
||||
await tester.tap(find.text(edit ? 'Edit Home' : 'Add server'));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -56,125 +48,114 @@ Future<void> _openEditor(
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('Back cancels an unsaved draft ($cupertino)', (tester) async {
|
||||
testWidgets('Back cancels an unsaved draft', (tester) async {
|
||||
final store = _ControlledStore();
|
||||
final connections = ServerConnections(
|
||||
store: store,
|
||||
onSelected: (_) async => fail('Cancel must not select a server'),
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
await _openEditor(tester, connections);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('server-profile-name')), findsNothing);
|
||||
expect(store.writes, isEmpty);
|
||||
expect(connections.catalog.servers, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('failed edit keeps draft and blocks duplicate save', (
|
||||
tester,
|
||||
) async {
|
||||
final original = SavedServer.validated(
|
||||
id: 'home',
|
||||
name: 'Home',
|
||||
endpoints: ['wss://home.test/connect'],
|
||||
);
|
||||
final store = _ControlledStore(
|
||||
catalog: ServerCatalog(servers: [original], selectedId: original.id),
|
||||
)..pending = Completer<bool>();
|
||||
final activations = <SavedServer?>[];
|
||||
final connections = ServerConnections(
|
||||
store: store,
|
||||
onSelected: (server) async => activations.add(server),
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
await _openEditor(tester, connections, edit: true);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Saving server…'), findsOneWidget);
|
||||
final button = find.widgetWithText(FilledButton, 'Saving server…');
|
||||
expect(tester.widget<FilledButton>(button).onPressed, isNull);
|
||||
await tester.tap(find.text('Saving server…'));
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('server-profile-name')), findsOneWidget);
|
||||
expect(store.writes, hasLength(1));
|
||||
expect(connections.catalog.active?.name, 'Home');
|
||||
expect(activations, isEmpty);
|
||||
|
||||
store.pending!.complete(false);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('could not be saved'), findsOneWidget);
|
||||
final name = tester.widget<EditableText>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('server-profile-name')),
|
||||
matching: find.byType(EditableText),
|
||||
),
|
||||
);
|
||||
final addresses = tester.widget<EditableText>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('server-profile-addresses')),
|
||||
matching: find.byType(EditableText),
|
||||
),
|
||||
);
|
||||
expect(name.controller.text, 'My home');
|
||||
expect(addresses.controller.text, contains('ws://192.168.1.2:8083'));
|
||||
expect(connections.catalog.active?.name, 'Home');
|
||||
|
||||
store.pending = null;
|
||||
await tester.ensureVisible(find.text('Save server'));
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('server-profile-name')), findsNothing);
|
||||
expect(connections.catalog.active?.name, 'My home');
|
||||
expect(store.catalog?.active?.endpoints, hasLength(2));
|
||||
expect(store.writes, hasLength(2));
|
||||
expect(activations.single?.id, original.id);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'activation failure retry does not duplicate new profile',
|
||||
(tester) async {
|
||||
final store = _ControlledStore();
|
||||
var attempts = 0;
|
||||
final connections = ServerConnections(
|
||||
store: store,
|
||||
onSelected: (_) async => fail('Cancel must not select a server'),
|
||||
onSelected: (_) async {
|
||||
if (++attempts == 1) throw StateError('Connection unavailable');
|
||||
},
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
await _openEditor(tester, connections, cupertino);
|
||||
await tester.binding.handlePopRoute();
|
||||
await connections.load();
|
||||
await _openEditor(tester, connections);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('Connection unavailable'), findsOneWidget);
|
||||
expect(find.byKey(const Key('server-profile-name')), findsOneWidget);
|
||||
expect(store.catalog?.servers, hasLength(1));
|
||||
final savedId = store.catalog!.servers.single.id;
|
||||
|
||||
await tester.ensureVisible(find.text('Save server'));
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(attempts, 2);
|
||||
expect(store.catalog?.servers, hasLength(1));
|
||||
expect(store.catalog?.servers.single.id, savedId);
|
||||
expect(find.byKey(const Key('server-profile-name')), findsNothing);
|
||||
expect(store.writes, isEmpty);
|
||||
expect(connections.catalog.servers, isEmpty);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'failed edit keeps draft and blocks duplicate save ($cupertino)',
|
||||
(tester) async {
|
||||
final original = SavedServer.validated(
|
||||
id: 'home',
|
||||
name: 'Home',
|
||||
endpoints: ['wss://home.test/connect'],
|
||||
);
|
||||
final store = _ControlledStore(
|
||||
catalog: ServerCatalog(servers: [original], selectedId: original.id),
|
||||
)..pending = Completer<bool>();
|
||||
final activations = <SavedServer?>[];
|
||||
final connections = ServerConnections(
|
||||
store: store,
|
||||
onSelected: (server) async => activations.add(server),
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
await _openEditor(tester, connections, cupertino, edit: true);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Saving server…'), findsOneWidget);
|
||||
final button = find.widgetWithText(
|
||||
cupertino ? CupertinoButton : FilledButton,
|
||||
'Saving server…',
|
||||
);
|
||||
expect(
|
||||
cupertino
|
||||
? tester.widget<CupertinoButton>(button).onPressed
|
||||
: tester.widget<FilledButton>(button).onPressed,
|
||||
isNull,
|
||||
);
|
||||
await tester.tap(find.text('Saving server…'));
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('server-profile-name')), findsOneWidget);
|
||||
expect(store.writes, hasLength(1));
|
||||
expect(connections.catalog.active?.name, 'Home');
|
||||
expect(activations, isEmpty);
|
||||
|
||||
store.pending!.complete(false);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('could not be saved'), findsOneWidget);
|
||||
final name = tester.widget<EditableText>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('server-profile-name')),
|
||||
matching: find.byType(EditableText),
|
||||
),
|
||||
);
|
||||
final addresses = tester.widget<EditableText>(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('server-profile-addresses')),
|
||||
matching: find.byType(EditableText),
|
||||
),
|
||||
);
|
||||
expect(name.controller.text, 'My home');
|
||||
expect(addresses.controller.text, contains('ws://192.168.1.2:8083'));
|
||||
expect(connections.catalog.active?.name, 'Home');
|
||||
|
||||
store.pending = null;
|
||||
await tester.ensureVisible(find.text('Save server'));
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('server-profile-name')), findsNothing);
|
||||
expect(connections.catalog.active?.name, 'My home');
|
||||
expect(store.catalog?.active?.endpoints, hasLength(2));
|
||||
expect(store.writes, hasLength(2));
|
||||
expect(activations.single?.id, original.id);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'activation failure retry does not duplicate new profile ($cupertino)',
|
||||
(tester) async {
|
||||
final store = _ControlledStore();
|
||||
var attempts = 0;
|
||||
final connections = ServerConnections(
|
||||
store: store,
|
||||
onSelected: (_) async {
|
||||
if (++attempts == 1) throw StateError('Connection unavailable');
|
||||
},
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
await _openEditor(tester, connections, cupertino);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.textContaining('Connection unavailable'), findsOneWidget);
|
||||
expect(find.byKey(const Key('server-profile-name')), findsOneWidget);
|
||||
expect(store.catalog?.servers, hasLength(1));
|
||||
final savedId = store.catalog!.servers.single.id;
|
||||
|
||||
await tester.ensureVisible(find.text('Save server'));
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(attempts, 2);
|
||||
expect(store.catalog?.servers, hasLength(1));
|
||||
expect(store.catalog?.servers.single.id, savedId);
|
||||
expect(find.byKey(const Key('server-profile-name')), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
expect(tester.takeException(), isNull);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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/servers/server_catalog.dart';
|
||||
@@ -108,95 +107,79 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('add, edit and select ordered server aliases ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
final calls = <String?>[];
|
||||
final connections = ServerConnections(
|
||||
store: MemoryServerCatalogStore(),
|
||||
onSelected: (s) async => calls.add(s?.id),
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
final body = SingleChildScrollView(
|
||||
child: SavedServersSection(connections: connections),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: body)),
|
||||
)
|
||||
: MaterialApp(home: Scaffold(body: body)),
|
||||
);
|
||||
await tester.tap(find.text('Add server'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-name')),
|
||||
'Home',
|
||||
);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-addresses')),
|
||||
'wss://tail.example/connect\nws://192.168.1.2:8083/connect',
|
||||
);
|
||||
await revealSave(tester);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(connections.catalog.active?.name, 'Home');
|
||||
expect(connections.catalog.active?.endpoints, [
|
||||
'wss://tail.example/connect',
|
||||
'ws://192.168.1.2:8083/connect',
|
||||
]);
|
||||
expect(
|
||||
find.text('Backup address: ws://192.168.1.2:8083/connect'),
|
||||
findsOneWidget,
|
||||
);
|
||||
await openSavedServerMenu(tester);
|
||||
await tester.tap(find.text('Edit Home'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-name')),
|
||||
'My home',
|
||||
);
|
||||
await revealSave(tester);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(connections.catalog.active?.name, 'My home');
|
||||
expect(calls, hasLength(2));
|
||||
expect(calls.first, calls.last);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
testWidgets('add, edit and select ordered server aliases', (tester) async {
|
||||
final calls = <String?>[];
|
||||
final connections = ServerConnections(
|
||||
store: MemoryServerCatalogStore(),
|
||||
onSelected: (s) async => calls.add(s?.id),
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
final body = SingleChildScrollView(
|
||||
child: SavedServersSection(connections: connections),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: body)));
|
||||
await tester.tap(find.text('Add server'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-name')),
|
||||
'Home',
|
||||
);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-addresses')),
|
||||
'wss://tail.example/connect\nws://192.168.1.2:8083/connect',
|
||||
);
|
||||
await revealSave(tester);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(connections.catalog.active?.name, 'Home');
|
||||
expect(connections.catalog.active?.endpoints, [
|
||||
'wss://tail.example/connect',
|
||||
'ws://192.168.1.2:8083/connect',
|
||||
]);
|
||||
expect(
|
||||
find.text('Backup address: ws://192.168.1.2:8083/connect'),
|
||||
findsOneWidget,
|
||||
);
|
||||
await openSavedServerMenu(tester);
|
||||
await tester.tap(find.text('Edit Home'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-name')),
|
||||
'My home',
|
||||
);
|
||||
await revealSave(tester);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(connections.catalog.active?.name, 'My home');
|
||||
expect(calls, hasLength(2));
|
||||
expect(calls.first, calls.last);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('invalid server addresses stay in editor ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
final connections = ServerConnections(
|
||||
store: MemoryServerCatalogStore(),
|
||||
onSelected: (_) async {},
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
final body = SavedServersSection(connections: connections);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
||||
: MaterialApp(home: Scaffold(body: body)),
|
||||
);
|
||||
await tester.tap(find.text('Add server'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-name')),
|
||||
'Home',
|
||||
);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-addresses')),
|
||||
'not-a-url',
|
||||
);
|
||||
await revealSave(tester);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('server-profile-addresses')), findsOneWidget);
|
||||
expect(connections.catalog.servers, isEmpty);
|
||||
expect(find.textContaining('valid URL'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
testWidgets('invalid server addresses stay in editor', (tester) async {
|
||||
final connections = ServerConnections(
|
||||
store: MemoryServerCatalogStore(),
|
||||
onSelected: (_) async {},
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
final body = SavedServersSection(connections: connections);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: body)));
|
||||
await tester.tap(find.text('Add server'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-name')),
|
||||
'Home',
|
||||
);
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('server-profile-addresses')),
|
||||
'not-a-url',
|
||||
);
|
||||
await revealSave(tester);
|
||||
await tester.tap(find.text('Save server'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('server-profile-addresses')), findsOneWidget);
|
||||
expect(connections.catalog.servers, isEmpty);
|
||||
expect(find.textContaining('valid URL'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -18,47 +17,31 @@ class _Store implements AnimationSpeedStore {
|
||||
|
||||
void main() {
|
||||
tearDown(() => timeDilation = 1);
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'native slider updates global speed and Reset restores normal ($cupertino)',
|
||||
(tester) async {
|
||||
final store = _Store();
|
||||
final controller = AnimationSpeedController(store: store);
|
||||
final section = SettingsAnimationSection(controller: controller);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: SingleChildScrollView(child: section),
|
||||
),
|
||||
)
|
||||
: MaterialApp(
|
||||
home: Scaffold(body: SingleChildScrollView(child: section)),
|
||||
),
|
||||
);
|
||||
if (cupertino) {
|
||||
final slider = tester.widget<CupertinoSlider>(
|
||||
find.byType(CupertinoSlider),
|
||||
);
|
||||
slider.onChanged!(1.8);
|
||||
slider.onChangeEnd!(1.8);
|
||||
} else {
|
||||
final slider = tester.widget<Slider>(find.byType(Slider));
|
||||
slider.onChanged!(1.8);
|
||||
slider.onChangeEnd!(1.8);
|
||||
}
|
||||
await tester.pump();
|
||||
expect(find.text('1.8×'), findsWidgets);
|
||||
expect(timeDilation, closeTo(1 / 1.8, 0.001));
|
||||
expect(store.saved, 1.8);
|
||||
await tester.tap(find.text('Reset'));
|
||||
await tester.pump();
|
||||
expect(controller.speed, 1);
|
||||
expect(timeDilation, 1);
|
||||
expect(store.saved, 1);
|
||||
expect(tester.takeException(), isNull);
|
||||
controller.dispose();
|
||||
},
|
||||
);
|
||||
}
|
||||
testWidgets(
|
||||
'layout slider updates global speed and Reset restores normal',
|
||||
(tester) async {
|
||||
final store = _Store();
|
||||
final controller = AnimationSpeedController(store: store);
|
||||
final section = SettingsAnimationSection(controller: controller);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(body: SingleChildScrollView(child: section)),
|
||||
),
|
||||
);
|
||||
final slider = tester.widget<Slider>(find.byType(Slider));
|
||||
slider.onChanged!(1.8);
|
||||
slider.onChangeEnd!(1.8);
|
||||
await tester.pump();
|
||||
expect(find.text('1.8×'), findsWidgets);
|
||||
expect(timeDilation, closeTo(1 / 1.8, 0.001));
|
||||
expect(store.saved, 1.8);
|
||||
await tester.tap(find.text('Reset'));
|
||||
await tester.pump();
|
||||
expect(controller.speed, 1);
|
||||
expect(timeDilation, 1);
|
||||
expect(store.saved, 1);
|
||||
expect(tester.takeException(), isNull);
|
||||
controller.dispose();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_custom_font_actions.dart';
|
||||
@@ -12,7 +11,6 @@ import 'package:pipelines_app/features/settings/settings_row.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_font.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_font_controller.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_font_store.dart';
|
||||
import 'package:pipelines_app/ui/theme/custom_fonts/custom_font.dart';
|
||||
import 'package:pipelines_app/ui/theme/custom_fonts/custom_font_draft.dart';
|
||||
import 'package:pipelines_app/ui/theme/custom_fonts/custom_font_library.dart';
|
||||
import 'package:pipelines_app/ui/theme/custom_fonts/font_bytes_store.dart';
|
||||
@@ -42,7 +40,6 @@ class _Harness {
|
||||
Future<void> _pump(
|
||||
WidgetTester tester,
|
||||
_Harness harness, {
|
||||
bool cupertino = false,
|
||||
FontFilePicker? pick,
|
||||
}) async {
|
||||
final section = SingleChildScrollView(
|
||||
@@ -51,11 +48,7 @@ Future<void> _pump(
|
||||
pickFiles: pick ?? harness.pick,
|
||||
),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: section))
|
||||
: MaterialApp(home: Scaffold(body: section)),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: section)));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
@@ -243,35 +236,4 @@ void main() {
|
||||
final row = tester.widget<SettingsRow>(find.byKey(settingsAddFontKey));
|
||||
expect(row.enabled, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino: an added font has the checkmark and options', (
|
||||
tester,
|
||||
) async {
|
||||
final harness = _Harness()..next = <PickedFontFile>[regular];
|
||||
await _pump(tester, harness, cupertino: true);
|
||||
await tester.tap(find.text(addCustomFontText));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Add'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final CustomFont font = harness.fonts.customFonts.single;
|
||||
final row = find.byKey(settingsFontKey(font));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: row,
|
||||
matching: find.byIcon(CupertinoIcons.check_mark),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
// The options button is its own control beside the row.
|
||||
expect(find.bySemanticsLabel(customFontActionsTooltip), findsOneWidget);
|
||||
await tester.tap(find.byIcon(CupertinoIcons.ellipsis_circle));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text(removeCustomFontText));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.widgetWithText(CupertinoDialogAction, 'Remove'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(harness.fonts.customFonts, isEmpty);
|
||||
expect(harness.fonts.selected, AppFont.system);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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/features/notification_service/notification_service_bridge.dart';
|
||||
@@ -8,7 +7,6 @@ import '../notification_service/fake_notification_service.dart';
|
||||
|
||||
Widget _host(
|
||||
NotificationServiceBridge bridge, {
|
||||
required bool cupertino,
|
||||
Future<void> Function()? requestPermission,
|
||||
}) {
|
||||
final body = SingleChildScrollView(
|
||||
@@ -17,59 +15,44 @@ Widget _host(
|
||||
requestNotificationPermission: requestPermission,
|
||||
),
|
||||
);
|
||||
return cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
||||
: MaterialApp(home: Scaffold(body: body));
|
||||
return MaterialApp(home: Scaffold(body: body));
|
||||
}
|
||||
|
||||
bool _switchValue(WidgetTester tester, {required bool cupertino}) {
|
||||
bool _switchValue(WidgetTester tester) {
|
||||
final tile = find.byKey(DeviceDeliveryKeys.toggle);
|
||||
if (cupertino) {
|
||||
return tester
|
||||
.widget<CupertinoSwitch>(
|
||||
find.descendant(of: tile, matching: find.byType(CupertinoSwitch)),
|
||||
)
|
||||
.value;
|
||||
}
|
||||
return tester.widget<SwitchListTile>(tile).value;
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final style = cupertino ? 'Cupertino' : 'Material';
|
||||
testWidgets('shows the switch, status and ntfy note', (tester) async {
|
||||
final service = FakeNotificationService();
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(deviceDeliverySwitchLabel), findsOneWidget);
|
||||
expect(_switchValue(tester), isTrue);
|
||||
expect(find.text('Connected'), findsOneWidget);
|
||||
expect(find.text(deviceDeliveryNote), findsOneWidget);
|
||||
expect(find.text(deviceDeliveryBatteryLabel), findsOneWidget);
|
||||
expect(find.byKey(DeviceDeliveryKeys.permission), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$style shows the switch, status and ntfy note', (
|
||||
tester,
|
||||
) async {
|
||||
final service = FakeNotificationService();
|
||||
await tester.pumpWidget(_host(service, cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(deviceDeliverySwitchLabel), findsOneWidget);
|
||||
expect(_switchValue(tester, cupertino: cupertino), isTrue);
|
||||
expect(find.text('Connected'), findsOneWidget);
|
||||
expect(find.text(deviceDeliveryNote), findsOneWidget);
|
||||
expect(find.text(deviceDeliveryBatteryLabel), findsOneWidget);
|
||||
expect(find.byKey(DeviceDeliveryKeys.permission), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$style switching off stops delivery', (tester) async {
|
||||
final service = FakeNotificationService();
|
||||
await tester.pumpWidget(_host(service, cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(DeviceDeliveryKeys.toggle));
|
||||
await tester.pumpAndSettle();
|
||||
expect(service.calls.last.$1, 'setEnabled');
|
||||
expect(service.calls.last.$2, {'enabled': false});
|
||||
expect(_switchValue(tester, cupertino: cupertino), isFalse);
|
||||
expect(find.text('Off'), findsOneWidget);
|
||||
// The grants only matter while delivery is on.
|
||||
expect(find.text(deviceDeliveryBatteryLabel), findsNothing);
|
||||
});
|
||||
}
|
||||
testWidgets('switching off stops delivery', (tester) async {
|
||||
final service = FakeNotificationService();
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(DeviceDeliveryKeys.toggle));
|
||||
await tester.pumpAndSettle();
|
||||
expect(service.calls.last.$1, 'setEnabled');
|
||||
expect(service.calls.last.$2, {'enabled': false});
|
||||
expect(_switchValue(tester), isFalse);
|
||||
expect(find.text('Off'), findsOneWidget);
|
||||
// The grants only matter while delivery is on.
|
||||
expect(find.text(deviceDeliveryBatteryLabel), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('live status pushed by the service is shown', (tester) async {
|
||||
final service = FakeNotificationService();
|
||||
await tester.pumpWidget(_host(service, cupertino: false));
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
service.push(service.copy(state: DeliveryState.reconnecting));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -80,7 +63,7 @@ void main() {
|
||||
tester,
|
||||
) async {
|
||||
final service = FakeNotificationService();
|
||||
await tester.pumpWidget(_host(service, cupertino: false));
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text(deviceDeliveryBatteryLabel));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -103,7 +86,6 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
_host(
|
||||
service,
|
||||
cupertino: false,
|
||||
requestPermission: () async {
|
||||
asked++;
|
||||
service.current = service.copy(notificationsAllowed: true);
|
||||
@@ -128,7 +110,7 @@ void main() {
|
||||
notificationsAllowed: false,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
_host(service, cupertino: false, requestPermission: () async => asked++),
|
||||
_host(service, requestPermission: () async => asked++),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(DeviceDeliveryKeys.toggle));
|
||||
@@ -139,7 +121,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('a failing platform is reported, not hidden', (tester) async {
|
||||
await tester.pumpWidget(_host(_FailingService(), cupertino: false));
|
||||
await tester.pumpWidget(_host(_FailingService()));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(DeviceDeliveryKeys.error), findsOneWidget);
|
||||
});
|
||||
|
||||
@@ -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/features/settings/settings_font_section.dart';
|
||||
@@ -29,19 +28,11 @@ class _Harness {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _pump(
|
||||
WidgetTester tester,
|
||||
_Harness harness, {
|
||||
bool cupertino = false,
|
||||
}) async {
|
||||
Future<void> _pump(WidgetTester tester, _Harness harness) async {
|
||||
final section = SingleChildScrollView(
|
||||
child: SettingsFontSection(controller: harness.fonts),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: section))
|
||||
: MaterialApp(home: Scaffold(body: section)),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: section)));
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
@@ -102,28 +93,6 @@ void main() {
|
||||
expect(harness.fonts.family, 'Source Sans 3');
|
||||
});
|
||||
|
||||
testWidgets('Cupertino: the chosen row carries the checkmark', (
|
||||
tester,
|
||||
) async {
|
||||
final harness = _Harness();
|
||||
await _pump(tester, harness, cupertino: true);
|
||||
|
||||
expect(find.byType(RadioListTile<FontChoice>), findsNothing);
|
||||
expect(_familyOf(tester, AppFont.system), 'CupertinoSystemText');
|
||||
Finder check(AppFont font) => find.descendant(
|
||||
of: find.byKey(settingsFontKey(font)),
|
||||
matching: find.byIcon(CupertinoIcons.check_mark),
|
||||
);
|
||||
expect(check(AppFont.system), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('Inter'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(check(AppFont.system), findsNothing);
|
||||
expect(check(AppFont.inter), findsOneWidget);
|
||||
expect(harness.store.id, AppFont.inter.id);
|
||||
expect(harness.fonts.family, 'Inter');
|
||||
});
|
||||
|
||||
testWidgets('a failed save is said under the group', (tester) async {
|
||||
final harness = _Harness();
|
||||
harness.store.failSaves = true;
|
||||
|
||||
@@ -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/servers/server_catalog.dart';
|
||||
@@ -15,7 +14,6 @@ import 'package:pipelines_app/features/settings/settings_layout.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_screen.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_store.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_trust_warning.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||
|
||||
import 'fake_channel.dart';
|
||||
import 'settings_topic_test_helper.dart';
|
||||
@@ -94,29 +92,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino uses inset-grouped sections on the grouped page', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, cupertino: true);
|
||||
|
||||
expect(find.byType(Card), findsNothing);
|
||||
expect(find.byType(CupertinoListSection), findsWidgets);
|
||||
for (final section in tester.widgetList<CupertinoListSection>(
|
||||
find.byType(CupertinoListSection),
|
||||
)) {
|
||||
expect(section.type, CupertinoListSectionType.insetGrouped);
|
||||
}
|
||||
final context = tester.element(find.byType(SettingsGroup).first);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) =>
|
||||
widget is ColoredBox &&
|
||||
widget.color == AppColors.groupedBackground.resolveFrom(context),
|
||||
),
|
||||
findsWidgets,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('the notification tile is the section\'s only title', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -131,77 +106,54 @@ void main() {
|
||||
expect(find.text('Connection').last, findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino keeps the compact secondary field label', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, cupertino: true);
|
||||
|
||||
final label = tester.widget<Text>(find.text('Server URL'));
|
||||
final context = tester.element(find.text('Server URL'));
|
||||
expect(
|
||||
label.style?.color,
|
||||
CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
testWidgets('server rows show which server is selected', (tester) async {
|
||||
final connections = ServerConnections(
|
||||
store: MemoryServerCatalogStore(
|
||||
catalog: ServerCatalog(
|
||||
servers: [
|
||||
SavedServer.validated(
|
||||
id: 'Home',
|
||||
name: 'Home',
|
||||
endpoints: const ['wss://home.test/connect'],
|
||||
),
|
||||
SavedServer.validated(
|
||||
id: 'Work',
|
||||
name: 'Work',
|
||||
endpoints: const ['wss://work.test/connect'],
|
||||
),
|
||||
],
|
||||
selectedId: 'Home',
|
||||
),
|
||||
),
|
||||
onSelected: (_) async {},
|
||||
);
|
||||
expect(find.byType(CupertinoTextField), findsNWidgets(2));
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
final body = SingleChildScrollView(
|
||||
child: SavedServersSection(connections: connections),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: body)));
|
||||
|
||||
expect(find.byType(SavedServerRow), findsNWidgets(2));
|
||||
expect(find.text('Pipelines and runs server'), findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) => widget is Icon && widget.semanticLabel == 'Selected',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Address: wss://work.test/connect'), findsOneWidget);
|
||||
expect(find.byKey(savedServerMenuKey('Home')), findsOneWidget);
|
||||
expect(find.text('Add server'), findsOneWidget);
|
||||
// Tapping another server's row uses it.
|
||||
await tester.tap(find.text('Work'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(connections.catalog.active?.id, 'Work');
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('server rows show which server is selected ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
final connections = ServerConnections(
|
||||
store: MemoryServerCatalogStore(
|
||||
catalog: ServerCatalog(
|
||||
servers: [
|
||||
SavedServer.validated(
|
||||
id: 'Home',
|
||||
name: 'Home',
|
||||
endpoints: const ['wss://home.test/connect'],
|
||||
),
|
||||
SavedServer.validated(
|
||||
id: 'Work',
|
||||
name: 'Work',
|
||||
endpoints: const ['wss://work.test/connect'],
|
||||
),
|
||||
],
|
||||
selectedId: 'Home',
|
||||
),
|
||||
),
|
||||
onSelected: (_) async {},
|
||||
);
|
||||
addTearDown(connections.dispose);
|
||||
await connections.load();
|
||||
final body = SingleChildScrollView(
|
||||
child: SavedServersSection(connections: connections),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
||||
: MaterialApp(home: Scaffold(body: body)),
|
||||
);
|
||||
|
||||
expect(find.byType(SavedServerRow), findsNWidgets(2));
|
||||
expect(find.text('Pipelines and runs server'), findsOneWidget);
|
||||
expect(
|
||||
find.byWidgetPredicate(
|
||||
(widget) => widget is Icon && widget.semanticLabel == 'Selected',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Address: wss://work.test/connect'), findsOneWidget);
|
||||
expect(find.byKey(savedServerMenuKey('Home')), findsOneWidget);
|
||||
expect(find.text('Add server'), findsOneWidget);
|
||||
// Tapping another server's row uses it.
|
||||
await tester.tap(find.text('Work'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(connections.catalog.active?.id, 'Work');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _pump(
|
||||
WidgetTester tester, {
|
||||
bool cupertino = false,
|
||||
NotificationController? notifications,
|
||||
Size size = const Size(800, 1600),
|
||||
double topPadding = 0,
|
||||
@@ -224,15 +176,10 @@ Future<void> _pump(
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
builder: padded,
|
||||
home: CupertinoPageScaffold(child: screen),
|
||||
)
|
||||
: MaterialApp(
|
||||
builder: padded,
|
||||
home: Scaffold(body: screen),
|
||||
),
|
||||
MaterialApp(
|
||||
builder: padded,
|
||||
home: Scaffold(body: screen),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
@@ -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';
|
||||
@@ -33,120 +32,96 @@ JsonMap _reply(bool run, bool needs, bool reply) => {
|
||||
},
|
||||
};
|
||||
|
||||
Widget _host(ApiGateway gateway, {required bool cupertino}) {
|
||||
Widget _host(ApiGateway gateway) {
|
||||
final body = SingleChildScrollView(
|
||||
child: SettingsNtfySection(gateway: gateway, connected: true),
|
||||
);
|
||||
return cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: body))
|
||||
: MaterialApp(home: Scaffold(body: body));
|
||||
return MaterialApp(home: Scaffold(body: body));
|
||||
}
|
||||
|
||||
bool _checked(WidgetTester tester, String key, {required bool cupertino}) {
|
||||
bool _checked(WidgetTester tester, String key) {
|
||||
final tile = find.byKey(ntfySettingKey(key));
|
||||
if (cupertino) {
|
||||
return tester
|
||||
.widget<CupertinoSwitch>(
|
||||
find.descendant(of: tile, matching: find.byType(CupertinoSwitch)),
|
||||
)
|
||||
.value;
|
||||
}
|
||||
return tester.widget<CheckboxListTile>(tile).value!;
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final style = cupertino ? 'Cupertino' : 'Material';
|
||||
testWidgets('loads the stored values', (tester) async {
|
||||
final gateway = _Gateway((_, _) => _reply(true, false, true));
|
||||
await tester.pumpWidget(_host(gateway));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.calls.single.$1, 'notification_settings');
|
||||
expect(find.text('Notify when any run ends'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Otherwise only runs started with Notify me'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Chat needs your answer or approval'), findsOneWidget);
|
||||
expect(find.text('Chat reply finished'), findsOneWidget);
|
||||
expect(find.text(ntfySectionSubtitle), findsOneWidget);
|
||||
expect(_checked(tester, 'run_finished'), isTrue);
|
||||
expect(_checked(tester, 'chat_needs_you'), isFalse);
|
||||
expect(_checked(tester, 'chat_reply_finished'), isTrue);
|
||||
});
|
||||
|
||||
testWidgets('$style loads the stored values', (tester) async {
|
||||
final gateway = _Gateway((_, _) => _reply(true, false, true));
|
||||
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.calls.single.$1, 'notification_settings');
|
||||
expect(find.text('Notify when any run ends'), findsOneWidget);
|
||||
expect(
|
||||
find.text('Otherwise only runs started with Notify me'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Chat needs your answer or approval'), findsOneWidget);
|
||||
expect(find.text('Chat reply finished'), findsOneWidget);
|
||||
expect(find.text(ntfySectionSubtitle), findsOneWidget);
|
||||
expect(_checked(tester, 'run_finished', cupertino: cupertino), isTrue);
|
||||
expect(_checked(tester, 'chat_needs_you', cupertino: cupertino), isFalse);
|
||||
expect(
|
||||
_checked(tester, 'chat_reply_finished', cupertino: cupertino),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
testWidgets('shows the server default: only marked runs', (tester) async {
|
||||
// The server's defaults: run ends notify only for "Notify me" runs.
|
||||
final gateway = _Gateway((_, _) => _reply(false, true, false));
|
||||
await tester.pumpWidget(_host(gateway));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_checked(tester, 'run_finished'), isFalse);
|
||||
expect(_checked(tester, 'chat_needs_you'), isTrue);
|
||||
expect(_checked(tester, 'chat_reply_finished'), isFalse);
|
||||
});
|
||||
|
||||
testWidgets('$style shows the server default: only marked runs', (
|
||||
tester,
|
||||
) async {
|
||||
// The server's defaults: run ends notify only for "Notify me" runs.
|
||||
final gateway = _Gateway((_, _) => _reply(false, true, false));
|
||||
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_checked(tester, 'run_finished', cupertino: cupertino), isFalse);
|
||||
expect(_checked(tester, 'chat_needs_you', cupertino: cupertino), isTrue);
|
||||
expect(
|
||||
_checked(tester, 'chat_reply_finished', cupertino: cupertino),
|
||||
isFalse,
|
||||
);
|
||||
testWidgets('toggling writes only that setting', (tester) async {
|
||||
final gateway = _Gateway((type, fields) {
|
||||
if (type == 'set_notification_settings') {
|
||||
return _reply(true, true, true);
|
||||
}
|
||||
return _reply(true, true, false);
|
||||
});
|
||||
await tester.pumpWidget(_host(gateway));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(ntfySettingKey('chat_reply_finished')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.calls, hasLength(2));
|
||||
expect(gateway.calls.last.$1, 'set_notification_settings');
|
||||
expect(gateway.calls.last.$2, {
|
||||
'notification_settings': {'chat_reply_finished': true},
|
||||
});
|
||||
expect(_checked(tester, 'chat_reply_finished'), isTrue);
|
||||
expect(find.byKey(ntfyErrorKey), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$style toggling writes only that setting', (tester) async {
|
||||
final gateway = _Gateway((type, fields) {
|
||||
if (type == 'set_notification_settings') {
|
||||
return _reply(true, true, true);
|
||||
}
|
||||
return _reply(true, true, false);
|
||||
});
|
||||
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(ntfySettingKey('chat_reply_finished')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.calls, hasLength(2));
|
||||
expect(gateway.calls.last.$1, 'set_notification_settings');
|
||||
expect(gateway.calls.last.$2, {
|
||||
'notification_settings': {'chat_reply_finished': true},
|
||||
});
|
||||
expect(
|
||||
_checked(tester, 'chat_reply_finished', cupertino: cupertino),
|
||||
isTrue,
|
||||
);
|
||||
expect(find.byKey(ntfyErrorKey), findsNothing);
|
||||
testWidgets('failure reverts and shows the refusal', (tester) async {
|
||||
final pending = Completer<JsonMap>();
|
||||
final gateway = _Gateway((type, _) {
|
||||
if (type == 'set_notification_settings') return pending.future;
|
||||
return _reply(true, true, false);
|
||||
});
|
||||
|
||||
testWidgets('$style failure reverts and shows the refusal', (tester) async {
|
||||
final pending = Completer<JsonMap>();
|
||||
final gateway = _Gateway((type, _) {
|
||||
if (type == 'set_notification_settings') return pending.future;
|
||||
return _reply(true, true, false);
|
||||
});
|
||||
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(ntfySettingKey('run_finished')));
|
||||
await tester.pump();
|
||||
// The change shows at once and the group is disabled while it saves.
|
||||
expect(_checked(tester, 'run_finished', cupertino: cupertino), isFalse);
|
||||
await tester.tap(find.byKey(ntfySettingKey('chat_needs_you')));
|
||||
await tester.pump();
|
||||
expect(gateway.calls, hasLength(2));
|
||||
pending.completeError(const ProtocolError('settings are read-only'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_checked(tester, 'run_finished', cupertino: cupertino), isTrue);
|
||||
expect(_checked(tester, 'chat_needs_you', cupertino: cupertino), isTrue);
|
||||
expect(
|
||||
find.text('Could not save: settings are read-only'),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
await tester.pumpWidget(_host(gateway));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(ntfySettingKey('run_finished')));
|
||||
await tester.pump();
|
||||
// The change shows at once and the group is disabled while it saves.
|
||||
expect(_checked(tester, 'run_finished'), isFalse);
|
||||
await tester.tap(find.byKey(ntfySettingKey('chat_needs_you')));
|
||||
await tester.pump();
|
||||
expect(gateway.calls, hasLength(2));
|
||||
pending.completeError(const ProtocolError('settings are read-only'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_checked(tester, 'run_finished'), isTrue);
|
||||
expect(_checked(tester, 'chat_needs_you'), isTrue);
|
||||
expect(
|
||||
find.text('Could not save: settings are read-only'),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('disabled while loading and offline', (tester) async {
|
||||
final pending = Completer<JsonMap>();
|
||||
final gateway = _Gateway((_, _) => pending.future);
|
||||
await tester.pumpWidget(_host(gateway, cupertino: false));
|
||||
await tester.pumpWidget(_host(gateway));
|
||||
await tester.pump();
|
||||
expect(find.text('Loading…'), findsOneWidget);
|
||||
await tester.tap(find.byKey(ntfySettingKey('run_finished')));
|
||||
@@ -181,7 +156,7 @@ void main() {
|
||||
if (fail) throw const ProtocolError('no store');
|
||||
return _reply(false, true, false);
|
||||
});
|
||||
await tester.pumpWidget(_host(gateway, cupertino: false));
|
||||
await tester.pumpWidget(_host(gateway));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('Could not load notification settings: no store'),
|
||||
@@ -210,38 +185,27 @@ void main() {
|
||||
|
||||
testWidgets('hidden when the server does not send it', (tester) async {
|
||||
final gateway = _Gateway((_, _) => _reply(true, true, false));
|
||||
await tester.pumpWidget(_host(gateway, cupertino: false));
|
||||
await tester.pumpWidget(_host(gateway));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(ntfySettingKey('ntfy_enabled')), findsNothing);
|
||||
expect(find.text(ntfySectionSubtitle), findsOneWidget);
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets(
|
||||
'${cupertino ? 'Cupertino' : 'Material'} shows and writes it',
|
||||
(tester) async {
|
||||
final gateway = _Gateway(
|
||||
(type, _) => withNtfy(type == 'set_notification_settings'),
|
||||
);
|
||||
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Also send to ntfy'), findsOneWidget);
|
||||
expect(find.text(ntfySectionAppSubtitle), findsOneWidget);
|
||||
expect(
|
||||
_checked(tester, 'ntfy_enabled', cupertino: cupertino),
|
||||
isFalse,
|
||||
);
|
||||
await tester.tap(find.byKey(ntfySettingKey('ntfy_enabled')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.calls.last.$2, {
|
||||
'notification_settings': {'ntfy_enabled': true},
|
||||
});
|
||||
expect(
|
||||
_checked(tester, 'ntfy_enabled', cupertino: cupertino),
|
||||
isTrue,
|
||||
);
|
||||
},
|
||||
testWidgets('shows and writes it', (tester) async {
|
||||
final gateway = _Gateway(
|
||||
(type, _) => withNtfy(type == 'set_notification_settings'),
|
||||
);
|
||||
}
|
||||
await tester.pumpWidget(_host(gateway));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Also send to ntfy'), findsOneWidget);
|
||||
expect(find.text(ntfySectionAppSubtitle), findsOneWidget);
|
||||
expect(_checked(tester, 'ntfy_enabled'), isFalse);
|
||||
await tester.tap(find.byKey(ntfySettingKey('ntfy_enabled')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(gateway.calls.last.$2, {
|
||||
'notification_settings': {'ntfy_enabled': true},
|
||||
});
|
||||
expect(_checked(tester, 'ntfy_enabled'), isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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/features/settings/settings_animation_section.dart';
|
||||
@@ -18,55 +17,42 @@ class _Store implements QuickSwitchAnimationStore {
|
||||
}
|
||||
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
testWidgets('chooses and saves quick switch animation ($cupertino)', (
|
||||
tester,
|
||||
) async {
|
||||
final store = _Store();
|
||||
final controller = QuickSwitchAnimationController(store: store);
|
||||
final speed = AnimationSpeedController();
|
||||
final child = SettingsAnimationSection(
|
||||
controller: speed,
|
||||
quickSwitchController: controller,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: SingleChildScrollView(child: child),
|
||||
),
|
||||
)
|
||||
: MaterialApp(
|
||||
home: Scaffold(body: SingleChildScrollView(child: child)),
|
||||
),
|
||||
);
|
||||
expect(find.text('Quick switch animation'), findsOneWidget);
|
||||
expect(
|
||||
cupertino ? find.byType(CupertinoSlider) : find.byType(Slider),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.text('Tape'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Card deck').last);
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.value, QuickSwitchAnimation.cardStack);
|
||||
expect(store.saved, 'cardStack');
|
||||
expect(
|
||||
find.text(QuickSwitchAnimation.cardStack.description),
|
||||
findsOneWidget,
|
||||
);
|
||||
store.success = false;
|
||||
await tester.tap(find.text('Card deck'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Swap').last);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('Could not save; applies until reload.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
controller.dispose();
|
||||
speed.dispose();
|
||||
});
|
||||
}
|
||||
testWidgets('chooses and saves quick switch animation', (tester) async {
|
||||
final store = _Store();
|
||||
final controller = QuickSwitchAnimationController(store: store);
|
||||
final speed = AnimationSpeedController();
|
||||
final child = SettingsAnimationSection(
|
||||
controller: speed,
|
||||
quickSwitchController: controller,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(body: SingleChildScrollView(child: child)),
|
||||
),
|
||||
);
|
||||
expect(find.text('Quick switch animation'), findsOneWidget);
|
||||
expect(find.byType(Slider), findsOneWidget);
|
||||
await tester.tap(find.text('Tape'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Card deck').last);
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.value, QuickSwitchAnimation.cardStack);
|
||||
expect(store.saved, 'cardStack');
|
||||
expect(
|
||||
find.text(QuickSwitchAnimation.cardStack.description),
|
||||
findsOneWidget,
|
||||
);
|
||||
store.success = false;
|
||||
await tester.tap(find.text('Card deck'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Swap').last);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('Could not save; applies until reload.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
controller.dispose();
|
||||
speed.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:pipelines_app/features/settings/settings_store.dart';
|
||||
|
||||
import 'fake_channel.dart';
|
||||
import 'settings_topic_test_helper.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('renders idle settings without opening a connection', (
|
||||
@@ -258,23 +257,6 @@ void main() {
|
||||
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('an explicit Cupertino host uses Cupertino fields and buttons', (
|
||||
tester,
|
||||
) async {
|
||||
final factory = FakeChannelFactory();
|
||||
final client = transport.PipelinesClient(channelFactory: factory.call);
|
||||
addTearDown(client.dispose);
|
||||
|
||||
await _pump(tester, client, cupertino: true);
|
||||
|
||||
expect(find.byType(SegmentedBar), findsOneWidget);
|
||||
expect(find.byType(CupertinoTextField), findsNWidgets(2));
|
||||
expect(find.byType(TextField), findsNothing);
|
||||
expect(find.byType(FilledButton), findsNothing);
|
||||
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
|
||||
expect(find.text('Trusted LAN/VPN only'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('narrow window with large text scrolls without overflow', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -375,26 +357,11 @@ Future<void> _pump(
|
||||
transport.PipelinesClient client, {
|
||||
SettingsStore? store,
|
||||
TargetPlatform platform = TargetPlatform.android,
|
||||
bool cupertino = false,
|
||||
double textScale = 1,
|
||||
Size size = const Size(800, 1200),
|
||||
}) async {
|
||||
await tester.binding.setSurfaceSize(size);
|
||||
addTearDown(() => tester.binding.setSurfaceSize(null));
|
||||
if (cupertino) {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: SettingsScreen(
|
||||
client: client,
|
||||
store: store ?? MemorySettingsStore(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
return;
|
||||
}
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: platform),
|
||||
|
||||
Reference in New Issue
Block a user