Merge main into chat tab re-tap
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import '../features/settings/settings_topic_test_helper.dart';
|
||||
import '../features/settings/settings_section_test_helper.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/application/pipelines_app.dart';
|
||||
@@ -84,7 +84,7 @@ void main() {
|
||||
expect(provider.value.uri.path, '/settings');
|
||||
expect(find.byType(SettingsScreen), findsOneWidget);
|
||||
expect(find.text('Quick switch animation'), findsOneWidget);
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
await openSettingsSection(tester, 'Connection');
|
||||
expect(find.text('Server URL'), findsOneWidget);
|
||||
// A page of Pipelines: Back in its bar, Settings selected in the bar.
|
||||
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import '../features/settings/settings_topic_test_helper.dart';
|
||||
import '../features/settings/settings_section_test_helper.dart';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -54,7 +54,7 @@ void main() {
|
||||
await tester.pump();
|
||||
expect(provider.value.uri.path, '/settings');
|
||||
expect(find.text('Quick switch animation'), findsOneWidget);
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
await openSettingsSection(tester, 'Connection');
|
||||
expect(find.text('Server URL'), findsOneWidget);
|
||||
expect(find.text('Settings — Not implemented'), findsNothing);
|
||||
expect(sockets, 1);
|
||||
|
||||
@@ -16,28 +16,39 @@ import 'package:pipelines_app/features/settings/settings_store.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_trust_warning.dart';
|
||||
|
||||
import 'fake_channel.dart';
|
||||
import 'settings_topic_test_helper.dart';
|
||||
import 'settings_section_test_helper.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('groups start at the bar inset and stop at the reading width', (
|
||||
testWidgets('groups are centred at the reading width beside the index', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, size: const Size(1200, 1600));
|
||||
|
||||
// The list area is the window less the jump index and the side insets.
|
||||
const area = 1200 - settingsIndexWidth - 2 * settingsPageSidePadding;
|
||||
final expectedLeft =
|
||||
settingsPageSidePadding + (area - settingsContentMaxWidth) / 2;
|
||||
final groups = find.byType(SettingsGroup);
|
||||
expect(groups, findsWidgets);
|
||||
for (final group in groups.evaluate()) {
|
||||
final rect = tester.getRect(find.byWidget(group.widget));
|
||||
// The column starts where the bar's title pill does, not centred.
|
||||
expect(rect.left, closeTo(settingsPageSidePadding, 0.01));
|
||||
expect(rect.left, closeTo(expectedLeft, 0.01));
|
||||
expect(rect.width, closeTo(settingsContentMaxWidth, 0.01));
|
||||
}
|
||||
// A header's text lines up with its rows' text.
|
||||
final header = tester.getRect(find.text('Connection').last);
|
||||
expect(
|
||||
header.left,
|
||||
closeTo(settingsPageSidePadding + settingsRowInset, 0.01),
|
||||
);
|
||||
final groupLeft = tester.getRect(find.byType(SettingsGroup).first).left;
|
||||
final header = tester.getRect(find.text('Connection').first);
|
||||
expect(header.left, closeTo(groupLeft + settingsRowInset, 0.01));
|
||||
});
|
||||
|
||||
testWidgets('on a narrow window the groups fill the inset width', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, size: const Size(390, 844));
|
||||
|
||||
final group = tester.getRect(find.byType(SettingsGroup).first);
|
||||
expect(group.left, closeTo(settingsPageSidePadding, 0.01));
|
||||
expect(group.width, closeTo(390 - 2 * settingsPageSidePadding, 0.01));
|
||||
});
|
||||
|
||||
testWidgets('Material groups are flat surfaces, not elevated cards', (
|
||||
@@ -64,32 +75,24 @@ void main() {
|
||||
}
|
||||
// The trust warning is the Connection group's footer, not a card.
|
||||
expect(find.byType(SettingsTrustWarning), findsOneWidget);
|
||||
final title = tester.widget<Text>(find.text('Connection').last);
|
||||
final theme = Theme.of(tester.element(find.text('Connection').last));
|
||||
final title = tester.widget<Text>(find.text('Connection').first);
|
||||
final theme = Theme.of(tester.element(find.text('Connection').first));
|
||||
expect(title.style?.color, theme.colorScheme.primary);
|
||||
});
|
||||
|
||||
testWidgets('content starts below the bar and persistent topic tabs', (
|
||||
testWidgets('content starts below the bar, with the search field pinned', (
|
||||
tester,
|
||||
) async {
|
||||
const barHeight = 72.0;
|
||||
await _pump(tester, topPadding: barHeight);
|
||||
|
||||
final first = tester.getRect(find.byType(SettingsGroup).first);
|
||||
expect(
|
||||
first.top,
|
||||
closeTo(
|
||||
barHeight +
|
||||
tester.getSize(find.byType(TabBar)).height +
|
||||
settingsPageTopPadding,
|
||||
0.01,
|
||||
),
|
||||
);
|
||||
// The topic selector stays above each page scroll view.
|
||||
expect(
|
||||
tester.getRect(find.byKey(const ValueKey('settings.scroll')).last).top,
|
||||
barHeight + tester.getSize(find.byType(TabBar)).height,
|
||||
// The search field sits under the bar and stays above the scrolling list.
|
||||
final search = tester.getRect(
|
||||
find.byKey(const ValueKey('settings.search')),
|
||||
);
|
||||
expect(search.top, closeTo(barHeight + settingsPageTopPadding, 0.01));
|
||||
final list = tester.getRect(find.byKey(const ValueKey('settings.scroll')));
|
||||
expect(list.top, greaterThan(search.bottom));
|
||||
});
|
||||
|
||||
testWidgets('the notification tile is the section\'s only title', (
|
||||
@@ -101,9 +104,9 @@ void main() {
|
||||
addTearDown(notifications.dispose);
|
||||
await _pump(tester, notifications: notifications);
|
||||
|
||||
await selectSettingsTopic(tester, 'Notifications');
|
||||
expect(find.text('Notifications'), findsNWidgets(2));
|
||||
expect(find.text('Connection').last, findsOneWidget);
|
||||
await openSettingsSection(tester, 'Notifications');
|
||||
expect(find.text('Notifications'), findsOneWidget);
|
||||
expect(find.text('Connection'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('server rows show which server is selected', (tester) async {
|
||||
@@ -183,5 +186,5 @@ Future<void> _pump(
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
await openSettingsSection(tester, 'Connection');
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ import 'package:pipelines_app/features/settings/settings_screen.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_store.dart';
|
||||
|
||||
import 'fake_channel.dart';
|
||||
import 'settings_topic_test_helper.dart';
|
||||
import 'settings_section_test_helper.dart';
|
||||
|
||||
/// The Tools topic's Library group lists Schedules only: Templates left
|
||||
/// The Library section lists Schedules only: Templates left
|
||||
/// Settings, and Schedules keeps its own route.
|
||||
void main() {
|
||||
Future<void> pump(
|
||||
@@ -34,10 +34,12 @@ void main() {
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await selectSettingsTopic(tester, 'Tools');
|
||||
if (onOpenSchedules != null) await openSettingsSection(tester, 'Library');
|
||||
}
|
||||
|
||||
testWidgets('Tools offers Schedules and no Templates entry', (tester) async {
|
||||
testWidgets('Library offers Schedules and no Templates entry', (
|
||||
tester,
|
||||
) async {
|
||||
var opened = 0;
|
||||
await pump(tester, onOpenSchedules: () => opened++);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:pipelines_app/features/settings/settings_screen.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_store.dart';
|
||||
|
||||
import 'fake_channel.dart';
|
||||
import 'settings_topic_test_helper.dart';
|
||||
import 'settings_section_test_helper.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('renders idle settings without opening a connection', (
|
||||
@@ -34,7 +34,7 @@ void main() {
|
||||
expect(find.text('Not connected'), findsOneWidget);
|
||||
expect(find.text('Saved workspace: /srv/pipelines'), findsOneWidget);
|
||||
expect(
|
||||
tester.widget<TextField>(find.byType(TextField).first).controller?.text,
|
||||
tester.widget<TextField>(serverUrlField).controller?.text,
|
||||
'ws://saved.test/connect',
|
||||
);
|
||||
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
|
||||
@@ -65,7 +65,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
final field = tester.widget<TextField>(find.byType(TextField).first);
|
||||
final field = tester.widget<TextField>(serverUrlField);
|
||||
expect(field.maxLines, 2);
|
||||
expect(field.controller?.text, contains('/connect'));
|
||||
expect(tester.takeException(), isNull);
|
||||
@@ -82,15 +82,14 @@ void main() {
|
||||
store: MemorySettingsStore(serverUrl: 'ws://127.0.0.1:8080/connect'),
|
||||
);
|
||||
|
||||
final fields = find.byType(TextField);
|
||||
final url = tester.widget<TextField>(fields.first);
|
||||
final url = tester.widget<TextField>(serverUrlField);
|
||||
expect(url.minLines, 1);
|
||||
// The URL field grows only when its text wraps: one line is the same
|
||||
// height as the single-line workspace field below it.
|
||||
Size editable(Finder field) => tester.getSize(
|
||||
find.descendant(of: field, matching: find.byType(EditableText)),
|
||||
);
|
||||
expect(editable(fields.first).height, editable(fields.last).height);
|
||||
expect(editable(serverUrlField).height, editable(workspaceField).height);
|
||||
});
|
||||
|
||||
testWidgets('an invalid URL shows the field error and opens no socket', (
|
||||
@@ -101,7 +100,7 @@ void main() {
|
||||
addTearDown(client.dispose);
|
||||
|
||||
await _pump(tester, client);
|
||||
await tester.enterText(find.byType(TextField).first, 'http://example.test');
|
||||
await tester.enterText(serverUrlField, 'http://example.test');
|
||||
await tester.pump();
|
||||
await tester.tap(find.byKey(SettingsKeys.connect));
|
||||
await tester.pump();
|
||||
@@ -119,10 +118,7 @@ void main() {
|
||||
addTearDown(client.dispose);
|
||||
|
||||
await _pump(tester, client);
|
||||
await tester.enterText(
|
||||
find.byType(TextField).first,
|
||||
'ws://example.test:8123',
|
||||
);
|
||||
await tester.enterText(serverUrlField, 'ws://example.test:8123');
|
||||
await tester.pump();
|
||||
await tester.tap(find.byKey(SettingsKeys.connect));
|
||||
await tester.pump();
|
||||
@@ -162,9 +158,13 @@ void main() {
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Connect'), findsNothing);
|
||||
// Notification settings are loaded only when their topic is opened.
|
||||
expect(factory.last.decodedOutgoing, hasLength(1));
|
||||
await selectSettingsTopic(tester, 'Notifications');
|
||||
// Notification settings load once their lazy section is near the list:
|
||||
// this tall window reaches it on open, after the single ping.
|
||||
expect(factory.last.decodedOutgoing.map((message) => message['type']), [
|
||||
'ping',
|
||||
'notification_settings',
|
||||
]);
|
||||
await openSettingsSection(tester, 'Phone notifications');
|
||||
_answerNtfySettings(factory.last);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
@@ -179,10 +179,7 @@ void main() {
|
||||
addTearDown(client.dispose);
|
||||
|
||||
await _pump(tester, client);
|
||||
await tester.enterText(
|
||||
find.byType(TextField).first,
|
||||
'ws://example.test:8123',
|
||||
);
|
||||
await tester.enterText(serverUrlField, 'ws://example.test:8123');
|
||||
await tester.pump();
|
||||
await tester.tap(find.byKey(SettingsKeys.connect));
|
||||
await tester.pump();
|
||||
@@ -206,7 +203,7 @@ void main() {
|
||||
expect(find.text(serverDetailsPending), findsNothing);
|
||||
expect(find.text('Server build unavailable'), findsOneWidget);
|
||||
expect(find.text('Server time unavailable'), findsOneWidget);
|
||||
await selectSettingsTopic(tester, 'Notifications');
|
||||
await openSettingsSection(tester, 'Phone notifications');
|
||||
_answerNtfySettings(factory.last);
|
||||
await tester.pump();
|
||||
});
|
||||
@@ -220,7 +217,7 @@ void main() {
|
||||
final store = MemorySettingsStore();
|
||||
|
||||
await _pump(tester, client, store: store);
|
||||
final workspace = find.byType(TextField).at(1);
|
||||
final workspace = workspaceField;
|
||||
await tester.enterText(workspace, 'relative/path');
|
||||
await tester.pump();
|
||||
|
||||
@@ -270,7 +267,7 @@ void main() {
|
||||
200,
|
||||
scrollable: find
|
||||
.descendant(
|
||||
of: find.byKey(const ValueKey('settings-topic-connection')),
|
||||
of: find.byKey(const ValueKey<String>('settings.scroll')),
|
||||
matching: find.byType(Scrollable),
|
||||
)
|
||||
.first,
|
||||
@@ -318,20 +315,88 @@ void main() {
|
||||
await _pump(tester, client);
|
||||
|
||||
final labels = <String>[
|
||||
tester
|
||||
.getSemantics(find.byType(TextField).at(0))
|
||||
.getSemanticsData()
|
||||
.label,
|
||||
tester
|
||||
.getSemantics(find.byType(TextField).at(1))
|
||||
.getSemanticsData()
|
||||
.label,
|
||||
tester.getSemantics(serverUrlField).getSemanticsData().label,
|
||||
tester.getSemantics(workspaceField).getSemanticsData().label,
|
||||
];
|
||||
expect(labels[0], contains('Server URL'));
|
||||
expect(labels[1], contains('Workspace path (on the server)'));
|
||||
handle.dispose();
|
||||
});
|
||||
|
||||
testWidgets('Help and about keeps the keyboard shortcuts row', (
|
||||
tester,
|
||||
) async {
|
||||
final factory = FakeChannelFactory();
|
||||
final client = transport.PipelinesClient(channelFactory: factory.call);
|
||||
addTearDown(client.dispose);
|
||||
|
||||
await _pump(tester, client);
|
||||
await openSettingsSection(tester, 'Help and about');
|
||||
|
||||
expect(find.text('Help and about'), findsOneWidget);
|
||||
expect(find.byKey(SettingsKeys.keyboardShortcuts), findsOneWidget);
|
||||
// Help is a plain section of the page, so the search reaches it too.
|
||||
await tester.enterText(
|
||||
find.byKey(const ValueKey<String>('settings.search')),
|
||||
'shortcuts',
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.byKey(SettingsKeys.keyboardShortcuts), findsOneWidget);
|
||||
expect(find.text('Server URL'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Help and about has a Show the walkthrough row', (tester) async {
|
||||
final factory = FakeChannelFactory();
|
||||
final client = transport.PipelinesClient(channelFactory: factory.call);
|
||||
addTearDown(client.dispose);
|
||||
var shown = 0;
|
||||
|
||||
await _pump(tester, client, onShowWalkthrough: () => shown++);
|
||||
await openSettingsSection(tester, 'Help and about');
|
||||
|
||||
final row = find.byKey(SettingsKeys.showWalkthrough);
|
||||
expect(find.text('Show the walkthrough'), findsOneWidget);
|
||||
expect(row, findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<ListTile>(find.descendant(of: row, matching: find.byType(ListTile)))
|
||||
.enabled,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
await tester.tap(row);
|
||||
await tester.pump();
|
||||
expect(shown, 1);
|
||||
|
||||
// The search reaches the row as well.
|
||||
await tester.enterText(
|
||||
find.byKey(const ValueKey<String>('settings.search')),
|
||||
'walkthrough',
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.byKey(SettingsKeys.showWalkthrough), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Show the walkthrough row is disabled without a handler', (
|
||||
tester,
|
||||
) async {
|
||||
final factory = FakeChannelFactory();
|
||||
final client = transport.PipelinesClient(channelFactory: factory.call);
|
||||
addTearDown(client.dispose);
|
||||
|
||||
await _pump(tester, client);
|
||||
await openSettingsSection(tester, 'Help and about');
|
||||
|
||||
final row = find.byKey(SettingsKeys.showWalkthrough);
|
||||
expect(row, findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<ListTile>(find.descendant(of: row, matching: find.byType(ListTile)))
|
||||
.enabled,
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('unmounting leaves the shared client usable', (tester) async {
|
||||
final factory = FakeChannelFactory();
|
||||
final client = transport.PipelinesClient(channelFactory: factory.call);
|
||||
@@ -348,8 +413,74 @@ void main() {
|
||||
await tester.pump();
|
||||
await connecting;
|
||||
});
|
||||
|
||||
testWidgets('phone: the page scrolls to rest above the floating tab bar', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.binding.setSurfaceSize(const Size(390, 844));
|
||||
addTearDown(() => tester.binding.setSurfaceSize(null));
|
||||
final client = transport.PipelinesClient(
|
||||
channelFactory: FakeChannelFactory().call,
|
||||
);
|
||||
addTearDown(client.dispose);
|
||||
|
||||
// The shell's shape: a body that extends behind a bottom bar, which the
|
||||
// body reads as its bottom padding.
|
||||
const barKey = ValueKey<String>('test.tabBar');
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: ThemeData(platform: TargetPlatform.android),
|
||||
home: Scaffold(
|
||||
extendBody: true,
|
||||
body: SettingsScreen(
|
||||
client: client,
|
||||
store: MemorySettingsStore(),
|
||||
embedded: true,
|
||||
onShowWalkthrough: () {},
|
||||
),
|
||||
bottomNavigationBar: const SizedBox(
|
||||
key: barKey,
|
||||
width: double.infinity,
|
||||
height: 80,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
final scroll = find.byKey(const ValueKey<String>('settings.scroll'));
|
||||
// Each lazy section that the scroll reaches grows the list, so keep
|
||||
// scrolling until the page stops moving.
|
||||
for (var i = 0; i < 6; i++) {
|
||||
await tester.drag(scroll, const Offset(0, -10000));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
final barTop = tester.getTopLeft(find.byKey(barKey)).dy;
|
||||
// Nothing scrolls under the bar: the list's viewport ends at its top edge,
|
||||
// and the last row (the page's end) sits above it at rest.
|
||||
expect(tester.getRect(scroll).bottom, lessThanOrEqualTo(barTop + 0.5));
|
||||
expect(
|
||||
tester.getRect(find.byKey(SettingsKeys.showWalkthrough)).bottom,
|
||||
lessThanOrEqualTo(barTop + 0.5),
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
|
||||
/// The Server URL and Workspace fields, addressed by their keys: the search
|
||||
/// field is the page's first text field.
|
||||
Finder get serverUrlField => find.descendant(
|
||||
of: find.byKey(SettingsKeys.serverUrl),
|
||||
matching: find.byType(TextField),
|
||||
);
|
||||
Finder get workspaceField => find.descendant(
|
||||
of: find.byKey(SettingsKeys.workspace),
|
||||
matching: find.byType(TextField),
|
||||
);
|
||||
|
||||
Future<void> _pump(
|
||||
WidgetTester tester,
|
||||
transport.PipelinesClient client, {
|
||||
@@ -357,6 +488,7 @@ Future<void> _pump(
|
||||
TargetPlatform platform = TargetPlatform.android,
|
||||
double textScale = 1,
|
||||
Size size = const Size(800, 1200),
|
||||
VoidCallback? onShowWalkthrough,
|
||||
}) async {
|
||||
await tester.binding.setSurfaceSize(size);
|
||||
addTearDown(() => tester.binding.setSurfaceSize(null));
|
||||
@@ -372,12 +504,13 @@ Future<void> _pump(
|
||||
home: SettingsScreen(
|
||||
client: client,
|
||||
store: store ?? MemorySettingsStore(),
|
||||
onShowWalkthrough: onShowWalkthrough,
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
await openSettingsSection(tester, 'Connection');
|
||||
}
|
||||
|
||||
/// Answers the Settings screen's queued ntfy-settings load on [channel].
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_search_page.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_section.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_server_load.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_server_view.dart';
|
||||
|
||||
/// Fills the page so a section placed after it starts far below the viewport.
|
||||
List<SettingsSection> _filler(int count) => [
|
||||
for (var i = 0; i < count; i++)
|
||||
SettingsSection(
|
||||
id: 'filler-$i',
|
||||
title: 'Filler $i',
|
||||
builder: (_) => const SizedBox(height: 400, child: Text('filler body')),
|
||||
),
|
||||
];
|
||||
|
||||
Future<void> _pump(
|
||||
WidgetTester tester,
|
||||
List<SettingsSection> sections, {
|
||||
Size size = const Size(800, 600),
|
||||
}) async {
|
||||
await tester.binding.setSurfaceSize(size);
|
||||
addTearDown(() => tester.binding.setSurfaceSize(null));
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(body: SettingsSearchPage(sections: sections)),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('local settings render while a server section has not answered', (
|
||||
tester,
|
||||
) async {
|
||||
var fetches = 0;
|
||||
final reply = Completer<int>();
|
||||
final load = ServerLoad<int>(() {
|
||||
fetches++;
|
||||
return reply.future;
|
||||
});
|
||||
addTearDown(load.dispose);
|
||||
await _pump(tester, [
|
||||
..._filler(6),
|
||||
SettingsSection(
|
||||
id: 'server',
|
||||
title: 'Phone notifications',
|
||||
lazy: true,
|
||||
builder: (_) => ServerSettingsView<int>(
|
||||
load: load,
|
||||
builder: (_, value) => Text('Server $value'),
|
||||
),
|
||||
),
|
||||
]);
|
||||
|
||||
// The local sections are built and the server section is only a skeleton:
|
||||
// no request runs until the list reaches it.
|
||||
expect(find.text('filler body'), findsWidgets);
|
||||
expect(find.text('Phone notifications'), findsOneWidget);
|
||||
expect(fetches, 0);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
await tester.ensureVisible(find.text('Phone notifications'));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(fetches, 1);
|
||||
// The reply is still pending, and the page keeps working.
|
||||
expect(find.bySemanticsLabel('Loading'), findsOneWidget);
|
||||
expect(find.text('filler body'), findsWidgets);
|
||||
reply.complete(3);
|
||||
await tester.pump();
|
||||
expect(find.text('Server 3'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('search filters sections by title and keywords', (tester) async {
|
||||
await _pump(tester, [
|
||||
SettingsSection(
|
||||
id: 'animations',
|
||||
title: 'Animations',
|
||||
keywords: 'motion speed',
|
||||
builder: _titled('Animations'),
|
||||
),
|
||||
SettingsSection(
|
||||
id: 'terminal',
|
||||
title: 'Terminal',
|
||||
keywords: 'layout split',
|
||||
builder: _titled('Terminal'),
|
||||
),
|
||||
]);
|
||||
expect(find.text('Animations'), findsOneWidget);
|
||||
expect(find.text('Terminal'), findsOneWidget);
|
||||
|
||||
await tester.enterText(
|
||||
find.byKey(const ValueKey('settings.search')),
|
||||
'motion',
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.text('Animations'), findsOneWidget);
|
||||
expect(find.text('Terminal'), findsNothing);
|
||||
|
||||
// Every word must match: "motion layout" matches neither section.
|
||||
await tester.enterText(
|
||||
find.byKey(const ValueKey('settings.search')),
|
||||
'motion layout',
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.text('Animations'), findsNothing);
|
||||
expect(find.text('Terminal'), findsNothing);
|
||||
expect(find.textContaining('No settings match'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byTooltip('Clear search'));
|
||||
await tester.pump();
|
||||
expect(find.text('Animations'), findsOneWidget);
|
||||
expect(find.text('Terminal'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a search that matches a server section loads it at once', (
|
||||
tester,
|
||||
) async {
|
||||
var fetches = 0;
|
||||
final load = ServerLoad<int>(() async {
|
||||
fetches++;
|
||||
return 9;
|
||||
});
|
||||
addTearDown(load.dispose);
|
||||
await _pump(tester, [
|
||||
..._filler(6),
|
||||
SettingsSection(
|
||||
id: 'server',
|
||||
title: 'Phone notifications',
|
||||
keywords: 'ntfy push',
|
||||
lazy: true,
|
||||
builder: (_) => ServerSettingsView<int>(
|
||||
load: load,
|
||||
builder: (_, value) => Text('Server $value'),
|
||||
),
|
||||
),
|
||||
]);
|
||||
expect(fetches, 0);
|
||||
|
||||
await tester.enterText(
|
||||
find.byKey(const ValueKey('settings.search')),
|
||||
'ntfy',
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(fetches, 1);
|
||||
expect(find.text('Server 9'), findsOneWidget);
|
||||
expect(find.text('filler body'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'a failing server section shows its own Retry; others are unaffected',
|
||||
(tester) async {
|
||||
var attempts = 0;
|
||||
final load = ServerLoad<String>(() async {
|
||||
attempts++;
|
||||
if (attempts == 1) throw StateError('server unreachable');
|
||||
return 'Stored';
|
||||
});
|
||||
addTearDown(load.dispose);
|
||||
await _pump(tester, [
|
||||
SettingsSection(
|
||||
id: 'local',
|
||||
title: 'Animations',
|
||||
builder: (_) =>
|
||||
const Column(children: [Text('Animations'), Text('Local value')]),
|
||||
),
|
||||
SettingsSection(
|
||||
id: 'server',
|
||||
title: 'Sign-in security',
|
||||
lazy: true,
|
||||
builder: (_) => ServerSettingsView<String>(
|
||||
load: load,
|
||||
retryKey: const Key('server-retry'),
|
||||
builder: (_, value) => Text('Security $value'),
|
||||
),
|
||||
),
|
||||
]);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.textContaining('server unreachable'), findsOneWidget);
|
||||
expect(find.byKey(const Key('server-retry')), findsOneWidget);
|
||||
expect(find.text('Local value'), findsOneWidget);
|
||||
expect(find.text('Animations'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('server-retry')));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(attempts, 2);
|
||||
expect(find.text('Security Stored'), findsOneWidget);
|
||||
expect(find.byKey(const Key('server-retry')), findsNothing);
|
||||
expect(find.text('Local value'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('wide layouts list every visible section in the jump index', (
|
||||
tester,
|
||||
) async {
|
||||
final sections = [
|
||||
SettingsSection(
|
||||
id: 'animations',
|
||||
title: 'Animations',
|
||||
builder: _titled('Animations'),
|
||||
),
|
||||
SettingsSection(
|
||||
id: 'terminal',
|
||||
title: 'Terminal',
|
||||
builder: _titled('Terminal'),
|
||||
),
|
||||
];
|
||||
await _pump(tester, sections, size: const Size(1200, 800));
|
||||
expect(
|
||||
find.byKey(const ValueKey('settings.index.animations')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.byKey(const ValueKey('settings.index.terminal')),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('settings.index.terminal')));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('a narrow layout has no jump index', (tester) async {
|
||||
await _pump(tester, [
|
||||
SettingsSection(
|
||||
id: 'animations',
|
||||
title: 'Animations',
|
||||
builder: _titled('Animations'),
|
||||
),
|
||||
], size: const Size(390, 844));
|
||||
expect(
|
||||
find.byKey(const ValueKey('settings.index.animations')),
|
||||
findsNothing,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
WidgetBuilder _titled(String title) =>
|
||||
(_) => Text(title);
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
/// Scrolls the Settings page to the heading [title] and lets a lazy section
|
||||
/// that the scroll reaches load its content.
|
||||
Future<void> openSettingsSection(WidgetTester tester, String title) async {
|
||||
final heading = find.text(title).first;
|
||||
await tester.ensureVisible(heading);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 300));
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_server_load.dart';
|
||||
|
||||
void main() {
|
||||
test('concurrent loads share one request', () async {
|
||||
var calls = 0;
|
||||
final reply = Completer<int>();
|
||||
final load = ServerLoad<int>(() {
|
||||
calls++;
|
||||
return reply.future;
|
||||
});
|
||||
addTearDown(load.dispose);
|
||||
|
||||
final first = load.load();
|
||||
final second = load.refresh();
|
||||
expect(calls, 1);
|
||||
expect(load.loading, isTrue);
|
||||
|
||||
reply.complete(7);
|
||||
await first;
|
||||
await second;
|
||||
expect(load.value, 7);
|
||||
expect(load.hasValue, isTrue);
|
||||
expect(load.loading, isFalse);
|
||||
expect(load.error, isNull);
|
||||
});
|
||||
|
||||
test(
|
||||
'a failed refresh keeps the last value; a retry clears the error',
|
||||
() async {
|
||||
var calls = 0;
|
||||
final load = ServerLoad<String>(() async {
|
||||
calls++;
|
||||
if (calls == 2) throw StateError('server unreachable');
|
||||
return 'value $calls';
|
||||
});
|
||||
addTearDown(load.dispose);
|
||||
|
||||
await load.load();
|
||||
expect(load.value, 'value 1');
|
||||
|
||||
await load.refresh();
|
||||
expect(load.value, 'value 1', reason: 'the cached value survives');
|
||||
expect(load.error, isA<StateError>());
|
||||
|
||||
await load.refresh();
|
||||
expect(load.error, isNull);
|
||||
expect(load.value, 'value 3');
|
||||
expect(calls, 3);
|
||||
},
|
||||
);
|
||||
|
||||
test('a reply that lands after dispose is dropped quietly', () async {
|
||||
final reply = Completer<int>();
|
||||
final load = ServerLoad<int>(() => reply.future);
|
||||
final pending = load.load();
|
||||
load.dispose();
|
||||
|
||||
reply.complete(1);
|
||||
await pending;
|
||||
expect(load.hasValue, isFalse);
|
||||
});
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_tabs.dart';
|
||||
import 'settings_topic_test_helper.dart';
|
||||
|
||||
class _Page extends StatefulWidget {
|
||||
const _Page({required this.name, required this.onMount});
|
||||
final String name;
|
||||
final VoidCallback onMount;
|
||||
@override
|
||||
State<_Page> createState() => _PageState();
|
||||
}
|
||||
|
||||
class _PageState extends State<_Page> {
|
||||
final text = TextEditingController();
|
||||
final scroll = ScrollController();
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
widget.onMount();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
text.dispose();
|
||||
scroll.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => SingleChildScrollView(
|
||||
controller: scroll,
|
||||
child: Column(
|
||||
children: [
|
||||
TextField(controller: text),
|
||||
for (var i = 0; i < 80; i++) Text('${widget.name} item $i'),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('lazy topic pages retain draft and scroll', (tester) async {
|
||||
final mounts = <SettingsTopic, int>{};
|
||||
final tabs = SettingsTopicTabs(
|
||||
pages: {
|
||||
for (final topic in SettingsTopic.values)
|
||||
topic: (_) => _Page(
|
||||
name: topic.name,
|
||||
onMount: () =>
|
||||
mounts.update(topic, (count) => count + 1, ifAbsent: () => 1),
|
||||
),
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(home: Scaffold(body: tabs)));
|
||||
expect(mounts, {SettingsTopic.appearance: 1});
|
||||
final appearance = tester.state<_PageState>(find.byType(_Page));
|
||||
appearance.text.text = 'Keep this draft';
|
||||
appearance.scroll.jumpTo(150);
|
||||
await tester.pump();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(mounts, {SettingsTopic.appearance: 1, SettingsTopic.connection: 1});
|
||||
final connection = tester.state<_PageState>(find.byType(_Page));
|
||||
connection.text.text = 'Unsubmitted server';
|
||||
connection.scroll.jumpTo(280);
|
||||
await selectSettingsTopic(tester, 'Appearance');
|
||||
expect(tester.state(find.byType(_Page)), same(appearance));
|
||||
expect(appearance.text.text, 'Keep this draft');
|
||||
expect(appearance.scroll.offset, 150);
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(tester.state(find.byType(_Page)), same(connection));
|
||||
expect(connection.text.text, 'Unsubmitted server');
|
||||
expect(connection.scroll.offset, 280);
|
||||
expect(mounts.values, everyElement(1));
|
||||
});
|
||||
|
||||
testWidgets('all topics reachable at narrow large text', (tester) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final tabs = SettingsTopicTabs(
|
||||
pages: {
|
||||
for (final topic in SettingsTopic.values)
|
||||
topic: (_) => Text('${topic.label} content'),
|
||||
},
|
||||
);
|
||||
Widget scale(BuildContext context, Widget? child) => MediaQuery(
|
||||
data: MediaQuery.of(
|
||||
context,
|
||||
).copyWith(textScaler: const TextScaler.linear(2)),
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
builder: scale,
|
||||
home: Scaffold(body: tabs),
|
||||
),
|
||||
);
|
||||
for (final topic in SettingsTopic.values) {
|
||||
await selectSettingsTopic(tester, topic.label);
|
||||
expect(find.text('${topic.label} content'), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,203 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/servers/server_scope.dart';
|
||||
import 'package:pipelines_app/core/storage/ordered_local_storage.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_tabs.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_topic_store.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'settings_topic_test_helper.dart';
|
||||
|
||||
Widget host({String? scope, SettingsTopicStore? store}) {
|
||||
final tabs = SettingsTopicTabs(
|
||||
navigationScope: scope,
|
||||
selectionStore: store,
|
||||
pages: {
|
||||
for (final topic in SettingsTopic.values)
|
||||
topic: (_) => Text('${topic.name} page'),
|
||||
},
|
||||
);
|
||||
return MaterialApp(home: Scaffold(body: tabs));
|
||||
}
|
||||
|
||||
class DelayedStore implements SettingsTopicStore {
|
||||
final read = Completer<String?>();
|
||||
final saves = <String>[];
|
||||
final pending = <Completer<void>>[];
|
||||
bool blockWrites = false;
|
||||
@override
|
||||
Future<String?> load() => read.future;
|
||||
@override
|
||||
Future<void> save(String topic) async {
|
||||
saves.add(topic);
|
||||
if (blockWrites) {
|
||||
final gate = Completer<void>();
|
||||
pending.add(gate);
|
||||
await gate.future;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SharedTopicBackend {
|
||||
final firstWrite = Completer<void>();
|
||||
final writes = <String>[];
|
||||
String? value;
|
||||
}
|
||||
|
||||
class SharedQueuedTopicStore implements SettingsTopicStore {
|
||||
SharedQueuedTopicStore(this.backend);
|
||||
final SharedTopicBackend backend;
|
||||
@override
|
||||
Future<String?> load() async => backend.value;
|
||||
@override
|
||||
Future<void> save(String topic) async {
|
||||
backend.writes.add(topic);
|
||||
if (backend.writes.length == 1) await backend.firstWrite.future;
|
||||
backend.value = topic;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('restores selected category after recreation', (tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
await tester.pumpWidget(host(scope: 'server-a'));
|
||||
await tester.pumpAndSettle();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pumpWidget(host(scope: 'server-a'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
final preferences = await SharedPreferences.getInstance();
|
||||
expect(
|
||||
preferences.getString(scopedServerKey(settingsTopicKey, 'server-a')),
|
||||
'connection',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('server scopes and malformed selections are independent', (
|
||||
tester,
|
||||
) async {
|
||||
SharedPreferences.setMockInitialValues({
|
||||
scopedServerKey(settingsTopicKey, 'server-a'): 'connection',
|
||||
scopedServerKey(settingsTopicKey, 'server-b'): 'not-a-topic',
|
||||
});
|
||||
await tester.pumpWidget(host(scope: 'server-a'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
await tester.pumpWidget(host(scope: 'server-b'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('appearance page'), findsOneWidget);
|
||||
await tester.pumpWidget(host(scope: 'server-a'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('standalone category tabs do not read or write preferences', (
|
||||
tester,
|
||||
) async {
|
||||
SharedPreferences.setMockInitialValues({settingsTopicKey: 'updates'});
|
||||
await tester.pumpWidget(host());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('appearance page'), findsOneWidget);
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(
|
||||
(await SharedPreferences.getInstance()).getString(settingsTopicKey),
|
||||
'updates',
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('late restore cannot overwrite a newer user selection', (
|
||||
tester,
|
||||
) async {
|
||||
final store = DelayedStore();
|
||||
await tester.pumpWidget(host(store: store));
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
store.read.complete('updates');
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('connection page'), findsOneWidget);
|
||||
expect(store.saves, ['connection']);
|
||||
});
|
||||
|
||||
testWidgets('writes are serialized so the latest selection wins last', (
|
||||
tester,
|
||||
) async {
|
||||
final store = DelayedStore()..blockWrites = true;
|
||||
store.read.complete(null);
|
||||
await tester.pumpWidget(host(store: store));
|
||||
await tester.pumpAndSettle();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
await selectSettingsTopic(tester, 'Notifications');
|
||||
expect(store.saves, ['connection']);
|
||||
store.pending.first.complete();
|
||||
await tester.pumpAndSettle();
|
||||
expect(store.saves, ['connection', 'notifications']);
|
||||
store.pending.last.complete();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('notifications page'), findsOneWidget);
|
||||
});
|
||||
for (final newerChoice in [false, true]) {
|
||||
testWidgets('recreation preserves accepted B; newer choice: $newerChoice', (
|
||||
tester,
|
||||
) async {
|
||||
final backend = SharedTopicBackend();
|
||||
final store = SharedQueuedTopicStore(backend);
|
||||
await tester.pumpWidget(host(store: store));
|
||||
await tester.pumpAndSettle();
|
||||
await selectSettingsTopic(tester, 'Connection');
|
||||
expect(backend.writes, ['connection']);
|
||||
await selectSettingsTopic(tester, 'Notifications');
|
||||
expect(backend.writes, ['connection']);
|
||||
await tester.pumpWidget(const SizedBox.shrink());
|
||||
await tester.pumpWidget(host(store: store));
|
||||
if (newerChoice) await selectSettingsTopic(tester, 'Tools');
|
||||
backend.firstWrite.complete();
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text(newerChoice ? 'tools page' : 'notifications page'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(backend.value, newerChoice ? 'tools' : 'notifications');
|
||||
expect(backend.writes, [
|
||||
'connection',
|
||||
'notifications',
|
||||
if (newerChoice) 'tools',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('production replacement reads after all accepted old writes', (
|
||||
tester,
|
||||
) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
const oldStore = SharedPreferencesSettingsTopicStore('ownership-check');
|
||||
final gate = Completer<void>();
|
||||
final oldA = orderedLocalStorage(oldStore.key, () async {
|
||||
await gate.future;
|
||||
await (await SharedPreferences.getInstance()).setString(
|
||||
oldStore.key,
|
||||
'connection',
|
||||
);
|
||||
});
|
||||
final oldB = oldStore.save('notifications');
|
||||
final replacement = SharedPreferencesSettingsTopicStore('ownership-check');
|
||||
var readFinished = false;
|
||||
final read = replacement.load().then((value) {
|
||||
readFinished = true;
|
||||
return value;
|
||||
});
|
||||
await tester.pump();
|
||||
expect(readFinished, isFalse);
|
||||
gate.complete();
|
||||
await oldA;
|
||||
await oldB;
|
||||
expect(await read, 'notifications');
|
||||
await replacement.save('tools');
|
||||
expect(
|
||||
(await SharedPreferences.getInstance()).getString(oldStore.key),
|
||||
'tools',
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
Future<void> selectSettingsTopic(WidgetTester tester, String topic) async {
|
||||
final label = find.text(topic).first;
|
||||
await tester.ensureVisible(label);
|
||||
await tester.tap(label);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 350));
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_keys.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_walkthrough_section.dart';
|
||||
import 'package:pipelines_app/ui/theme/app_theme.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Settings reopens the walkthrough on the first page', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
theme: appLightTheme(),
|
||||
home: const Scaffold(body: SettingsWalkthroughSection()),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('Show the walkthrough'), findsOneWidget);
|
||||
expect(find.text('Welcome to Pipelines'), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(SettingsKeys.walkthrough));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Welcome to Pipelines'), findsOneWidget);
|
||||
expect(find.text('Step 1 of 4'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey<String>('walkthrough.skip')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Welcome to Pipelines'), findsNothing);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user