mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
test(mobile): cover authenticated age gate
Co-authored-by: Tom Brow <tomb@block.xyz> Signed-off-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
co-authored by
Tom Brow
parent
0d86e46b7c
commit
4ded04c4a7
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:buzz/app.dart';
|
||||
import 'package:buzz/features/age_gate/age_restriction_page.dart';
|
||||
import 'package:buzz/features/age_gate/age_signal_provider.dart';
|
||||
import 'package:buzz/features/home/home_page.dart';
|
||||
import 'package:buzz/shared/auth/auth.dart';
|
||||
import 'package:buzz/shared/theme/theme_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -18,6 +19,26 @@ void main() {
|
||||
.setMockMethodCallHandler(ageSignalChannel, null);
|
||||
});
|
||||
|
||||
testWidgets('blocks authenticated app content', (tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
authProvider.overrideWith(() => _AuthenticatedAuthNotifier()),
|
||||
ageSignalProvider.overrideWith(() => _BlockingAgeSignalNotifier()),
|
||||
savedPrefsProvider.overrideWithValue(prefs),
|
||||
],
|
||||
child: const App(),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byType(AgeRestrictionPage), findsOneWidget);
|
||||
expect(find.byType(HomePage), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('requests after the first frame and gates pushed routes', (
|
||||
tester,
|
||||
) async {
|
||||
@@ -63,6 +84,18 @@ void main() {
|
||||
});
|
||||
}
|
||||
|
||||
class _AuthenticatedAuthNotifier extends AuthNotifier {
|
||||
@override
|
||||
Future<AuthState> build() async {
|
||||
return const AuthState(status: AuthStatus.authenticated);
|
||||
}
|
||||
}
|
||||
|
||||
class _BlockingAgeSignalNotifier extends AgeSignalNotifier {
|
||||
@override
|
||||
bool build() => true;
|
||||
}
|
||||
|
||||
class _FakeAuthNotifier extends AuthNotifier {
|
||||
@override
|
||||
Future<AuthState> build() async {
|
||||
|
||||
Reference in New Issue
Block a user