From 30c10c51c47cf3cf9474a1f66d1dc30b4778992c Mon Sep 17 00:00:00 2001 From: Sarah Jamie Lewis Date: Tue, 31 Jan 2023 15:57:31 -0800 Subject: [PATCH] Loop Expect Wait --- .../features/01_general/02_save_load.feature | 4 +-- .../gherkin_suite_test.editable.dart | 4 +-- integration_test/steps/overrides.dart | 36 ++++++++++--------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/integration_test/features/01_general/02_save_load.feature b/integration_test/features/01_general/02_save_load.feature index 69b3a574..7c372355 100644 --- a/integration_test/features/01_general/02_save_load.feature +++ b/integration_test/features/01_general/02_save_load.feature @@ -14,11 +14,11 @@ Feature: Settings pane opens and can save settings persistently And I tap the widget that contains the text "Block Unknown Contacts" And I tap the widget that contains the text "Streamer/Presentation Mode" And I tap the widget that contains the text "Enable Experiments" - And I wait until the text 'Enable Group Chat' is present + Then I wait until the text 'Enable Group Chat' is present And I tap the widget that contains the text "Enable Group Chat" And I tap the widget that contains the text "Hosting Servers" And I tap the widget that contains the text "File Sharing" - And I wait until the text 'Image Previews and Profile Pictures' is present + Then I wait until the text 'Image Previews and Profile Pictures' is present And I tap the widget that contains the text "Image Previews and Profile Pictures" And I wait until the text 'Download Folder' is present And I fill the "DownloadFolderPicker" field with "/this/is/a/test" diff --git a/integration_test/gherkin_suite_test.editable.dart b/integration_test/gherkin_suite_test.editable.dart index 65e0d544..98c9198e 100644 --- a/integration_test/gherkin_suite_test.editable.dart +++ b/integration_test/gherkin_suite_test.editable.dart @@ -92,9 +92,7 @@ void main() async { TestRunSummaryReporter() ..setWriteLineFn(print) ..setWriteFn(print), - JsonReporter( - - ), + JsonReporter(), ], customStepParameterDefinitions: [ SwitchStateParameter(), diff --git a/integration_test/steps/overrides.dart b/integration_test/steps/overrides.dart index b5e36c2e..26acaa66 100644 --- a/integration_test/steps/overrides.dart +++ b/integration_test/steps/overrides.dart @@ -139,16 +139,17 @@ StepDefinitionGeneric ExpectWidgetWithTextWithin() { return given3( RegExp(r'I expect a {string} widget with text {string} to be present within {int} second(s)$'), (widgetType, text, seconds, context) async { - await () async { - await context.world.appDriver.waitForAppToSettle(); + await () async { + var result = false; + while (!result) { + await context.world.appDriver.waitForAppToSettle(); - return context.world.appDriver.isPresent( - context.world.appDriver.findByDescendant( - context.world.appDriver.findBy( - widgetTypeByName(widgetType), FindType.type), - context.world.appDriver.findBy(text, FindType.text)), - ); - }().timeout(Duration(seconds: 120)); + result = await context.world.appDriver.isPresent( + context.world.appDriver.findByDescendant(context.world.appDriver.findBy(widgetTypeByName(widgetType), FindType.type), context.world.appDriver.findBy(text, FindType.text)), + ); + } + }() + .timeout(Duration(seconds: 120)); }, configuration: StepDefinitionConfiguration()..timeout = const Duration(days: 1), ); @@ -158,18 +159,21 @@ StepDefinitionGeneric WaitUntilTextExists() { return then2( 'I wait until the text {string} is {existence}', (text, existence, context) async { - await context.world.appDriver.waitUntil( - () async { - return existence == Existence.absent + await () async { + var result = false; + while (!result) { + await context.world.appDriver.waitForAppToSettle(); + + result = await (existence == Existence.absent ? context.world.appDriver.isAbsent( context.world.appDriver.findBy(text, FindType.text), ) : context.world.appDriver.isPresent( context.world.appDriver.findBy(text, FindType.text), - ); - }, - timeout: Duration(seconds: 120), - ); + )); + } + }() + .timeout(Duration(seconds: 120)); }, configuration: StepDefinitionConfiguration()..timeout = const Duration(days: 1), );