192 lines
6.1 KiB
Dart
192 lines
6.1 KiB
Dart
part of 'app_test.dart';
|
|
|
|
class MenuTest {
|
|
static Future labels2AppbarConsistency() async {
|
|
patrolWidgetTest(
|
|
'As labels dos menuItems correspondem aos títulos das AppBars?', //
|
|
(PatrolTester tester) async {
|
|
$ = tester;
|
|
await _logged();
|
|
await $.pumpWidget(const App());
|
|
await $.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();
|
|
|
|
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;
|
|
if (route == '/petsPage') continue;
|
|
if (route == '/fastPassPage') continue;
|
|
if (route == '/reservation') continue;
|
|
await $.pumpAndSettle();
|
|
|
|
ff.navigatorKey.currentContext!.go(route);
|
|
await $.pumpAndSettle();
|
|
|
|
Future.delayed(const Duration(milliseconds: 500));
|
|
|
|
final Finder appBar = find.text(title);
|
|
await $.pumpAndSettle();
|
|
expect(appBar, findsOneWidget);
|
|
await $.pumpAndSettle();
|
|
}
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
return;
|
|
},
|
|
);
|
|
}
|
|
|
|
static Future containEntries() async {
|
|
patrolWidgetTest(
|
|
'HomeMenu contém seus itens?', //
|
|
(PatrolTester tester) async {
|
|
$ = tester;
|
|
await _logged();
|
|
await $.pumpWidget(const App());
|
|
await $.pumpAndSettle();
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
|
|
final Finder gridView = find.byType(GridView);
|
|
await $.pumpAndSettle();
|
|
await $.pumpAndSettle();
|
|
final Finder gridEntries = find.descendant(
|
|
of: gridView,
|
|
matching: find.byType(ButtonMenuItem),
|
|
);
|
|
await $.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 $.pumpAndSettle();
|
|
final List<MenuEntry> entries = MenuEntry.entries;
|
|
await $.pumpAndSettle();
|
|
final List<String> entriesKey = entries
|
|
.where((entry) => entry.types.contains(MenuEntryType.Home))
|
|
.map((entry) => entry.key)
|
|
.toList();
|
|
await $.pumpAndSettle();
|
|
expect(entriesKey, containsAll(menuKeys));
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
return;
|
|
},
|
|
);
|
|
|
|
patrolWidgetTest(
|
|
'DrawerMenu contém seus itens?', //
|
|
(PatrolTester tester) async {
|
|
$ = tester;
|
|
await _logged();
|
|
await $.pumpWidget(const App());
|
|
await $.pumpAndSettle();
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
|
|
final Finder drawerButton = find.byIcon(Icons.menu_rounded);
|
|
await $.pumpAndSettle();
|
|
await $.tap(drawerButton);
|
|
await $.pumpAndSettle();
|
|
|
|
final Finder gridView = find.byType(ListView);
|
|
await $.pumpAndSettle();
|
|
final Finder gridEntries = find.descendant(
|
|
of: gridView,
|
|
matching: find.byType(CardMenuItem),
|
|
);
|
|
await $.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 $.pumpAndSettle();
|
|
final List<MenuEntry> entries = MenuEntry.entries;
|
|
await $.pumpAndSettle();
|
|
final List<String> entriesKey = entries
|
|
.where((entry) => entry.types.contains(MenuEntryType.Drawer))
|
|
.map((entry) => entry.key)
|
|
.toList();
|
|
await $.pumpAndSettle();
|
|
expect(entriesKey, containsAll(menuKeys));
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
return;
|
|
},
|
|
);
|
|
}
|
|
|
|
static Future navToEntries() async {
|
|
patrolWidgetTest(
|
|
'Navegação entre items do Menu',
|
|
(PatrolTester tester) async {
|
|
$ = tester;
|
|
await _logged();
|
|
await $.pumpWidgetAndSettle(const App());
|
|
await $.waitUntilVisible($(MenuStaggeredView));
|
|
|
|
final PatrolFinder profile =
|
|
$(const Key('AsyncLocalProfileComponentWidget_InkWell'));
|
|
await $(profile)
|
|
.waitUntilVisible()
|
|
.tap(settlePolicy: SettlePolicy.noSettle);
|
|
await $.waitUntilVisible($(BottomArrowLinkedLocalsComponentWidget));
|
|
|
|
final PatrolFinder local = $('FRE ACCESS DEMO');
|
|
await $(local)
|
|
.waitUntilVisible()
|
|
.tap(settlePolicy: SettlePolicy.trySettle);
|
|
|
|
await $.waitUntilVisible($(MenuStaggeredView));
|
|
|
|
final Finder gridView = find.byType(GridView);
|
|
final Finder gridEntries = find.descendant(
|
|
of: gridView,
|
|
matching: find.byType(ButtonMenuItem),
|
|
);
|
|
await $.pumpAndSettle();
|
|
expect(gridEntries, findsWidgets);
|
|
|
|
final int gridEntriesCount = gridEntries.evaluate().length;
|
|
for (int i = 0; i < gridEntriesCount; i++) {
|
|
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;
|
|
}
|
|
},
|
|
);
|
|
}
|
|
}
|