mirror of
https://github.com/jonasbark/swiftcontrol.git
synced 2026-12-04 12:42:18 +01:00
Desktop was routed straight into step 1's rail, which asks a rider to pick a trainer app before anything has said what BikeControl does or how long setup takes. The one screen that answers "what am I about to agree to" was the one desktop never saw. The screen was built for a phone column — Spacers, full-width buttons, 24px padding — so simply unlocking it would have stretched a column of short lines across a 1400px window. It is capped to kOnboardingBodyMaxWidth, the same measure the wizard's own body uses on desktop, so stepping from the welcome into the rail keeps the text at one width instead of snapping narrower. step_app's update banner already keyed off _showedWelcome, so the offer moves to the welcome screen on desktop by itself and never appears twice; only its comment claimed desktop had no welcome screen. The existing test asserted the behaviour being removed, so it is rewritten around the new one, plus a case pinning the readable measure on a wide window — that cap is the whole reason this doesn't look wrong on desktop. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
95 lines
4.2 KiB
Dart
95 lines
4.2 KiB
Dart
// The wizard opens on the welcome screen on every platform — desktop riders
|
|
// used to be dropped straight into step 1's rail, so the one screen that says
|
|
// what BikeControl does and how long setup takes was the one they never saw.
|
|
// "I'll set this up later" must record completion so a rider who declines
|
|
// isn't asked again on the next launch.
|
|
import 'package:bike_control/gen/l10n.dart';
|
|
import 'package:bike_control/main.dart' show OtherLocalizationsDelegate;
|
|
import 'package:bike_control/pages/onboarding/onboarding_page.dart';
|
|
import 'package:bike_control/pages/onboarding/steps/step_app.dart' show OnboardingAppTile;
|
|
import 'package:bike_control/pages/onboarding/steps/step_welcome.dart';
|
|
import 'package:bike_control/utils/core.dart';
|
|
import 'package:bike_control/utils/settings/settings.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();
|
|
|
|
Future<void> pumpWizard(WidgetTester tester, Size size) async {
|
|
tester.view.physicalSize = size * 3.0;
|
|
tester.view.devicePixelRatio = 3.0;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
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();
|
|
await tester.pump(const Duration(milliseconds: 1600));
|
|
}
|
|
|
|
testWidgets('mobile opens on the welcome screen and can enter the wizard', (tester) async {
|
|
await core.settings.setOnboardingState(Settings.onboardingStatePending);
|
|
await pumpWizard(tester, const Size(390, 800));
|
|
|
|
expect(find.byType(OnboardingWelcome), findsOneWidget);
|
|
expect(find.byType(OnboardingAppTile), findsNothing, reason: 'step 1 comes after the welcome screen');
|
|
|
|
await tester.tap(find.byType(PrimaryButton).last);
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 500));
|
|
expect(find.byType(OnboardingWelcome), findsNothing);
|
|
expect(find.byType(OnboardingAppTile), findsWidgets);
|
|
});
|
|
|
|
testWidgets('desktop opens on the welcome screen too, and can enter the wizard', (tester) async {
|
|
await core.settings.setOnboardingState(Settings.onboardingStatePending);
|
|
await pumpWizard(tester, const Size(1100, 800));
|
|
|
|
expect(find.byType(OnboardingWelcome), findsOneWidget);
|
|
expect(find.byType(OnboardingAppTile), findsNothing, reason: 'step 1 comes after the welcome screen');
|
|
|
|
await tester.tap(find.byType(PrimaryButton).last);
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 500));
|
|
expect(find.byType(OnboardingWelcome), findsNothing);
|
|
expect(find.byType(OnboardingAppTile), findsWidgets);
|
|
});
|
|
|
|
testWidgets('the welcome screen keeps a readable measure on a wide window', (tester) async {
|
|
await core.settings.setOnboardingState(Settings.onboardingStatePending);
|
|
await pumpWizard(tester, const Size(1400, 900));
|
|
|
|
// Capped to the same width the wizard's own body uses, so stepping from
|
|
// here into the rail doesn't snap the text narrower.
|
|
final width = tester.getSize(find.byType(OnboardingWelcome)).width;
|
|
expect(width, 1400);
|
|
final column = tester.getSize(find.byType(Wrap).first).width;
|
|
expect(column, lessThanOrEqualTo(kOnboardingBodyMaxWidth));
|
|
});
|
|
|
|
testWidgets('"set up later" records completion so the wizard stops nagging', (tester) async {
|
|
await core.settings.setOnboardingState(Settings.onboardingStatePending);
|
|
await pumpWizard(tester, const Size(390, 800));
|
|
|
|
await tester.tap(find.byType(GhostButton).last);
|
|
await tester.pump();
|
|
await tester.pump(const Duration(milliseconds: 400));
|
|
expect(core.settings.getOnboardingState(), Settings.onboardingStateCompleted);
|
|
});
|
|
}
|