Merge branch 'master' into feat/ui

This commit is contained in:
2026-07-28 18:18:29 +04:00
2 changed files with 44 additions and 4 deletions
@@ -31,7 +31,6 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
_launcherApiClient = launcherApiClient,
_preferencesRepository = preferencesRepository,
_session = session,
_manifest = manifest,
super(
HomeScreenState(
model: HomeScreenModel.initial().copyWith(
@@ -59,7 +58,6 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
StreamSubscription<ClientSyncStatus>? _syncSubscription;
final LauncherSession _session;
final ClientManifest _manifest;
bool _pauseRequested = false;
Future<void> _onHomeScreenLoad(
@@ -147,7 +145,6 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
request: ClientSyncRequest(
installationDir: outputPath.toFilePath(),
accessToken: _session.accessToken,
manifest: _manifest,
),
isCancelled: () async => _pauseRequested,
),
@@ -50,6 +50,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(<String, Object?>{
'files': <Map<String, Object?>>[],
}),
);
await pumpEventQueue(times: 20);
bloc.add(HomeScreenSyncRequested());
await pumpEventQueue(times: 20);
expect(syncUseCase.lastInput, isNotNull);
expect(syncUseCase.lastInput!.request.manifest, isNull);
await bloc.close();
});
});
}
@@ -66,6 +95,16 @@ class _IdleClientSyncUseCase extends ClientSyncUseCase {
}
}
class _CapturingClientSyncUseCase extends _IdleClientSyncUseCase {
ClientSyncUseCaseInput? lastInput;
@override
Stream<ClientSyncStatus> call(ClientSyncUseCaseInput input) {
lastInput = input;
return const Stream<ClientSyncStatus>.empty();
}
}
class _FakeLauncherApiClient extends LauncherApiClient {
_FakeLauncherApiClient({required this.newsItems});
@@ -91,6 +130,10 @@ class _FakeGameInstallationService extends GameInstallationService {
}
class _FakePreferencesRepository implements PreferencesRepository {
_FakePreferencesRepository({this.outputDir});
final Uri? outputDir;
@override
Future<void> clearLauncherSession() async {}
@@ -98,7 +141,7 @@ class _FakePreferencesRepository implements PreferencesRepository {
Future<LauncherSession?> getLauncherSession() async => null;
@override
Future<Uri?> getOutputDir() async => null;
Future<Uri?> getOutputDir() async => outputDir;
@override
Future<MoonWellThemeVariant> getThemeVariant() async =>