diff --git a/test/pages/dashboard_page_test.dart b/test/pages/dashboard_page_test.dart index 8becd51c..fb134892 100644 --- a/test/pages/dashboard_page_test.dart +++ b/test/pages/dashboard_page_test.dart @@ -615,6 +615,65 @@ void main() { expect(find.byType(DashboardGrid, skipOffstage: false), findsNWidgets(1)); }); + testWidgets('Reordering tabs', (widgetTester) async { + FlutterError.onError = ignoreOverflowErrors; + setupMockOfflineNT4(); + + await widgetTester.pumpWidget( + MaterialApp( + home: DashboardPage( + connectionStream: Stream.value(false), + preferences: preferences, + version: '0.0.0.0', + ), + ), + ); + + await widgetTester.pumpAndSettle(); + + expect(find.byType(DashboardGrid, skipOffstage: false), findsNWidgets(2)); + + final editableTabBar = find.byType(EditableTabBar); + + expect(editableTabBar, findsOneWidget); + + final tabLeftButton = + find.descendant(of: editableTabBar, matching: find.byIcon(Icons.west)); + final tabRightButton = + find.descendant(of: editableTabBar, matching: find.byIcon(Icons.east)); + + expect(tabLeftButton, findsOneWidget); + expect(tabRightButton, findsOneWidget); + + editableTabBarWidget() => + (editableTabBar.evaluate().first.widget as EditableTabBar); + + expect(editableTabBarWidget().currentIndex, 0); + + await widgetTester.tap(tabLeftButton); + await widgetTester.pumpAndSettle(); + + expect(editableTabBarWidget().currentIndex, 0, + reason: 'Tab index should not change since index is 0'); + + await widgetTester.tap(tabRightButton); + await widgetTester.pumpAndSettle(); + + expect(editableTabBarWidget().currentIndex, 1); + + await widgetTester.tap(tabRightButton); + await widgetTester.pumpAndSettle(); + + expect(editableTabBarWidget().currentIndex, 1, + reason: + 'Tab index should not change since index is equal to number of tabs'); + + await widgetTester.tap(tabLeftButton); + await widgetTester.pumpAndSettle(); + + expect(editableTabBarWidget().currentIndex, 0); + }); + testWidgets('Renaming tab', (widgetTester) async { FlutterError.onError = ignoreOverflowErrors; setupMockOfflineNT4(); diff --git a/test/widgets/editable_tab_bar_test.dart b/test/widgets/editable_tab_bar_test.dart index 066d7547..dc01d890 100644 --- a/test/widgets/editable_tab_bar_test.dart +++ b/test/widgets/editable_tab_bar_test.dart @@ -48,7 +48,6 @@ void main() { DashboardGrid(), DashboardGrid(), ], - newDashboardGridBuilder: () => DashboardGrid(key: GlobalKey()), onTabCreate: (tab) {}, onTabDestroy: (index) {}, onTabMoveLeft: () {}, @@ -89,7 +88,6 @@ void main() { DashboardGrid(), DashboardGrid(), ], - newDashboardGridBuilder: () => DashboardGrid(key: GlobalKey()), onTabCreate: (tab) { tabBarFunctions.onTabCreate(); }, @@ -141,7 +139,6 @@ void main() { DashboardGrid(), DashboardGrid(), ], - newDashboardGridBuilder: () => DashboardGrid(key: GlobalKey()), onTabCreate: (tab) { tabBarFunctions.onTabCreate(); }, @@ -177,7 +174,7 @@ void main() { verify(tabBarFunctions.onTabDestroy()).called(1); }); - testWidgets('Move tabs', (widgetTester) async { + testWidgets('Reordering tabs', (widgetTester) async { FlutterError.onError = ignoreOverflowErrors; await widgetTester.pumpWidget( @@ -193,7 +190,6 @@ void main() { DashboardGrid(), DashboardGrid(), ], - newDashboardGridBuilder: () => DashboardGrid(key: GlobalKey()), onTabCreate: (tab) { tabBarFunctions.onTabCreate(); }, @@ -258,7 +254,6 @@ void main() { DashboardGrid(), DashboardGrid(), ], - newDashboardGridBuilder: () => DashboardGrid(key: GlobalKey()), onTabCreate: (tab) { tabBarFunctions.onTabCreate(); }, @@ -335,7 +330,6 @@ void main() { DashboardGrid(), DashboardGrid(), ], - newDashboardGridBuilder: () => DashboardGrid(key: GlobalKey()), onTabCreate: (tab) { tabBarFunctions.onTabCreate(); },