208 lines
6.8 KiB
Dart
208 lines
6.8 KiB
Dart
part of 'app_test.dart';
|
|
|
|
class LocalsTest {
|
|
static Future setLocal() async {
|
|
patrolWidgetTest(
|
|
'Selecionar um local disponível', //
|
|
(PatrolTester tester) async {
|
|
$ = tester;
|
|
await _logged();
|
|
await $.pumpWidgetAndSettle(const App());
|
|
await $.waitUntilVisible($(MenuStaggeredView));
|
|
await $.waitUntilVisible($(LocalProfileComponentWidget));
|
|
|
|
final PatrolFinder profileFinder =
|
|
$(#AsyncLocalProfileComponentWidget_InkWell);
|
|
expect(profileFinder, findsOneWidget);
|
|
|
|
await $(profileFinder).tap();
|
|
await $.pump(const Duration(milliseconds: 500));
|
|
|
|
final PatrolFinder bottomSheetFinder =
|
|
$(BottomArrowLinkedLocalsComponentWidget);
|
|
expect(bottomSheetFinder, findsOneWidget);
|
|
|
|
await $.pump(const Duration(milliseconds: 500));
|
|
|
|
final PatrolFinder listViewFinder = $(bottomSheetFinder).$(ListView);
|
|
expect(listViewFinder, findsOneWidget);
|
|
|
|
await $.pump(const Duration(milliseconds: 500));
|
|
|
|
final PatrolFinder entriesFinder =
|
|
$(listViewFinder).$(CardItemTemplateComponentWidget);
|
|
expect(entriesFinder, findsWidgets);
|
|
|
|
if (entriesFinder.evaluate().isNotEmpty) {
|
|
await $.tap(entriesFinder.first);
|
|
await $.pumpAndSettle();
|
|
}
|
|
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
},
|
|
);
|
|
}
|
|
|
|
static Future unlinkLocal() async {
|
|
// patrolWidgetTest('Desvincular do local selecionado', //
|
|
// (PatrolTester tester) async {
|
|
// $ = tester;
|
|
// await _logged();
|
|
// await $.pumpWidgetAndSettle(const App());
|
|
// await $.waitUntilVisible($(MenuStaggeredView));
|
|
// Future.delayed(const Duration(milliseconds: 500));
|
|
//
|
|
// final PatrolFinder gridView = await $(GridView) //
|
|
// .waitUntilVisible();
|
|
// final PatrolFinder entries = await $(gridView)
|
|
// .$(ButtonMenuItem) //
|
|
// .waitUntilVisible();
|
|
//
|
|
// await $.pumpAndSettle();
|
|
// expect(entries, findsWidgets);
|
|
// final PatrolFinder settings = await $(gridView) //
|
|
// .$(Icons.settings)
|
|
// .waitUntilVisible();
|
|
// expect(settings, findsOneWidget);
|
|
//
|
|
// await $(settings).tap();
|
|
//
|
|
// final PatrolFinder unlinkButton = await $(Symbols.digital_out_of_home) //
|
|
// .waitUntilVisible();
|
|
// expect(unlinkButton, findsOneWidget);
|
|
// await $(unlinkButton).tap();
|
|
//
|
|
// await $('Sim') //
|
|
// .waitUntilVisible()
|
|
// .tap(settlePolicy: SettlePolicy.noSettle);
|
|
//
|
|
// await $.pump();
|
|
// await $.pump(const Duration(seconds: 1));
|
|
// await $.pump();
|
|
//
|
|
// final PatrolFinder bottomSheetFinder =
|
|
// await $(BottomArrowLinkedLocalsComponentWidget) //
|
|
// .waitUntilVisible();
|
|
//
|
|
// await $.pump(const Duration(seconds: 1));
|
|
// expect(bottomSheetFinder, findsOneWidget);
|
|
// await $.pump(const Duration(seconds: 1));
|
|
//
|
|
// await $.pump(const Duration(seconds: 1));
|
|
// final PatrolFinder listViewFinder = await $(bottomSheetFinder) //
|
|
// .$(ListView)
|
|
// .waitUntilVisible();
|
|
//
|
|
// expect(listViewFinder, findsOneWidget);
|
|
//
|
|
// await $.pump(const Duration(seconds: 1));
|
|
//
|
|
// final PatrolFinder entriesFinder = await $(listViewFinder)
|
|
// .$(CardItemTemplateComponentWidget)
|
|
// .waitUntilVisible();
|
|
//
|
|
// expect(entriesFinder, findsWidgets);
|
|
// await Future.delayed(const Duration(milliseconds: 500));
|
|
// return;
|
|
// });
|
|
|
|
patrolWidgetTest(
|
|
'Vincular um local desvinculado', //
|
|
(PatrolTester tester) async {
|
|
$ = tester;
|
|
await _logged(false);
|
|
await $.pumpWidget(const App());
|
|
|
|
final loc = ff.FFLocalizations.of(navigatorKey.currentContext!);
|
|
|
|
//
|
|
// await $.waitUntilVisible($(MenuStaggeredView));
|
|
// await $.waitUntilVisible($(LocalProfileComponentWidget));
|
|
//
|
|
// final PatrolFinder profileFinder =
|
|
// $(#AsyncLocalProfileComponentWidget_InkWell);
|
|
// expect(profileFinder, findsOneWidget);
|
|
//
|
|
// await $(profileFinder).tap();
|
|
// await $.pump(const Duration(milliseconds: 500));
|
|
|
|
final PatrolFinder bottomSheetFinder =
|
|
await $(BottomArrowLinkedLocalsComponentWidget) //
|
|
.waitUntilVisible();
|
|
expect(bottomSheetFinder, findsOneWidget);
|
|
|
|
await $.pump(const Duration(milliseconds: 500));
|
|
|
|
final PatrolFinder listViewFinder = $(bottomSheetFinder) //
|
|
.$(ListView);
|
|
expect(listViewFinder, findsOneWidget);
|
|
|
|
await $.pump(const Duration(milliseconds: 500));
|
|
|
|
final PatrolFinder entriesFinder = $(listViewFinder) //
|
|
.$(CardItemTemplateComponentWidget);
|
|
expect(entriesFinder, findsWidgets);
|
|
|
|
if (entriesFinder.evaluate().isNotEmpty) {
|
|
await $(entriesFinder.first).waitUntilVisible().tap();
|
|
final String accept =
|
|
loc.getVariableText(enText: 'Yes', ptText: 'Sim');
|
|
await $(accept).waitUntilVisible().tap();
|
|
}
|
|
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
|
|
// try {
|
|
// await $.pumpAndSettle(
|
|
// duration: const Duration(seconds: 2),
|
|
// phase: EnginePhase.sendSemanticsUpdate,
|
|
// timeout: const Duration(seconds: 2),
|
|
// );
|
|
// throw Exception('Local está vinculado');
|
|
// } catch (e) {
|
|
// await Future.delayed(const Duration(milliseconds: 500));
|
|
// return;
|
|
// }
|
|
},
|
|
);
|
|
}
|
|
|
|
static Future attachLocal() async {
|
|
patrolWidgetTest(
|
|
'Selecionar um local disponível', //
|
|
(PatrolTester tester) async {
|
|
$ = tester;
|
|
await _logged();
|
|
await $.pumpWidget(const App());
|
|
late Map<String, String> credentials;
|
|
final PatrolFinder throwsException = $('');
|
|
|
|
var name = ff.randomString(7, 7, true, true, true);
|
|
var email = '$name@example.com';
|
|
var password = '12345678';
|
|
credentials = {
|
|
'nameTextFormField': name,
|
|
'emailTextFormField': email,
|
|
'passwordTextFormField': password
|
|
};
|
|
|
|
await $.pumpWidget(const App());
|
|
await _navigateToSignUp($);
|
|
await _auth(credentials, $, throwsException);
|
|
credentials = {
|
|
'emailTextFormField': email,
|
|
'passwordTextFormField': password
|
|
};
|
|
await _auth(credentials, $, throwsException);
|
|
|
|
await $.pumpAndSettle();
|
|
await StorageHelper() //
|
|
.set(ProfileStorageKey.clientUUID.key, '7');
|
|
await $.pumpAndSettle();
|
|
await Future.delayed(const Duration(milliseconds: 500));
|
|
return;
|
|
},
|
|
);
|
|
}
|
|
}
|