Files
buzz/mobile/test/features/profile/profile_setup_fallback_test.dart
klopez4212 a2540fbe3d Align Android profile setup with iOS steps (#8871)
Android profile setup now matches iOS: choose a display name, then an
optional avatar using the existing dotted-circle placeholder and Image /
Emoji / Animated editor. Back preserves drafts; Skip saves the name
without an avatar, and failed saves retain retry/exit options.

Validated on Pixel 10 and approved by Kenny; analysis clean, 4,064
mobile tests passed (8 skipped). Device preview uses no-write callbacks;
preview-only files are excluded.

| Display name | Avatar |
| --- | --- |
| ![Display name
step](https://github.com/user-attachments/assets/516361ea-2c02-4ed5-8847-f716ed5c0272)
| ![Avatar
step](https://github.com/user-attachments/assets/2a1607e0-59dd-4ff6-9ffa-a1dd13faad3e)
|

buzz-review-completed

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
2026-10-31 17:08:39 +00:00

83 lines
3.0 KiB
Dart

import 'dart:async';
import 'package:buzz/shared/hosted/hosted_flow.dart';
import 'package:buzz/features/profile/profile_setup_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../helpers/hosted_communities_fixture.dart';
import '../../helpers/widget_helpers.dart';
void main() {
testWidgets('failed fallback save can continue without saving', (
tester,
) async {
FlutterSecureStorage.setMockInitialValues({});
final fixture = HostedCommunitiesFixture();
await fixture.initialize(widget: true);
addTearDown(fixture.dispose);
var attempts = 0;
final release = Completer<void>();
final pending = fixture.flow.requestProfile((_) async {
attempts++;
await release.future;
throw StateError('Relay unavailable');
});
await tester.pumpWidget(
WidgetHelpers.testable(
disableAnimations: true,
child: ProfileSetupPage(flow: fixture.flow),
),
);
await tester.pump();
await tester.pump();
final route = ModalRoute.of(tester.element(find.byType(TextField)))!;
expect(route.transitionDuration, Duration.zero);
expect(route.reverseTransitionDuration, Duration.zero);
expect(route.animation!.isCompleted, isTrue);
expect(find.text('Not now'), findsNothing);
expect(find.byTooltip('Back'), findsNothing);
await tester.binding.handlePopRoute();
await tester.pump();
expect(fixture.flow.stage, HostedFlowStage.profile);
await tester.enterText(find.byType(TextField), 'Kenny');
await tester.pump();
await tester.tap(find.text('Continue'));
await tester.pump();
expect(find.text('Choose your avatar'), findsOneWidget);
expect(attempts, 0);
expect(
tester.widget<FilledButton>(find.byType(FilledButton)).onPressed,
isNull,
);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(
tester.widget<TextField>(find.byType(TextField)).controller!.text,
'Kenny',
);
await tester.tap(find.text('Continue'));
await tester.pumpAndSettle();
await tester.ensureVisible(find.text('Skip'));
await tester.tap(find.text('Skip'));
await tester.pump();
expect(find.text('Saving…'), findsOneWidget);
await tester.binding.handlePopRoute();
await tester.pump();
expect(fixture.flow.stage, HostedFlowStage.profile);
expect(find.text('Saving…'), findsOneWidget);
release.complete();
await tester.pumpAndSettle();
expect(attempts, 1);
expect(find.text('Not now'), findsOneWidget);
await tester.ensureVisible(find.text('Not now'));
await tester.pumpAndSettle();
await tester.tap(find.text('Not now').hitTestable());
await tester.pumpAndSettle();
await pending;
expect(attempts, 1);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pumpAndSettle();
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
}