From 3134ecad0f4ba93308dbcec8918bcc11d977682a Mon Sep 17 00:00:00 2001 From: sindoring Date: Sun, 19 Jul 2026 16:09:51 +0400 Subject: [PATCH] refresh manifest before client sync --- .../home_screen/bloc/home_screen_bloc.dart | 3 -- .../bloc/home_screen_bloc_test.dart | 45 ++++++++++++++++++- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/lib/app/home_screen/bloc/home_screen_bloc.dart b/lib/app/home_screen/bloc/home_screen_bloc.dart index a9f4231..f3a21f0 100644 --- a/lib/app/home_screen/bloc/home_screen_bloc.dart +++ b/lib/app/home_screen/bloc/home_screen_bloc.dart @@ -31,7 +31,6 @@ class HomeScreenBloc extends Bloc { _launcherApiClient = launcherApiClient, _preferencesRepository = preferencesRepository, _session = session, - _manifest = manifest, super( HomeScreenState( model: HomeScreenModel.initial().copyWith( @@ -59,7 +58,6 @@ class HomeScreenBloc extends Bloc { StreamSubscription? _syncSubscription; final LauncherSession _session; - final ClientManifest _manifest; bool _pauseRequested = false; Future _onHomeScreenLoad( @@ -146,7 +144,6 @@ class HomeScreenBloc extends Bloc { request: ClientSyncRequest( installationDir: outputPath.toFilePath(), accessToken: _session.accessToken, - manifest: _manifest, ), isCancelled: () async => _pauseRequested, ), diff --git a/test/app/home_screen/bloc/home_screen_bloc_test.dart b/test/app/home_screen/bloc/home_screen_bloc_test.dart index be0aef9..a1d3748 100644 --- a/test/app/home_screen/bloc/home_screen_bloc_test.dart +++ b/test/app/home_screen/bloc/home_screen_bloc_test.dart @@ -49,6 +49,35 @@ void main() { await bloc.close(); }); + + test('fetches a fresh manifest for every client sync', () async { + final syncUseCase = _CapturingClientSyncUseCase(); + final bloc = HomeScreenBloc( + clientSyncUseCase: syncUseCase, + gameInstallationService: _FakeGameInstallationService(), + launcherApiClient: _FakeLauncherApiClient(newsItems: const []), + preferencesRepository: _FakePreferencesRepository( + outputDir: Uri.directory('C:/World of Warcraft'), + ), + session: LauncherSession( + accessToken: 'token', + tokenType: 'Bearer', + expiresAt: null, + ), + manifest: ClientManifest.fromJson({ + 'files': >[], + }), + ); + + await pumpEventQueue(times: 20); + bloc.add(HomeScreenSyncRequested()); + await pumpEventQueue(times: 20); + + expect(syncUseCase.lastInput, isNotNull); + expect(syncUseCase.lastInput!.request.manifest, isNull); + + await bloc.close(); + }); }); } @@ -65,6 +94,16 @@ class _IdleClientSyncUseCase extends ClientSyncUseCase { } } +class _CapturingClientSyncUseCase extends _IdleClientSyncUseCase { + ClientSyncUseCaseInput? lastInput; + + @override + Stream call(ClientSyncUseCaseInput input) { + lastInput = input; + return const Stream.empty(); + } +} + class _FakeLauncherApiClient extends LauncherApiClient { _FakeLauncherApiClient({required this.newsItems}); @@ -90,6 +129,10 @@ class _FakeGameInstallationService extends GameInstallationService { } class _FakePreferencesRepository implements PreferencesRepository { + _FakePreferencesRepository({this.outputDir}); + + final Uri? outputDir; + @override Future clearLauncherSession() async {} @@ -97,7 +140,7 @@ class _FakePreferencesRepository implements PreferencesRepository { Future getLauncherSession() async => null; @override - Future getOutputDir() async => null; + Future getOutputDir() async => outputDir; @override Future setLauncherSession(LauncherSession session) async {}