175 lines
5.7 KiB
Dart
175 lines
5.7 KiB
Dart
part of 'app_test.dart';
|
|
|
|
class MenuTest {
|
|
static Future labels2AppbarConsistency() async {
|
|
_setUpAllLogged();
|
|
testWidgets('As labels dos menuItems correspondem aos títulos das AppBars?',
|
|
(WidgetTester tester) async {
|
|
await tester.pumpWidget(const App());
|
|
await tester.pumpAndSettle();
|
|
|
|
final List<String> routes = MenuEntry.entries
|
|
.where((entry) => entry.key != 'FRE-HUB-LOGOUT')
|
|
.map((entry) => entry.route)
|
|
.toList();
|
|
final List<String> titles = MenuEntry.entries
|
|
.where((entry) => entry.key != 'FRE-HUB-LOGOUT')
|
|
.map((entry) => entry.name)
|
|
.toList();
|
|
|
|
tester.printToConsole(routes.toString());
|
|
|
|
final LinkedHashMap<String, String> routesTitles =
|
|
LinkedHashMap.fromIterables(
|
|
routes,
|
|
titles,
|
|
);
|
|
for (final entry in routesTitles.entries) {
|
|
final String route = entry.key;
|
|
final String title = entry.value;
|
|
tester.printToConsole('Start: $title');
|
|
if (route == '/petsPage') continue;
|
|
if (route == '/fastPassPage') continue;
|
|
if (route == '/reservation') continue;
|
|
await tester.pumpAndSettle();
|
|
|
|
ff.navigatorKey.currentContext!.go(route);
|
|
await tester.pumpAndSettle();
|
|
|
|
Future.delayed(const Duration(milliseconds: 500));
|
|
|
|
final Finder appBar = find.text(title);
|
|
await tester.pumpAndSettle();
|
|
expect(appBar, findsOneWidget);
|
|
await tester.pumpAndSettle();
|
|
tester.printToConsole('Finish: $title');
|
|
}
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
return;
|
|
});
|
|
}
|
|
|
|
static Future containEntries() async {
|
|
_setUpAllLogged();
|
|
testWidgets('HomeMenu contém seus itens?', (WidgetTester tester) async {
|
|
await tester.pumpWidget(const App());
|
|
await tester.pumpAndSettle();
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
|
|
final Finder gridView = find.byType(GridView);
|
|
await tester.pumpAndSettle();
|
|
await tester.ensureVisible(gridView);
|
|
await tester.pumpAndSettle();
|
|
final Finder gridEntries = find.descendant(
|
|
of: gridView,
|
|
matching: find.byType(ButtonMenuItem),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(gridEntries, findsWidgets);
|
|
|
|
final List<String?> menuKeys = gridEntries
|
|
.evaluate()
|
|
.map((element) {
|
|
final key = element.widget.key;
|
|
if (key is ValueKey<String>) {
|
|
return key.value;
|
|
}
|
|
return null;
|
|
})
|
|
.where((key) => key != null)
|
|
.toList();
|
|
|
|
await tester.pumpAndSettle();
|
|
final List<MenuEntry> entries = MenuEntry.entries;
|
|
await tester.pumpAndSettle();
|
|
final List<String> entriesKey = entries
|
|
.where((entry) => entry.types.contains(MenuEntryType.Home))
|
|
.map((entry) => entry.key)
|
|
.toList();
|
|
await tester.pumpAndSettle();
|
|
expect(entriesKey, containsAll(menuKeys));
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
return;
|
|
});
|
|
|
|
testWidgets('DrawerMenu contém seus itens?', (WidgetTester tester) async {
|
|
await tester.pumpWidget(const App());
|
|
await tester.pumpAndSettle();
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
|
|
final Finder drawerButton = find.byIcon(Icons.menu_rounded);
|
|
await tester.pumpAndSettle();
|
|
await tester.tap(drawerButton);
|
|
await tester.pumpAndSettle();
|
|
|
|
final Finder gridView = find.byType(ListView);
|
|
await tester.pumpAndSettle();
|
|
await tester.ensureVisible(gridView);
|
|
await tester.pumpAndSettle();
|
|
final Finder gridEntries = find.descendant(
|
|
of: gridView,
|
|
matching: find.byType(CardMenuItem),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
expect(gridEntries, findsWidgets);
|
|
|
|
final List<String?> menuKeys = gridEntries
|
|
.evaluate()
|
|
.map((element) {
|
|
final key = element.widget.key;
|
|
if (key is ValueKey<String>) {
|
|
return key.value;
|
|
}
|
|
return null;
|
|
})
|
|
.where((key) => key != null)
|
|
.toList();
|
|
|
|
await tester.pumpAndSettle();
|
|
final List<MenuEntry> entries = MenuEntry.entries;
|
|
await tester.pumpAndSettle();
|
|
final List<String> entriesKey = entries
|
|
.where((entry) => entry.types.contains(MenuEntryType.Drawer))
|
|
.map((entry) => entry.key)
|
|
.toList();
|
|
await tester.pumpAndSettle();
|
|
expect(entriesKey, containsAll(menuKeys));
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
return;
|
|
});
|
|
_tearDownAll();
|
|
}
|
|
|
|
static Future navToEntries() async {
|
|
_setUpAllLogged();
|
|
testWidgets('Navegação entre items do Menu', (WidgetTester tester) async {
|
|
tester = tester;
|
|
await tester.pumpWidget(const App());
|
|
await tester.pumpAndSettle();
|
|
|
|
final Finder gridView = find.byType(GridView);
|
|
await tester.ensureVisible(gridView);
|
|
final Finder gridEntries = find.descendant(
|
|
of: gridView,
|
|
matching: find.byType(ButtonMenuItem),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
await Future.delayed(const Duration(seconds: 5));
|
|
expect(gridEntries, findsWidgets);
|
|
|
|
final int gridEntriesCount = gridEntries.evaluate().length;
|
|
for (int i = 0; i < gridEntriesCount; i++) {
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
await tester.tap(gridEntries.at(i));
|
|
await tester.pumpAndSettle();
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
await tester.tap(find.byIcon(Icons.keyboard_arrow_left));
|
|
await tester.pumpAndSettle();
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
return;
|
|
}
|
|
});
|
|
_tearDownAll();
|
|
}
|
|
}
|