mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-11-30 01:34:57 +01:00
- Mobile opens on a welcome screen whose headline reveals word by word, then the subtitle, the three what-you'll-do rows and the actions. 'I'll set this up later' records completion, so a rider who declines isn't asked again on every launch. Desktop keeps its rail-framed step 1. - Dark mode: colorScheme.primary is only the brand blue in the LIGHT theme, so white-on-primary icons and check marks were invisible (the Network tile above all). New onboardingAccent()/onboardingOnAccent keep the brand accent in both themes, lightened for dark. - Step 4's blocked state read as 'Virtual Shifting doesn't work here'; it now leads with 'Optional: connect your smart trainer' and says plainly that VS does work — just not with both apps on one phone. The normal step regains the design's 'Optional:' prefix too. - 'See Pro & Base options' goes through IAPManager again, so iOS/Android get RevenueCat's hosted paywall instead of the desktop fallback with placeholder 'about x €' prices (_loadRevenueCatPricing is macOS-only). The desktop paywall keeps pull-to-dismiss, now for every caller. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
101 lines
4.1 KiB
Dart
101 lines
4.1 KiB
Dart
// Regression: tapping the Local method tile on step 5 opened the permission
|
|
// sheet with a context above the wizard's Scaffold ("No DrawerOverlay found")
|
|
// because _body/_footer were built with the page-level context. This walks
|
|
// the real wizard to step 5 and taps Local.
|
|
import 'package:bike_control/gen/l10n.dart';
|
|
import 'package:bike_control/main.dart' show OtherLocalizationsDelegate;
|
|
import 'package:bike_control/pages/onboarding/steps/step_app.dart' show OnboardingAppTile;
|
|
import 'package:bike_control/pages/onboarding/onboarding_page.dart';
|
|
import 'package:bike_control/utils/core.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shadcn_flutter/shadcn_flutter.dart';
|
|
|
|
import 'widget_snapshot.dart';
|
|
|
|
Future<void> main() async {
|
|
await ensureSnapshotHarness();
|
|
|
|
testWidgets('Local tile on step 5 opens the permission sheet without crashing', (tester) async {
|
|
// Deny the keypress-simulator permission so the sheet path runs (there's
|
|
// no native plugin in tests) — and the toggle must then stay OFF.
|
|
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
|
const MethodChannel('dev.leanflutter.plugins/keypress_simulator'),
|
|
(call) async => false,
|
|
);
|
|
addTearDown(() => tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
|
|
const MethodChannel('dev.leanflutter.plugins/keypress_simulator'), null));
|
|
|
|
tester.view.physicalSize = const Size(390, 800) * 3.0;
|
|
tester.view.devicePixelRatio = 3.0;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
|
|
// Keep the controller step from kicking off a real BLE scan in the test
|
|
// environment — performScanning early-returns while isScanning is set.
|
|
core.connection.isScanning.value = true;
|
|
addTearDown(() => core.connection.isScanning.value = false);
|
|
|
|
await tester.pumpWidget(
|
|
ShadcnApp(
|
|
debugShowCheckedModeBanner: false,
|
|
localizationsDelegates: [
|
|
...ShadcnLocalizations.localizationsDelegates,
|
|
const OtherLocalizationsDelegate(),
|
|
AppLocalizations.delegate,
|
|
],
|
|
supportedLocales: AppLocalizations.delegate.supportedLocales,
|
|
theme: ThemeData(colorScheme: ColorSchemes.lightSlate, radius: 0.7),
|
|
home: const OnboardingPage(),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
|
|
Future<void> settle() async {
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 350));
|
|
}
|
|
|
|
Future<void> tapContinue() async {
|
|
await tester.tap(find.byType(PrimaryButton).last);
|
|
await settle();
|
|
}
|
|
|
|
// Mobile now opens on the welcome screen — enter the wizard first.
|
|
await tester.tap(find.byType(PrimaryButton).last);
|
|
await settle();
|
|
|
|
// Step 1: pick the first app, continue.
|
|
await tester.tap(find.byType(OnboardingAppTile).first);
|
|
await settle();
|
|
await tapContinue();
|
|
|
|
// Step 2: pick "on this device", continue.
|
|
await tester.tap(find.byKey(const ValueKey('onboarding-where-thisDevice')));
|
|
await settle();
|
|
await tapContinue();
|
|
|
|
// Step 3 (controller): footer's last GhostButton is "can't find" /
|
|
// "set up later" depending on phase — press through to step 4.
|
|
await tester.tap(find.byType(GhostButton).last);
|
|
await settle();
|
|
await tester.tap(find.byType(GhostButton).last);
|
|
await settle();
|
|
|
|
// Step 4 (virtual shifting): ghost footer skips it.
|
|
await tester.tap(find.byType(GhostButton).last);
|
|
await settle();
|
|
|
|
// Step 5: tap the Local method tile (keyboard icon).
|
|
expect(find.byIcon(LucideIcons.keyboard), findsOneWidget, reason: 'should be on step 5');
|
|
await tester.tap(find.byIcon(LucideIcons.keyboard));
|
|
await settle();
|
|
await tester.pump(const Duration(milliseconds: 400));
|
|
|
|
expect(tester.takeException(), isNull, reason: 'Local toggle must not crash (DrawerOverlay regression)');
|
|
// Permissions were denied — Local must not report itself enabled.
|
|
expect(core.settings.getLocalEnabled(), isFalse,
|
|
reason: 'Local must stay off when its permissions are not granted');
|
|
});
|
|
}
|