Add end-to-end auth session widget flow test
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:relationship_saver/core/auth/in_memory_token_store.dart';
|
||||
import 'package:relationship_saver/features/local/storage/local_data_store_in_memory.dart';
|
||||
import 'package:relationship_saver/features/local/storage/local_data_store_provider.dart';
|
||||
import 'package:relationship_saver/features/sync/storage/sync_state_store_in_memory.dart';
|
||||
import 'package:relationship_saver/features/sync/storage/sync_state_store_provider.dart';
|
||||
import 'package:relationship_saver/integrations/backend/backend_gateway_fake.dart';
|
||||
import 'package:relationship_saver/integrations/backend/backend_gateway_provider.dart';
|
||||
import 'package:relationship_saver/main.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
void main() {
|
||||
setUp(() {
|
||||
SharedPreferences.setMockInitialValues(<String, Object>{});
|
||||
});
|
||||
|
||||
testWidgets('sign-in and sign-out session flow works end-to-end', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.binding.setSurfaceSize(const Size(1280, 800));
|
||||
addTearDown(() => tester.binding.setSurfaceSize(null));
|
||||
|
||||
await tester.pumpWidget(
|
||||
ProviderScope(
|
||||
overrides: [
|
||||
tokenStoreProvider.overrideWithValue(InMemoryTokenStore()),
|
||||
backendGatewayProvider.overrideWithValue(BackendGatewayFake()),
|
||||
localDataStoreProvider.overrideWithValue(InMemoryLocalDataStore()),
|
||||
syncStateStoreProvider.overrideWithValue(InMemorySyncStateStore()),
|
||||
],
|
||||
child: const RelationshipSaverApp(),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Sign in to continue'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.widgetWithText(FilledButton, 'Sign In'));
|
||||
await tester.pumpAndSettle(const Duration(milliseconds: 450));
|
||||
|
||||
expect(find.text('Dashboard'), findsWidgets);
|
||||
|
||||
await tester.tap(find.text('Settings').first);
|
||||
await tester.pumpAndSettle(const Duration(milliseconds: 450));
|
||||
|
||||
expect(
|
||||
find.text('Environment and integration configuration for this build.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
await tester.tap(find.widgetWithText(FilledButton, 'Sign Out'));
|
||||
await tester.pumpAndSettle(const Duration(milliseconds: 450));
|
||||
|
||||
expect(find.text('Sign in to continue'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user