End to end testing using Protractor! A Detailed Guide step by step including bugs - 401ChemistryGenealogy/ChemistryGenealogy GitHub Wiki

###Things before running tests:

#Always reset the test database.

Always. Without doing this you will get an EXTREMELY LARGE number of failed tests.

How to reset the test database: Navigate to the backend folder, in there should be a shell script called ./cshellscript.sh" note, run this and wait for it. This will set up the test database with the expected data.

1: All tests were performed using the Chrome browser. I cannot guarantee that they will work on other browsers.

2: The webpage MUST be in full screen mode, errors occur otherwise.

3: Please do not interact with the webpage launched by the tests.

4: Seemingly irrelevant details that may impact tests; tests were ran only on a 4k resolution.

###How to download, set up, and run the tests.

VERY CRITICAL: If you follow the main protractor installation guide you WILL NOT be able to use these tests. We're using a different version of protractor specific to our version of angular.

1: Install protractor globally: npm install -g protractor@2

The protractor webpage however says this, THIS DOES NOT WORK: npm install -g protractor

https://github.com/angular/protractor#compatibility

2: Obtain the webdriver manager: webdriver-manager update

####Now to run the tests:

1: Ensure that you have the back end AND front end running.

Backend: In the backend folder use the command: "rails s"

Frontend: In the frontend folder use the command node server.js

2: Now make sure the webdriver is running using the command: "webdriver-manager start"

3: In the frontend/tests folder use the command: "protractor conf.js

***NOTE: This will run the "main core" of tests, this will take an expected time of ~10 minutes to run through all of the tests.

###What to expect Running the tests at 12:19AM on April 1st, 2016 (Yes, April Fool's day) yielded the following results:

Finished in 504.376 seconds 312 tests, 1252 assertions, 0 failures

###Known (bugs?) oddities with testing:

Sometimes (random 50% chance) there will be an issue with the submit page tests that raises the following message (or something quite similar).

  1. Search Test functioning input of ditype Message: UnknownError: unknown error: Element is not clickable at point (761, 578). Other element would receive the click:

or

  1. Search Test submitting a postdoc appointment Message: ElementNotVisibleError: element not visible

This is due to the fact that in the submit page there is a clickable dropdown box that must be clicked. Protractor seems to not click it at seemingly random times. However, the code is there and it does function the other 50% of the time without issue. Unsure how to resolve.

Overall when these elements have errors they cause errors throughout the entire submit page testing (Which yes, is very concerning), despite the tests having had previously worked during creation.

#note

note if that script fails, then try ./reloadDB.sh you can view the differences in the scripts and make the appropriate decision:

cshellscript.sh

[reloadDB.sh] (https://github.com/401ChemistryGenealogy/ChemistryGenealogy/blob/master/backend/reloadDB.sh)