From 83cdc130e54673dfcaae2e3ba47513f3fd5301af Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Mon, 9 Sep 2024 04:46:46 +0530 Subject: [PATCH] Update integration test --- integration_test/test_helper.dart | 17 +++++++++++++---- lib/main.dart | 12 +++++++++--- lib/services/hive_services.dart | 4 ++-- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/integration_test/test_helper.dart b/integration_test/test_helper.dart index 70cafa9d..4cb151dc 100644 --- a/integration_test/test_helper.dart +++ b/integration_test/test_helper.dart @@ -1,3 +1,5 @@ +import 'package:apidash/models/settings_model.dart'; +import 'package:apidash/providers/providers.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -34,17 +36,24 @@ class ApidashTestHelper { final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized(); binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive; - await app.initApp(); + await app.initApp(false); await app.initWindow(sz: size); return binding; } static Future loadApp(WidgetTester tester) async { - await app.initApp(); + await app.initApp(false); await tester.pumpWidget( - const ProviderScope( - child: DashApp(), + ProviderScope( + overrides: [ + settingsProvider.overrideWith( + (ref) => ThemeStateNotifier( + settingsModel: const SettingsModel() + .copyWithPath(workspaceFolderPath: "test")), + ) + ], + child: const DashApp(), ), ); } diff --git a/lib/main.dart b/lib/main.dart index b5fa019f..51fbd840 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,7 +11,10 @@ import 'app.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); var settingsModel = await getSettingsFromSharedPrefs(); - final initStatus = await initApp(settingsModel: settingsModel); + final initStatus = await initApp( + kIsDesktop, + settingsModel: settingsModel, + ); if (kIsDesktop) { await initWindow(settingsModel: settingsModel); } @@ -31,11 +34,14 @@ void main() async { ); } -Future initApp({SettingsModel? settingsModel}) async { +Future initApp( + bool initializeUsingPath, { + SettingsModel? settingsModel, +}) async { GoogleFonts.config.allowRuntimeFetching = false; try { final openBoxesStatus = await openBoxes( - kIsDesktop, + initializeUsingPath, settingsModel?.workspaceFolderPath, ); debugPrint("openBoxesStatus: $openBoxesStatus"); diff --git a/lib/services/hive_services.dart b/lib/services/hive_services.dart index fab18540..cc7f8960 100644 --- a/lib/services/hive_services.dart +++ b/lib/services/hive_services.dart @@ -11,11 +11,11 @@ const String kHistoryBoxIds = "historyIds"; const String kHistoryLazyBox = "apidash-history-lazy"; Future openBoxes( - bool isDesktop, + bool initializeUsingPath, String? workspaceFolderPath, ) async { try { - if (isDesktop) { + if (initializeUsingPath) { if (workspaceFolderPath != null) { Hive.init(workspaceFolderPath); } else {