From 9de5f913ed4aa3ffc598a4cb2b2f3c814e4b5a1c Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Fri, 3 Apr 2020 11:51:59 +0200 Subject: [PATCH] Improve screenshot script Which also acts as our integration test. --- lib/editors/common.dart | 1 + lib/screens/folder_view.dart | 1 + test_driver/main.dart | 4 +++ test_driver/main_test.dart | 65 ++++++++++++++++++++++++++++++++---- 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/lib/editors/common.dart b/lib/editors/common.dart index 93f58fa3..45829588 100644 --- a/lib/editors/common.dart +++ b/lib/editors/common.dart @@ -34,6 +34,7 @@ AppBar buildEditorAppBar( actions: [ ...?extraButtons, IconButton( + key: const ValueKey("EditorSelector"), icon: const Icon(Icons.library_books), onPressed: () { var note = editorState.getNote(); diff --git a/lib/screens/folder_view.dart b/lib/screens/folder_view.dart index 31cd1c5f..85543f3d 100644 --- a/lib/screens/folder_view.dart +++ b/lib/screens/folder_view.dart @@ -124,6 +124,7 @@ class _FolderViewState extends State { IconButton( icon: const Icon(Icons.library_books), onPressed: _folderViewChooserSelected, + key: const ValueKey("FolderViewSelector"), ), if (appState.remoteGitRepoConfigured) SyncButton(), IconButton( diff --git a/test_driver/main.dart b/test_driver/main.dart index c6a131a1..f3d2b7c5 100644 --- a/test_driver/main.dart +++ b/test_driver/main.dart @@ -1,9 +1,13 @@ import 'package:flutter_driver/driver_extension.dart'; import 'package:gitjournal/app.dart'; +import 'package:gitjournal/settings.dart'; import 'package:shared_preferences/shared_preferences.dart'; void main() async { enableFlutterDriverExtension(); + var pref = await SharedPreferences.getInstance(); + Settings.instance.load(pref); + await JournalApp.main(pref); } diff --git a/test_driver/main_test.dart b/test_driver/main_test.dart index fef15595..3296f67e 100644 --- a/test_driver/main_test.dart +++ b/test_driver/main_test.dart @@ -62,11 +62,34 @@ void main() { await driver.tap(fab); await driver.waitFor(find.text('Write here'), timeout: const Duration(seconds: 5)); - //await _takeScreenshot(); + await _takeScreenshot(); await driver.enterText( "Your notes will be saved in Markdown with a YAML header for the metadata.\n\nThe writing experience is clean and distraction free"); - // await _takeScreenshot(); + await _takeScreenshot(); + + // Editor Selector + var editorSelector = find.byValueKey("EditorSelector"); + await driver.tap(editorSelector); + await Future.delayed(const Duration(milliseconds: 100)); + await _takeScreenshot(); + + // Raw Edtitor + var rawEditor = find.text("Raw Editor"); + await driver.waitFor(rawEditor, timeout: const Duration(seconds: 2)); + await driver.tap(rawEditor); + await Future.delayed(const Duration(milliseconds: 100)); + await _takeScreenshot(); + + // Journal Editor + await driver.tap(editorSelector); + var journalEditor = find.text("Journal Editor"); + await driver.waitFor(journalEditor, timeout: const Duration(seconds: 2)); + await driver.tap(journalEditor); + await Future.delayed(const Duration(milliseconds: 100)); + await _takeScreenshot(); + + // Go Back to home screen await driver.tap(find.byValueKey("NewEntry")); // Create another note @@ -76,17 +99,47 @@ void main() { timeout: const Duration(seconds: 5)); await driver.enterText( - "Journaling is a great way to clear your mind and get all your throughts down into paper. Well, not literal paper, as this is an app, but I think you get the point."); + "Taking Notes is a great way to clear your mind and get all your throughts down into paper. Well, not literal paper, as this is an app, but I think you get the point."); await _takeScreenshot(); await driver.tap(find.byValueKey("NewEntry")); - await Future.delayed(const Duration(milliseconds: 500)); + await Future.delayed(const Duration(milliseconds: 100)); + await _takeScreenshot(); + + // Folder View Selector + print("Taking Screenshots of FolderViewSelector"); + var folderViewSelector = find.byValueKey("FolderViewSelector"); + await driver.tap(folderViewSelector); + await Future.delayed(const Duration(milliseconds: 100)); + await _takeScreenshot(); + + // Select Card View + var cardView = find.text("Card View (Experimental)"); + await driver.waitFor(cardView, timeout: const Duration(seconds: 2)); + await driver.tap(cardView); + await Future.delayed(const Duration(milliseconds: 100)); + await _takeScreenshot(); + + // Select Journal View + await driver.tap(folderViewSelector); + var journalView = find.text("Journal View"); + await driver.waitFor(journalView, timeout: const Duration(seconds: 2)); + await driver.tap(journalView); + await Future.delayed(const Duration(milliseconds: 100)); + await _takeScreenshot(); + + // Select Grid View + await driver.tap(folderViewSelector); + var gridView = find.text("Grid View"); + await driver.waitFor(gridView, timeout: const Duration(seconds: 2)); + await driver.tap(gridView); + await Future.delayed(const Duration(milliseconds: 100)); await _takeScreenshot(); // Open the Drawer final drawerButtonFinder = find.byValueKey("DrawerButton"); await driver.tap(drawerButtonFinder); - await Future.delayed(const Duration(milliseconds: 500)); + await Future.delayed(const Duration(milliseconds: 100)); await _takeScreenshot(); // The Git Host setup screen @@ -100,6 +153,6 @@ void main() { // Close the drawer // var app = find.byValueKey("App"); // await driver.scroll(app, -300.0, 0.0, const Duration(milliseconds: 300)); - }); + }, timeout: const Timeout(Duration(minutes: 2))); }); }