diff --git a/integration_test/features/01_general/01_splash.feature b/integration_test/features/01_general/01_splash.feature index 67d48c18..20f3896e 100644 --- a/integration_test/features/01_general/01_splash.feature +++ b/integration_test/features/01_general/01_splash.feature @@ -1,12 +1,13 @@ @env:clean Feature: Splash screen displays and then closes Scenario: splash screen appears - Then I expect the widget 'SplashView' to be present within 10 seconds Then I expect the widget 'ProfileManagerView' to be present within 10 seconds # first-run of cwtch creates expected files and folders + Then I expect the folder 'integration_test/env/temp' to exist And I expect the folder 'integration_test/env/temp/dev' to exist And I expect the file 'integration_test/env/temp/dev/SALT' to exist + Then I wait for the file 'integration_test/env/temp/dev/ui.globals' to exist And I expect the file 'integration_test/env/temp/dev/ui.globals' to exist And I expect the folder 'integration_test/env/temp/dev/tor' to exist And I expect the file 'integration_test/env/temp/dev/tor/torrc' to exist \ No newline at end of file diff --git a/integration_test/features/04_profile_mgmt/01_create_delete.feature b/integration_test/features/04_profile_mgmt/01_create_delete.feature index ac27352b..c656035a 100644 --- a/integration_test/features/04_profile_mgmt/01_create_delete.feature +++ b/integration_test/features/04_profile_mgmt/01_create_delete.feature @@ -32,6 +32,9 @@ Feature: Basic Profile Management Scenario: Load Unencrypted Profile Given I wait until the widget with type 'ProfileMgrView' is present Then I expect a "ProfileRow" widget with text "Alice (Unencrypted)" + # This test is too short...if the test finishes before flutter has finished initializing then + # the framework gets very confused... + And I wait for 2 seconds Scenario: Create Encrypted Profile Given I wait until the widget with type 'ProfileMgrView' is present diff --git a/integration_test/gherkin_suite_test.editable.dart b/integration_test/gherkin_suite_test.editable.dart index 5f350a77..262fb470 100644 --- a/integration_test/gherkin_suite_test.editable.dart +++ b/integration_test/gherkin_suite_test.editable.dart @@ -56,6 +56,7 @@ void main() async { // files FolderExists(), FileExists(), + WaitFileExists(), ]; var sb = StringBuffer(); diff --git a/integration_test/steps/files.dart b/integration_test/steps/files.dart index 657b1f24..ce2d6933 100644 --- a/integration_test/steps/files.dart +++ b/integration_test/steps/files.dart @@ -19,3 +19,16 @@ StepDefinitionGeneric FileExists() { }, ); } + +StepDefinitionGeneric WaitFileExists() { + return then1( + RegExp(r'I wait for the file {string} to exist'), + (input1, context) async { + await context.world.appDriver.waitUntil( + () async { + await context.world.appDriver.waitForAppToSettle(); + return File(input1).existsSync(); + }); + }, + ); +} diff --git a/integration_test/steps/text.dart b/integration_test/steps/text.dart index 2aea8569..fde658e0 100644 --- a/integration_test/steps/text.dart +++ b/integration_test/steps/text.dart @@ -33,7 +33,6 @@ StepDefinitionGeneric TorVersionPresent() { break; } } - print('File is now closed.'); } catch (e) { print('Error: $e'); } @@ -44,12 +43,14 @@ StepDefinitionGeneric TorVersionPresent() { context.world.attach(versionString, "text/plain", "Then I expect the Tor version to be present"); //context.reporter.message("test!!!", MessageLevel.info); print("looking for version string $versionString"); - final finder = context.world.appDriver.findBy( - versionString, - FindType.text, - ); - final isP = await context.world.appDriver.isPresent(finder); - context.expect(isP, true); + return await context.world.appDriver.waitUntil(() async { + final finder = context.world.appDriver.findBy( + versionString, + FindType.text, + ); + final isP = await context.world.appDriver.isPresent(finder); + return isP; + }); }, ); } diff --git a/integration_test/steps/utils.dart b/integration_test/steps/utils.dart index d9809ba5..e23c8f91 100644 --- a/integration_test/steps/utils.dart +++ b/integration_test/steps/utils.dart @@ -19,3 +19,4 @@ StepDefinitionGeneric TakeScreenshot() { }, ); } + diff --git a/lib/main.dart b/lib/main.dart index b22e6b88..f3ccc0ad 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -78,6 +78,7 @@ class FlwtchState extends State with WindowListener { @override initState() { + print("initState() started, setting up handlers"); globalSettings = Settings(Locale("en", ''), CwtchDark()); globalErrorHandler = ErrorHandler(); globalTorStatus = TorStatus(); diff --git a/run-tests.sh b/run-tests.sh index 570a5fcf..eb9c68c5 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -7,7 +7,7 @@ flutter pub run build_runner build --delete-conflicting-outputs PATH=$PATH:$PWD/linux/Tor LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$PWD/linux/":"$PWD/linux/Tor/" -PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH CWTCH_HOME=$PWD/integration_test/env/temp/ flutter test -d linux --dart-define TEST_MODE=true integration_test/gherkin_suite_test.dart +PATH=$PATH LD_LIBRARY_PATH=$LD_LIBRARY_PATH LOG_FILE=test.log CWTCH_HOME=$PWD/integration_test/env/temp/ flutter test -d linux --dart-define TEST_MODE=true integration_test/gherkin_suite_test.dart #node index2.js #if [ "$HEADLESS" = "false" ]; then # xdg-open integration_test/gherkin/reports/cucumber_report.html