Keep settings and delivery updates together
Preserve the reviewed grouped Settings page while fixing its embedded phone safe area, and land the accompanying notification, walkthrough, terminal, and documentation updates captured by this run.
This commit is contained in:
@@ -18,6 +18,9 @@ Widget _host(
|
||||
return MaterialApp(home: Scaffold(body: body));
|
||||
}
|
||||
|
||||
int _requests(FakeNotificationService service) =>
|
||||
service.calls.where((call) => call.$1 == 'requestBatteryExemption').length;
|
||||
|
||||
bool _switchValue(WidgetTester tester) {
|
||||
final tile = find.byKey(DeviceDeliveryKeys.toggle);
|
||||
return tester.widget<SwitchListTile>(tile).value;
|
||||
@@ -62,9 +65,11 @@ void main() {
|
||||
testWidgets('allow background delivery asks for the exemption', (
|
||||
tester,
|
||||
) async {
|
||||
final service = FakeNotificationService();
|
||||
final service = FakeNotificationService()..batteryGranted = false;
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
// The open-time prompt was declined; the row is the user's second try.
|
||||
service.batteryGranted = true;
|
||||
await tester.tap(find.text(deviceDeliveryBatteryLabel));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
@@ -125,6 +130,157 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(DeviceDeliveryKeys.error), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'a missing battery exemption keeps a warning row with the Samsung note',
|
||||
(tester) async {
|
||||
// The open-time prompt is declined, so the exemption stays missing.
|
||||
final service = FakeNotificationService()..batteryGranted = false;
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsOneWidget);
|
||||
expect(find.text(deviceDeliveryWarningTitle), findsOneWidget);
|
||||
expect(find.textContaining(deviceDeliverySamsungNote), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('the warning goes away once the exemption is granted', (
|
||||
tester,
|
||||
) async {
|
||||
final service = FakeNotificationService()..batteryGranted = false;
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsOneWidget);
|
||||
service.batteryGranted = true;
|
||||
await tester.tap(find.text(deviceDeliveryBatteryLabel));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('switching on asks for the battery exemption before starting', (
|
||||
tester,
|
||||
) async {
|
||||
final service = FakeNotificationService();
|
||||
service.current = service.copy(enabled: false, state: DeliveryState.off);
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.byKey(DeviceDeliveryKeys.toggle));
|
||||
await tester.pumpAndSettle();
|
||||
final names = service.calls.map((call) => call.$1).toList();
|
||||
expect(names, contains('requestBatteryExemption'));
|
||||
expect(
|
||||
names.indexOf('requestBatteryExemption'),
|
||||
lessThan(names.indexOf('setEnabled')),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'opening Settings with delivery on and no exemption asks right away',
|
||||
(tester) async {
|
||||
final service = FakeNotificationService();
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_requests(service), 1);
|
||||
expect(
|
||||
find.text('Allowed: battery optimisation will not pause delivery'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsNothing);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('a declined open-time prompt is not repeated on resume', (
|
||||
tester,
|
||||
) async {
|
||||
final service = FakeNotificationService()..batteryGranted = false;
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_requests(service), 1);
|
||||
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsOneWidget);
|
||||
// Returning from the system screen re-reads the status only.
|
||||
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.inactive);
|
||||
tester.binding.handleAppLifecycleStateChanged(AppLifecycleState.resumed);
|
||||
await tester.pumpAndSettle();
|
||||
expect(_requests(service), 1);
|
||||
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('no open-time prompt when the exemption is already granted', (
|
||||
tester,
|
||||
) async {
|
||||
final service = FakeNotificationService();
|
||||
service.current = service.copy(batteryExempt: true);
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_requests(service), 0);
|
||||
});
|
||||
|
||||
testWidgets('no open-time prompt while delivery is off', (tester) async {
|
||||
final service = FakeNotificationService();
|
||||
service.current = service.copy(enabled: false, state: DeliveryState.off);
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_requests(service), 0);
|
||||
});
|
||||
|
||||
testWidgets('no warning while delivery is off', (tester) async {
|
||||
final service = FakeNotificationService();
|
||||
service.current = service.copy(enabled: false, state: DeliveryState.off);
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(DeviceDeliveryKeys.batteryWarning), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('a refused session says the user must sign in again', (
|
||||
tester,
|
||||
) async {
|
||||
final service = FakeNotificationService();
|
||||
service.current = service.copy(state: DeliveryState.signInRequired);
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.text('Sign in to Pipelines again to keep notifications'),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'the connection log lists the service events, failures included',
|
||||
(tester) async {
|
||||
final service = FakeNotificationService();
|
||||
service.events = [
|
||||
NotificationConnectionEvent(
|
||||
time: DateTime(2026, 11, 12, 9, 30, 5),
|
||||
event: 'failed',
|
||||
error: 'Expected HTTP 101',
|
||||
code: 403,
|
||||
),
|
||||
NotificationConnectionEvent(
|
||||
time: DateTime(2026, 11, 12, 9, 29),
|
||||
event: 'connected',
|
||||
),
|
||||
];
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text(deviceDeliveryLogTitle));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Socket failed'), findsOneWidget);
|
||||
expect(
|
||||
find.textContaining('HTTP 403 · Expected HTTP 101'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Socket opened'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('an empty connection log says so', (tester) async {
|
||||
final service = FakeNotificationService();
|
||||
await tester.pumpWidget(_host(service));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text(deviceDeliveryLogTitle));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(deviceDeliveryLogEmpty), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
class _FailingService extends FakeNotificationService {
|
||||
|
||||
@@ -413,6 +413,61 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user