Introduction
End to end tests are performed using Protractor.
Each plugin (and OpenVeo core) defines a list of test suites in tests/client/protractorSuites.json.
Install selenium web driver and chrome driver
node_modules/grunt-protractor-runner/node_modules/protractor/bin/webdriver-manager update
Configure tests
You need to specify a new database which will be used during tests. To do so, you can add a new configuration file in user's directory under ~/.openveo/core called databaseTestConf.json.
~/.openveo/core/databaseTestConf.json
{
"type": "mongodb",
"host": "localhost",
"port": 27017,
"database": "openveo-test",
"username": "openveo",
"password": "openveo"
}
WARNING : Each time you launch end to end tests, all information will be removed from this database ! DO NOT use the same database as the one described in databaseConf.json
When launching tests, an OpenVeo server is automatically spawned and must be configured through serverTestConf.json. Typically you may want to change the server port.
~/.openveo/core/serverTestConf.json
{
"app": {
"port": 3004,
"sessionSecret": "2bXELdIqoT9Tbv5i1RfcXGEIE+GQS+XYbwVn0qEx"
},
"ws": {
"port": 3005
}
}
Finally the logger has to be configured through loggerTestConf.json. Typically you may want to deactivate logger standard output.
~/.openveo/core/loggerTestConf.json
{
"app": {
"level": "info",
"maxFileSize": 1048576,
"maxFiles": 2,
"fileName": "C:/Users/Vodalys/AppData/Local/Temp/openveo/logs/openveo.log",
"console": false
},
"ws": {
"level": "info",
"maxFileSize": 1048576,
"maxFiles": 2,
"fileName": "C:/Users/Vodalys/AppData/Local/Temp/openveo/logs/openveo-ws.log",
"console": false
}
}
console: false will deactivate standard output.
Writing tests
Boot steps
When launching end to end tests, several things happen before the first test is launched :
- Database defined in ~/.openveo/core/databaseTestConf.json is dropped
- Users, roles, groups and applications described in tests/client/e2eTests/database/data.json, from core and plugins, are inserted into database
- Tests suites files, in tests/client/e2eTests/protractorSuites.json from core and plugins, are merged into one single file (tests/client/e2eTests/suites/suites.json)
- An OpenVeo server is launched
- An OpenVeo Web Service server is launched
- A database connection is made to be able to use models in tests
- All plugins are loaded and available in ApplicationStorage
Add users, roles, groups and application before tests
Users, roles, groups and applications can be added before tests are launched using tests/client/e2eTests/database/data.json configuration file.
Structure is as follow :
{
"groups": {
...
},
"roles": {
...
},
"users": {
...
},
"applications": {
...
}
}
Create a group
{
"groups": {
"coreGroupId": { // Id of the group to use when creating roles
"name": "Core group name", // The name of the group
"description": "Core group description" // The description of the group
}
}
}
Create a role
{
"roles": {
"coreAdmin": { // Id of the role to use when creating users
"name": "core-admin", // The name of the role
"permissions": [ // The list of permissions ids as described in conf.js file
"add-application",
"update-application",
"delete-application",
"add-taxonomy",
"update-taxonomy",
"delete-taxonomy",
"add-user",
"update-user",
"delete-user",
"add-role",
"update-role",
"delete-role",
"access-applications-page",
"access-users-page",
"access-roles-page",
"get-group-coreGroupId", // Permission "get" on the group "coreGroupId"
"update-group-coreGroupId", // Permission "update" on the group "coreGroupId"
"delete-group-coreGroupId" // Permission "delete" on the group "coreGroupId"
]
}
}
}
Create a user
{
"users": {
"coreAdmin": { // Id of the user (not used)
"name": "core-admin", // The name of the user
"email": "core-admin@veo-labs.com", User's email
"password": "core-admin", // User's password
"roles": [ "coreAdmin" ] // User's list of roles (role ids are the one described in the same file)
}
}
}
Create an application
{
"applications": {
"coreApplicationsGuest": { // Id of the application (not used)
"name": "core-applications-guest", // Name of the application
"scopes": [ "publish-videos" ] // List of scope ids for the application
}
}
}
Create test
Create your test file in tests/client/e2eTests/ then update the list of suites, if necessary, in tests/client/e2eTests/suites/suites.json.
Debug
If a test fails, a screenshot of the browser at the instant is taken and available in build/screenshots of the core.
Launch end to end tests
# Launch all end to end tests on chrome
grunt test-e2e --capabilities="{\"browserName\": \"chrome\"}" --directConnect=true
# Launch all end to end tests on firefox
grunt test-e2e --capabilities="{\"browserName\": \"firefox\"}" --directConnect=true
# Launch only coreHome suite on chrome
grunt test-e2e --capabilities="{\"browserName\": \"chrome\"}" --directConnect=true --suite="coreHome"