Merge branch 'main' into resolve-issue-env-field

This commit is contained in:
Ragul Raj
2024-07-11 23:26:36 +05:30
committed by GitHub
17 changed files with 258 additions and 256 deletions

View File

@ -11,7 +11,6 @@ import 'package:apidash/screens/home_page/editor_pane/editor_default.dart';
import 'package:apidash/screens/home_page/editor_pane/editor_pane.dart';
import 'package:apidash/screens/home_page/editor_pane/url_card.dart';
import 'package:apidash/screens/home_page/home_page.dart';
import 'package:apidash/screens/intro_page.dart';
import 'package:apidash/screens/settings_page.dart';
import 'package:apidash/services/hive_services.dart';
import 'package:apidash/widgets/widgets.dart';
@ -58,7 +57,6 @@ void main() {
// Verify that the HomePage is displayed initially
expect(find.byType(HomePage), findsOneWidget);
expect(find.byType(EnvironmentPage), findsNothing);
expect(find.byType(IntroPage), findsNothing);
expect(find.byType(SettingsPage), findsNothing);
});
@ -79,12 +77,11 @@ void main() {
// Verify that the EnvironmentPage is displayed
expect(find.byType(HomePage), findsNothing);
expect(find.byType(EnvironmentPage), findsOneWidget);
expect(find.byType(IntroPage), findsNothing);
expect(find.byType(SettingsPage), findsNothing);
});
testWidgets(
"Dashboard should display IntroPage when navRailIndexStateProvider is 2",
"Dashboard should display SettingsPage when navRailIndexStateProvider is 2",
(WidgetTester tester) async {
await tester.pumpWidget(
ProviderScope(
@ -99,33 +96,9 @@ void main() {
),
);
// Verify that the IntroPage is displayed
expect(find.byType(HomePage), findsNothing);
expect(find.byType(EnvironmentPage), findsNothing);
expect(find.byType(IntroPage), findsOneWidget);
expect(find.byType(SettingsPage), findsNothing);
});
testWidgets(
"Dashboard should display SettingsPage when navRailIndexStateProvider is 3",
(WidgetTester tester) async {
await tester.pumpWidget(
ProviderScope(
overrides: [
navRailIndexStateProvider.overrideWith((ref) => 3),
],
child: const Portal(
child: MaterialApp(
home: Dashboard(),
),
),
),
);
// Verify that the SettingsPage is displayed
expect(find.byType(HomePage), findsNothing);
expect(find.byType(EnvironmentPage), findsNothing);
expect(find.byType(IntroPage), findsNothing);
expect(find.byType(SettingsPage), findsOneWidget);
});
@ -142,8 +115,8 @@ void main() {
),
);
// Tap on the Intro icon
await tester.tap(find.byIcon(Icons.help_outline));
// Tap on the Settings icon
await tester.tap(find.byIcon(Icons.settings_outlined));
await tester.pump();
// Verify that the navRailIndexStateProvider is updated
@ -184,11 +157,10 @@ void main() {
// Verify that the navRailIndexStateProvider still has the updated value
final dashboard = tester.element(find.byType(Dashboard));
final container = ProviderScope.containerOf(dashboard);
expect(container.read(navRailIndexStateProvider), 3);
expect(container.read(navRailIndexStateProvider), 2);
// Verify that the SettingsPage is still displayed after the rebuild
expect(find.byType(SettingsPage), findsOneWidget);
expect(find.byType(IntroPage), findsNothing);
expect(find.byType(HomePage), findsNothing);
expect(find.byType(EnvironmentPage), findsNothing);
});
@ -219,17 +191,8 @@ void main() {
// Verify that the selected icon is the filled version (selectedIcon)
expect(find.byIcon(Icons.computer_rounded), findsOneWidget);
// Go to IntroPage
container.read(navRailIndexStateProvider.notifier).state = 2;
await tester.pump();
// Verify that the IntroPage is displayed
expect(find.byType(IntroPage), findsOneWidget);
// Verify that the selected icon is the filled version (selectedIcon)
expect(find.byIcon(Icons.help), findsOneWidget);
// Go to SettingsPage
container.read(navRailIndexStateProvider.notifier).state = 3;
container.read(navRailIndexStateProvider.notifier).state = 2;
await tester.pump();
// Verify that the SettingsPage is displayed