From 26ff692606d322e1548f1030351db9d16c7aa6bd Mon Sep 17 00:00:00 2001
From: Mark <mark@openappstack.net>
Date: Wed, 4 Dec 2019 15:08:17 +0100
Subject: [PATCH] Rewrite testing instructions

---
 frontend/README.md | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)

diff --git a/frontend/README.md b/frontend/README.md
index 3e29492..af15809 100644
--- a/frontend/README.md
+++ b/frontend/README.md
@@ -70,19 +70,44 @@ access the api with a browser that automatically includes your cookie in the req
 Passing the token as a GET or POST variable is not supported.
 
 
-### Run the tests
+### Testing
 
-Install the development dependencies with
+The test folder includes end to end tests that you can run from your workstation to check if
+your setup is working properly especially in case you want to make changes to the code.
+
+#### Prerequisites
+
+E2E tests are executed with chromedriver. Make sure that you have a supported version
+of chromium installed. To downgrade the chromium version that is used in the tests, change
+the version number in `package.json` [accordingly](https://www.npmjs.com/package/chromedriver).
+
+In order to run the tests you also need to install additional node packages.
+The development and testing dependencies can be installed with
 
 ```
 npm install # without --production
 ```
-Configure the application as described above.
-After creating two regular users and an admin user by assigning the role `admin` to the admin
-user and granting the admin and one of the test users access to the `user-panel` application,
-configure the default values in `test/nightwatch_globals.js`. Don't forget to set the usernames
-and passwords of the test users you created. After that, run `npm run test`.
+The tests will use login credentials of 3 different users.
+ * Create a user that has the role `admin`and the application `user-panel` assigned to it.
+ * Create a second user and only assign the  application `user-panel`.
+ * Create a third user and don't assign anything to it.
 
-Note: E2E tests are executed with chromedriver. Make sure that you have a supported version
-of chromium installed. To downgrade the chromium version that is used in the tests, change
-the version number in `package.json` [accordingly](https://www.npmjs.com/package/chromedriver).
+You can use the utility scripts provided in the backend folder of this repo to create the users
+applications and roles. To do that execute:
+
+```
+bash ../backend/utils/create-application.bash user-panel
+bash ../backend/utils/create-role.bash admin
+bash ../backend/utils/create-user.bash admin adminadmin admin@example.net
+bash ../backend/utils/create-user.bash testuser testtest testuser@example.net
+bash ../backend/utils/create-user.bash testuser2 testtest testuser2@example.net
+bash ../backend/utils/assign-role.bash admin admin
+bash ../backend/utils/grant-access.bash admin user-panel
+bash ../backend/utils/grant-access.bash testuser user-panel
+```
+After that configure the values in `test/nightwatch_globals.js` to match the usernames and
+passwords.
+
+#### Run the tests
+
+To run the tests, execute `npm run test`
-- 
GitLab