Connect sign-up to Sendico Facts intake (#46)

This commit is contained in:
Stephan D committed 2026-10-15 00:55:19 +02:00
1 parent 30f0455122
commit a584c8189a
40 files changed
+1616 -35

No files matched your search

+80
View File
@@ -6,6 +6,8 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:go_router/go_router.dart';
import 'package:sxchnge_analytics/sxchnge_analytics.dart';
import 'package:sxchnge_auth/sxchnge_auth.dart';
import 'package:sxchnge_app/main.dart';
@@ -41,6 +43,84 @@ class UnverifiedBackend extends BackendAuthServices {
}
void main() {
for (final language in ['en', 'ru']) {
testWidgets(
'signup requiring assistance preserves input and records failure ($language)',
(tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
tester.platformDispatcher.textScaleFactorTestValue = 1.5;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
final analytics = DummyAnalyticsService();
final locale = LocaleProvider(initialLocale: Locale(language));
await tester.pumpWidget(
SxchngeApp(
localeProvider: locale,
analyticsService: analytics,
signupService: const DummySignupService(
delay: Duration.zero,
failure: AuthError.signupNeedsAssistance,
),
),
);
await tester.pumpAndSettle();
final signupLabel = language == 'ru' ? 'Регистрация' : 'Sign up';
await tester.ensureVisible(find.text(signupLabel));
await tester.tap(find.text(signupLabel));
await tester.pumpAndSettle();
for (final entry in {
'name': 'Ada Lovelace',
'email': 'ada@example.com',
'password': 'password preserved',
'confirmation': 'password preserved',
}.entries) {
await tester.enterText(find.byKey(ValueKey(entry.key)), entry.value);
}
await tester.ensureVisible(find.byKey(const ValueKey('submit')));
await tester.tap(find.byKey(const ValueKey('submit')));
await tester.pumpAndSettle();
final feedback = find.byKey(const ValueKey('auth-error'));
await tester.ensureVisible(feedback);
expect(
find.text(
language == 'ru'
? 'Не удалось завершить создание аккаунта. Обратитесь в службу поддержки.'
: 'We could not finish setting up your account. Please contact support.',
),
findsOneWidget,
);
expect(find.byKey(const ValueKey('verification-sent')), findsNothing);
expect(
tester
.widget<TextFormField>(find.byKey(const ValueKey('email')))
.controller!
.text,
'ada@example.com',
);
expect(
tester
.widget<TextFormField>(find.byKey(const ValueKey('password')))
.controller!
.text,
'password preserved',
);
expect(
analytics.events.where((event) => event.name == 'auth_signup_failed'),
hasLength(1),
);
expect(
analytics.events.where(
(event) => event.name == 'auth_signup_succeeded',
),
isEmpty,
);
expect(tester.takeException(), isNull);
},
);
}
testWidgets('backend mode gates workspace and recovers unverified login', (
tester,
) async {