test(session): cover avatar refresh and session teardown

Add regression tests for avatar reset and token-change refresh, stale 401 handling, idempotent session teardown and account-scoped preference cleanup. Update existing cubit tests for the new session dependency.

Refs: #1113
This commit is contained in:
2026-10-30 15:15:36 +03:00
parent cba2689406
commit 51aff6c175
20 changed files with 684 additions and 67 deletions

View File

@@ -4,6 +4,8 @@ import 'package:eatvio_app/features/profile/repositories/profile_repository.dart
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/annotations.dart';
import 'package:mockito/mockito.dart';
import '../../../../fixtures/doubles/session_doubles.dart';
import 'menu_cubit_test.mocks.dart';
@GenerateNiceMocks([MockSpec<ProfileRepository>()])
@@ -25,12 +27,12 @@ void main() {
});
test('начальное состояние - MenuState', () {
menuCubit = MenuCubit(mockProfileRepository);
menuCubit = MenuCubit(mockProfileRepository, FakeSessionLifecycleService());
expect(menuCubit!.state, isA<MenuState>());
});
test('makePassKey - успешно создает passKey', () async {
menuCubit = MenuCubit(mockProfileRepository);
menuCubit = MenuCubit(mockProfileRepository, FakeSessionLifecycleService());
const expectedPassKey = 'test-pass-key';
when(mockProfileRepository.getPassKey(
@@ -48,7 +50,7 @@ void main() {
});
test('makePassKey - возвращает null при ошибке', () async {
menuCubit = MenuCubit(mockProfileRepository);
menuCubit = MenuCubit(mockProfileRepository, FakeSessionLifecycleService());
when(mockProfileRepository.getPassKey(
routeName: 'product_nutritional_value.index',