From 1ef46d082c7baaea77dc217e40f8481ab9b72c09 Mon Sep 17 00:00:00 2001 From: SwikritiT Date: Tue, 18 Aug 2020 10:30:22 +0545 Subject: [PATCH 1/4] Feature files created to login, add users and logout Co-authored-by: Yamuna Adhikari --- .gitignore | 11 ++ nightwatch.conf.js | 29 ++++ package.json | 13 ++ test/acceptance/features/addUsers.feature | 86 ++++++++++++ test/acceptance/features/listUsers.feature | 29 ++++ test/acceptance/features/login.feature | 27 ++++ test/acceptance/features/logout.feature | 10 ++ test/acceptance/index.js | 14 ++ test/acceptance/pageObjects/addUsersPage.js | 128 ++++++++++++++++++ test/acceptance/pageObjects/homePage.js | 44 ++++++ test/acceptance/pageObjects/listUsersPage.js | 47 +++++++ test/acceptance/pageObjects/loginPage.js | 83 ++++++++++++ test/acceptance/pageObjects/logoutPage.js | 34 +++++ .../stepDefinitions/addUsersContext.js | 123 +++++++++++++++++ .../stepDefinitions/listUsersContext.js | 14 ++ .../stepDefinitions/loginContext.js | 22 +++ .../stepDefinitions/logoutContext.js | 14 ++ 17 files changed, 728 insertions(+) create mode 100644 nightwatch.conf.js create mode 100644 package.json create mode 100644 test/acceptance/features/addUsers.feature create mode 100644 test/acceptance/features/listUsers.feature create mode 100644 test/acceptance/features/login.feature create mode 100644 test/acceptance/features/logout.feature create mode 100644 test/acceptance/index.js create mode 100644 test/acceptance/pageObjects/addUsersPage.js create mode 100644 test/acceptance/pageObjects/homePage.js create mode 100644 test/acceptance/pageObjects/listUsersPage.js create mode 100644 test/acceptance/pageObjects/loginPage.js create mode 100644 test/acceptance/pageObjects/logoutPage.js create mode 100644 test/acceptance/stepDefinitions/addUsersContext.js create mode 100644 test/acceptance/stepDefinitions/listUsersContext.js create mode 100644 test/acceptance/stepDefinitions/loginContext.js create mode 100644 test/acceptance/stepDefinitions/logoutContext.js diff --git a/.gitignore b/.gitignore index 344822f0e9e..ac7a618c503 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,14 @@ htdocs/includes/sebastian/ htdocs/includes/squizlabs/ htdocs/includes/webmozart/ htdocs/.well-known/apple-developer-merchantid-domain-association + +# Node Modules +build/yarn-error.log +build/node_modules/ +node_modules/ + +#yarn +yarn.lock + +#package-lock +package-lock.json diff --git a/nightwatch.conf.js b/nightwatch.conf.js new file mode 100644 index 00000000000..1c4b089baa9 --- /dev/null +++ b/nightwatch.conf.js @@ -0,0 +1,29 @@ +const admin_username = process.env.ADMIN_USERNAME || 'dolibarr'; +const admin_password = process.env.ADMIN_PASSWORD || 'password'; +const launch_url = process.env.LAUNCH_URL || 'http://localhost/dolibarr/htdocs/'; +const dol_api_key = process.env.DOLAPIKEY || 'superadminuser'; +module.exports = { + page_objects_path : './test/acceptance/pageObjects/', // jshint ignore:line + src_folders : ['test'], + + test_settings : { + default : { + selenium_host : '127.0.0.1', + launchUrl : launch_url, + globals : { + backend_url : launch_url, + adminUsername : admin_username, + adminPassword : admin_password, + dolApiKey : dol_api_key + }, + desiredCapabilities : { + browserName : 'chrome', + javascriptEnabled : true, + chromeOptions : { + args : ['disable-gpu'], + w3c : false + } + } + } + } +}; diff --git a/package.json b/package.json new file mode 100644 index 00000000000..7ea03c08bca --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "devDependencies": { + "cucumber": "^6.0.5", + "nightwatch": "^1.4.1", + "nightwatch-api": "^3.0.1" + }, + "scripts": { + "test:e2e": "node_modules/cucumber/bin/cucumber-js --require test/acceptance/index.js --require test/acceptance/stepDefinitions" + }, + "dependencies": { + "node-fetch": "^2.6.1" + } +} diff --git a/test/acceptance/features/addUsers.feature b/test/acceptance/features/addUsers.feature new file mode 100644 index 00000000000..918bff771c2 --- /dev/null +++ b/test/acceptance/features/addUsers.feature @@ -0,0 +1,86 @@ +Feature: Add user + As an admin + I want to add users + So that the authorized access is possible + + Background: + Given the administrator has logged in using the webUI + And the administrator has browsed to the new users page + + Scenario: Admin adds user without permission + When the admin creates user with following details + | last name | Potter | + | login | harrypotter@gmail.com | + | password | password | + Then new user "Potter" should be created + And message "This user has no permissions defined" should be displayed in the webUI + + Scenario Outline: Admin adds user with permission + When the admin creates user with following details + | last name | Potter | + | login | harrypotter@gmail.com | + | password | password | + | administrator | | + | gender | | + Then message "This user has no permissions defined" be displayed in the webUI + And new user "Potter" should be created + Examples: + | administrator | gender | shouldOrShouldNot | + | No | | should | + | No | Man | should | + | No | Woman | should | + | Yes | | should not | + | Yes | Man | should not | + | Yes | Woman | should not | + + Scenario Outline: Admin adds user with last name as special characters + When the admin creates user with following details + | last name | | + | login | harry | + | password | password | + Then message "This user has no permissions defined" should be displayed in the webUI + And new user "" should be created + Examples: + | last name | + | swi@ | + | g!!@%ui | + | swikriti@h | + | !@#$%^&*()-_+=[]{}:;,.<>?~ | + | $w!kr!t! | + | España§àôœ€ | + | नेपाली | + | सिमप्ले $%#?&@name.txt | + + Scenario Outline: Admin adds user with incomplete essential credentials + When the admin creates user with following details + | last name | | + | login | | + | password | | + Then message "" should be displayed in the webUI + And new user "" should not be created + Examples: + | last name | login | password | message | + | | | | Name is not defined.\nLogin is not defined. | + | Joseph | | | Login is not defined. | + | | john@gmail.com | | Name is not defined. | + | Joseph | | hihi | Login is not defined. | + + Scenario: Admin adds user with incomplete essential credentials + When the admin creates user with following details + | last name | Doe | + | login | John | + | password | | + Then message "This user has no permissions defined" should be displayed in the webUI + And new user "Doe" should be created + + Scenario: Admin tries to add user with pre-existing login credential + Given a user has been created with following details + | login | last name | password | + | Tyler | Joseph | pass1234 | + And the administrator has browsed to the new users page + When the admin creates user with following details + | last name | Dun | + | login | Tyler | + | password | pass1234 | + Then message "Login already exists." should be displayed in the webUI + And new user "Dun" should not be created diff --git a/test/acceptance/features/listUsers.feature b/test/acceptance/features/listUsers.feature new file mode 100644 index 00000000000..e9c0443cdd4 --- /dev/null +++ b/test/acceptance/features/listUsers.feature @@ -0,0 +1,29 @@ +Feature: list users + As an admin user + I want to view the list of users + So that I can manage users + + Background: + Given the administrator has logged in using the webUI + + Scenario: Admin user should be able to see list of created users when no new users are created + When the administrator browses to the list of users page using the webUI + Then following users should be displayed in the users list + | login | last name | + | dolibarr | SuperAdmin | + And the number of created users should be 1 + + Scenario: Admin user should be able to see number of created users + Given the admin has created the following users + | login | last name | password | + | Harry | Potter | hello123 | + | Hermoine | Granger | hello123 | + | Ron | Weasley | hello123 | + When the administrator browses to the list of users page using the webUI + Then following users should be displayed in the users list + | login | last name | + | dolibarr | SuperAdmin | + | Harry | Potter | + | Hermoine | Granger | + | Ron | Weasley | + And the number of created users should be 4 diff --git a/test/acceptance/features/login.feature b/test/acceptance/features/login.feature new file mode 100644 index 00000000000..fd7058812cf --- /dev/null +++ b/test/acceptance/features/login.feature @@ -0,0 +1,27 @@ +Feature: user login + As a user/admin + I want to login to my account + So that I can have access to my functionality + + Background: + Given the user has browsed to the login page + + Scenario: Admin user should be able to login successfully + When user logs in with username "dolibarr" and password "password" + Then the user should be directed to the homepage + + Scenario: Admin user with empty credentials should not be able to login + When user logs in with username "" and password "" + Then the user should not be able to login + + Scenario Outline: user logs in with invalid credentials + When user logs in with username "" and password "" + Then the user should not be able to login + And error message "Bad value for login or password" should be displayed in the webUI + Examples: + | username | password | + | dolibar | pass | + | dolibarr | passw | + | dolibar | | + | dolibarr | | + | dolibar | password | diff --git a/test/acceptance/features/logout.feature b/test/acceptance/features/logout.feature new file mode 100644 index 00000000000..137c5260008 --- /dev/null +++ b/test/acceptance/features/logout.feature @@ -0,0 +1,10 @@ +Feature: user logs out + As a user + I want to log out of my account + So that I can protect my work, identity and be assured of my privacy + + Scenario: User can logout + Given the administrator has logged in using the webUI + When the user opens the user profile using the webUI + And the user logs out using the webUI + Then the user should be logged out successfully diff --git a/test/acceptance/index.js b/test/acceptance/index.js new file mode 100644 index 00000000000..a9fcda8105a --- /dev/null +++ b/test/acceptance/index.js @@ -0,0 +1,14 @@ +const { setDefaultTimeout, After, Before } = require('cucumber') +const { createSession, closeSession, startWebDriver, stopWebDriver } = require('nightwatch-api') + +setDefaultTimeout(60000) + +Before(async () => { + await startWebDriver(); + await createSession(); +}) + +After(async () => { + await closeSession(); + await stopWebDriver(); +}) diff --git a/test/acceptance/pageObjects/addUsersPage.js b/test/acceptance/pageObjects/addUsersPage.js new file mode 100644 index 00000000000..7f31523b842 --- /dev/null +++ b/test/acceptance/pageObjects/addUsersPage.js @@ -0,0 +1,128 @@ +const util = require('util'); +module.exports = { + url: function () { + return this.api.launchUrl + 'user/card.php?leftmenu=users&action=create'; + }, + + commands: [ + { + adminCreatesUser: async function (dataTable) { + const userDetails = dataTable.rowsHash(); + let administrator = userDetails['administrator']; + let gender = userDetails['gender']; + await this.waitForElementVisible('@newUserAddOption') + .useXpath() + .waitForElementVisible('@lastnameField') + .clearValue('@lastnameField') + .setValue('@lastnameField', userDetails['last name']) + .waitForElementVisible('@loginField') + .clearValue('@loginField') + .setValue('@loginField', userDetails['login']) + .waitForElementVisible('@newUserPasswordField') + .clearValue('@newUserPasswordField') + .setValue('@newUserPasswordField', userDetails['password']); + + if (userDetails['administrator']) { + const admin = util.format(this.elements.administratorSelectOption.selector, administrator); + await this.waitForElementVisible('@administratorField') + .click('@administratorField') + .waitForElementVisible(admin) + .click(admin); + } + + if (userDetails['gender']) { + const genderValue = util.format(this.elements.genderSelectOption.selector, gender) + await this.waitForElementVisible('@genderField') + .click('@genderField') + .waitForElementVisible(genderValue) + .click(genderValue); + } + return this.waitForElementVisible('@submitButton') + .click('@submitButton') + .useCss(); + }, + + noPermissionMessage: async function (message) { + await this.useXpath() + .waitForElementVisible('@noPermissionDefinedMessage') + .expect.element('@noPermissionDefinedMessage') + .text.to.equal(message); + return this.useCss(); + }, + + newUserShouldBeCreated: async function (lastname) { + await this.useXpath() + .waitForElementVisible('@newUserCreated') + .expect.element('@newUserCreated') + .text.to.equal(lastname); + return this.useCss(); + }, + + noPermissionDefinedMessageNotShown: function (message) { + return this.useXpath() + .waitForElementNotPresent('@noPermissionDefinedMessage') + .useCss(); + }, + + userNotCreated: function (lastname) { + return this.waitForElementVisible('@newUserAddOption'); + } + } + ], + + elements: { + newUserAddOption: { + selector: '.fiche' + }, + + lastnameField: { + selector: '//table[@class="border centpercent"]/tbody/tr/td//input[@id="lastname"]', + locateStrategy: 'xpath' + }, + + loginField: { + selector: '//table[@class="border centpercent"]/tbody/tr/td//input[@name="login"]', + locateStrategy: 'xpath' + }, + + newUserPasswordField: { + selector: '//table[@class="border centpercent"]/tbody/tr/td//input[@name="password"]', + locateStrategy: 'xpath' + }, + + submitButton: { + selector: '//div[@class="center"]/input[@class="button"]', + locateStrategy: 'xpath' + }, + + administratorField: { + selector: '//table[@class="border centpercent"]/tbody/tr/td//select[@id="admin"]', + locateStrategy: 'xpath' + }, + + administratorSelectOption: { + selector: '//select[@id="admin"]/option[.="%s"]', + locateStrategy: 'xpath' + + }, + + genderField: { + selector: '//table[@class="border centpercent"]/tbody/tr/td//select[@id="gender"]', + locateStrategy: 'xpath' + }, + genderSelectOption: { + selector: '//select[@id="gender"]/option[.="%s"]', + locateStrategy: 'xpath' + }, + + noPermissionDefinedMessage: { + selector: '//div[@class="jnotify-message"]', + locateStrategy: 'xpath' + }, + + newUserCreated: { + selector: '//div[contains(@class,"valignmiddle")]//div[contains(@class,"inline-block floatleft valignmiddle")]', + locateStrategy: 'xpath' + } + } +}; diff --git a/test/acceptance/pageObjects/homePage.js b/test/acceptance/pageObjects/homePage.js new file mode 100644 index 00000000000..7c225e90f5a --- /dev/null +++ b/test/acceptance/pageObjects/homePage.js @@ -0,0 +1,44 @@ +module.exports = { + url: function () { + return this.api.launchUrl + 'admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete'; + }, + + commands: [ + { + browsedToNewUserPage: function () { + return this.useXpath() + .waitForElementVisible('@usersAndGroups') + .click('@usersAndGroups') + .waitForElementVisible('@newUser') + .click('@newUser') + .useCss(); + }, + + browsedToListOfUsers: function () { + return this.useXpath() + .waitForElementVisible('@usersAndGroups') + .click('@usersAndGroups') + .waitForElementVisible('@listOfUsers') + .click('@listOfUsers') + .useCss(); + } + } + ], + + elements: { + usersAndGroups: { + selector: '//div[@class="menu_titre"]/a[@title="Users & Groups"]', + locateStrategy: 'xpath' + }, + + newUser: { + selector: '//div[@class="menu_contenu menu_contenu_user_card"]/a[@title="New user"]', + locateStrategy: 'xpath' + }, + + listOfUsers: { + selector: '//a[@class="vsmenu"][@title="List of users"]', + locateStrategy: 'xpath' + } + } +}; diff --git a/test/acceptance/pageObjects/listUsersPage.js b/test/acceptance/pageObjects/listUsersPage.js new file mode 100644 index 00000000000..6f9df509d5f --- /dev/null +++ b/test/acceptance/pageObjects/listUsersPage.js @@ -0,0 +1,47 @@ +const util = require('util'); +module.exports = { + url: function () { + return this.api.launchUrl + 'user/list.php?leftmenu=users'; + }, + + commands: [ + { + listOfUsersDisplayed: async function (dataTable) { + const usersList = dataTable.hashes(); + this.useXpath(); + for (const row of usersList) { + let login = row['login']; + let lastName = row['last name']; + const userDetail = util.format(this.elements.userList.selector, login, lastName); + await this.waitForElementVisible('@userRow') + .waitForElementVisible(userDetail); + } + return this.useCss(); + }, + + numberOfUsersDisplayed: async function (number) { + const userCount = util.format(this.elements.numberOfUsers.selector, number); + await this.useXpath() + .waitForElementVisible(userCount); + return this.useCss(); + } + } + ], + + elements: { + userRow: { + selector: '//table[contains(@class,"tagtable liste")]/tbody/tr[position()>2]', + locateStrategy: 'xpath' + }, + + numberOfUsers: { + selector: '//div[contains(@class, "titre inline-block") and contains(., "List of users")]/span[.="(%d)"]', + locateStrategy: 'xpath' + }, + + userList: { + selector: '//table[contains(@class,"tagtable liste")]/tbody/tr[position()>2]/td/a//span[normalize-space(@class="nopadding usertext")][.="%s"]/../../following-sibling::td[.="%s"]', + locateStrategy: 'xpath' + } + } +}; diff --git a/test/acceptance/pageObjects/loginPage.js b/test/acceptance/pageObjects/loginPage.js new file mode 100644 index 00000000000..75195cc3746 --- /dev/null +++ b/test/acceptance/pageObjects/loginPage.js @@ -0,0 +1,83 @@ +module.exports = { + url: function () { + return this.api.launchUrl; + }, + + commands: [ + { + waitForLoginPage: function () { + return this.waitForElementVisible('@loginTable'); + }, + + userLogsInWithUsernameAndPassword: function (username, password) { + return this.waitForElementVisible('@userNameField') + .setValue('@userNameField', username) + .waitForElementVisible('@passwordField') + .setValue('@passwordField', password) + .useXpath() + .waitForElementVisible('@loginButton') + .click('@loginButton') + .useCss(); + }, + + successfulLogin: function () { + return this.waitForElementNotPresent('@loginTable') + .waitForElementVisible('@userProfileDropdown'); + }, + + userIsLoggedIn: async function (login) { + await this.useXpath() + .waitForElementVisible('@userLogin') + .expect.element('@userLogin') + .text.to.equal(login); + return this.useCss(); + }, + + unsuccessfulLogin: function () { + return this.waitForElementVisible('@loginTable') + .waitForElementNotPresent('@userProfileDropdown'); + }, + + loginErrorDisplayed: async function (errorMessage) { + await this.useXpath() + .waitForElementVisible('@loginError') + .expect.element('@loginError') + .text.to.equal(errorMessage); + return this.useCss(); + } + } + ], + + elements: { + loginButton: { + selector: '//div[@id="login-submit-wrapper"]/input[@type="submit"]', + locateStrategy: 'xpath' + }, + + userNameField: { + selector: '#username' + }, + + passwordField: { + selector: '#password' + }, + + loginTable: { + selector: '.login_table' + }, + + userProfileDropdown: { + selector: '#topmenu-login-dropdown' + }, + + userLogin: { + selector: '//div[@id="topmenu-login-dropdown"]/a//span[contains(@class,"atoploginusername")]', + locateStrategy: 'xpath' + }, + + loginError: { + selector: '//div[@class="center login_main_message"]/div[@class="error"]', + locateStrategy: 'xpath' + } + } +}; diff --git a/test/acceptance/pageObjects/logoutPage.js b/test/acceptance/pageObjects/logoutPage.js new file mode 100644 index 00000000000..a63b8415238 --- /dev/null +++ b/test/acceptance/pageObjects/logoutPage.js @@ -0,0 +1,34 @@ +module.exports = { + url: function () { + return this.api.launchUrl + 'admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete'; + }, + + commands: + [ + { + userOpensProfile: async function () { + await this.useXpath() + .waitForElementVisible('@userProfileDropdown') + .click('@userProfileDropdown') + return this.useCss(); + }, + + userLogsOut: function () { + return this.waitForElementVisible('@logoutButton') + .click('@logoutButton'); + } + } + ], + + elements: { + + logoutButton: { + selector: '.pull-right' + }, + + userProfileDropdown: { + selector: '//div[@id="topmenu-login-dropdown"]', + locateStrategy: 'xpath' + } + } +}; diff --git a/test/acceptance/stepDefinitions/addUsersContext.js b/test/acceptance/stepDefinitions/addUsersContext.js new file mode 100644 index 00000000000..6f1745bff94 --- /dev/null +++ b/test/acceptance/stepDefinitions/addUsersContext.js @@ -0,0 +1,123 @@ +const { Before, Given, When, Then, After } = require('cucumber'); +const { client } = require('nightwatch-api'); +const fetch = require('node-fetch'); +let initialUsers = {}; + +Given('the administrator has logged in using the webUI', async function () { + await client.page.loginPage().navigate().waitForLoginPage(); + await client.page.loginPage().userLogsInWithUsernameAndPassword(client.globals.adminUsername, client.globals.adminPassword); + return client.page.loginPage().userIsLoggedIn(client.globals.adminUsername); +}); + +Given('the administrator has browsed to the new users page', function () { + return client.page.homePage().browsedToNewUserPage(); +}); + +When('the admin creates user with following details', function (datatable) { + return client.page.addUsersPage().adminCreatesUser(datatable); +}); + +Then('new user {string} should be created', function (lastname) { + return client.page.addUsersPage().newUserShouldBeCreated(lastname); +}); + +Then('message {string} should be displayed in the webUI', function (message) { + return client.page.addUsersPage().noPermissionMessage(message); +}); + +Then('message {string} should not be displayed in the webUI', function (message) { + return client.page.addUsersPage().noPermissionDefinedMessageNotShown(message); +}); + +Then('new user {string} should not be created', function (lastname) { + return client.page.addUsersPage().userNotCreated(lastname); +}); + +Given('a user has been created with following details', function (dataTable) { + return adminHasCreatedUser(dataTable); +}); + +Given('the admin has created the following users', function (dataTable) { + return adminHasCreatedUser(dataTable); +}); + +const getUsers = async function () { + const header = {}; + const url = client.globals.backend_url + 'api/index.php/users'; + const users = {}; + header['Accept'] = 'application/json'; + header['DOLAPIKEY'] = client.globals.dolApiKey; + await fetch(url, { + method: 'GET', + headers: header + }) + .then(async (response) => { + const json_response = await response.json(); + for (const user of json_response) { + users[user.id] = user.id; + } + }); + return users; +}; + +const adminHasCreatedUser = async function (dataTable) { + const header = {}; + const url = client.globals.backend_url + 'api/index.php/users'; + header['Accept'] = 'application/json'; + header['DOLAPIKEY'] = client.globals.dolApiKey; + header['Content-Type'] = 'application/json'; + const userDetails = dataTable.hashes(); + for (const user of userDetails) { + await fetch(url, { + method: 'POST', + headers: header, + body: JSON.stringify( + { + login: user['login'], + lastname: user['last name'], + pass: user['password'] + } + ) + }) + .then((response) => { + if (response.status < 200 || response.status >= 400) { + throw new Error('Failed to create user: ' + user['login'] + + ' ' + response.statusText); + } + return response.text(); + }); + } +}; + +Before(async () => { + initialUsers = await getUsers(); +}); + +After(async () => { + const finalUsers = await getUsers(); + const header = {}; + const url = client.globals.backend_url + 'api/index.php/users/'; + header['Accept'] = 'application/json'; + header['DOLAPIKEY'] = client.globals.dolApiKey; + let found; + for (const finaluser in finalUsers) { + for (const initialuser in initialUsers) { + found = false; + if (initialuser === finaluser) { + found = true; + break; + } + } + if (!found) { + await fetch(url + finaluser, { + method: 'DELETE', + headers: header + }) + .then(res => { + if (res.status < 200 || res.status >= 400) { + throw new Error("Failed to delete user: " + res.statusText); + } + }); + } + } +}); diff --git a/test/acceptance/stepDefinitions/listUsersContext.js b/test/acceptance/stepDefinitions/listUsersContext.js new file mode 100644 index 00000000000..78912abd3a0 --- /dev/null +++ b/test/acceptance/stepDefinitions/listUsersContext.js @@ -0,0 +1,14 @@ +const { When, Then } = require('cucumber'); +const { client } = require('nightwatch-api'); + +When('the administrator browses to the list of users page using the webUI', function () { + return client.page.homePage().browsedToListOfUsers(); +}); + +Then('following users should be displayed in the users list', function (dataTable) { + return client.page.listUsersPage().listOfUsersDisplayed(dataTable); +}); + +Then('the number of created users should be {int}', function (number) { + return client.page.listUsersPage().numberOfUsersDisplayed(number); +}); diff --git a/test/acceptance/stepDefinitions/loginContext.js b/test/acceptance/stepDefinitions/loginContext.js new file mode 100644 index 00000000000..428fd7b5dc7 --- /dev/null +++ b/test/acceptance/stepDefinitions/loginContext.js @@ -0,0 +1,22 @@ +const { Given, When, Then } = require('cucumber') +const { client } = require('nightwatch-api') + +Given('the user has browsed to the login page', function () { + return client.page.loginPage().navigate(); +}); + +When('user logs in with username {string} and password {string}', function (username, password) { + return client.page.loginPage().userLogsInWithUsernameAndPassword(username, password); +}); + +Then('the user should be directed to the homepage', function () { + return client.page.loginPage().successfulLogin(); +}); + +Then('the user should not be able to login', function () { + return client.page.loginPage().unsuccessfulLogin(); +}); + +Then('error message {string} should be displayed in the webUI', function (errormessage) { + return client.page.loginPage().loginErrorDisplayed(errormessage); +}); diff --git a/test/acceptance/stepDefinitions/logoutContext.js b/test/acceptance/stepDefinitions/logoutContext.js new file mode 100644 index 00000000000..018bf566cfb --- /dev/null +++ b/test/acceptance/stepDefinitions/logoutContext.js @@ -0,0 +1,14 @@ +const { When, Then } = require('cucumber'); +const { client } = require('nightwatch-api'); + +When('the user opens the user profile using the webUI', function () { + return client.page.logoutPage().userOpensProfile(); +}); + +When('the user logs out using the webUI', function () { + return client.page.logoutPage().userLogsOut(); +}); + +Then('the user should be logged out successfully', function () { + return client.page.loginPage().waitForLoginPage(); +}); From f343fbb55ebb31bca209f7babef2869e63197fd4 Mon Sep 17 00:00:00 2001 From: SwikritiT Date: Tue, 6 Oct 2020 13:08:47 +0545 Subject: [PATCH 2/4] travis setup Co-authored-by: Yamuna Adhikari --- .travis.yml | 559 +++++++++--------- nightwatch.conf.js | 4 +- package.json | 3 +- .../stepDefinitions/addUsersContext.js | 25 +- 4 files changed, 312 insertions(+), 279 deletions(-) diff --git a/.travis.yml b/.travis.yml index c47e1b19598..36e3f42a9cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,48 +8,63 @@ dist: xenial #dist: bionic sudo: required -language: php +matrix: + include: + - language: php + php: + - '5.6' + - '7.0' + - '7.1' + - '7.2' + - '7.3' + - '7.4' + - nightly + + - language: node_js + node_js: + - '12.14.0' + before_install: + - docker run -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm --name selenium selenium/standalone-chrome-debug + install: + - npm install + script: yarn test:e2e test/acceptance/features + env: + global: + - LAUNCH_URL=http://127.0.0.1/$TRAVIS_BUILD_DIR/htdocs # Start on every boot services: -- memcached -- mysql -- postgresql + - memcached + - mysql + - postgresql + - docker addons: # Force postgresql to 9.4 (the oldest availablable on xenial) postgresql: '9.4' apt: sources: - # To use the last version of pgloader, we add repo of postgresql with a name available in http://apt.postgresql.org/pub/repos/apt/ - - pgdg-xenial + # To use the last version of pgloader, we add repo of postgresql with a name available in http://apt.postgresql.org/pub/repos/apt/ + - pgdg-xenial packages: - # We need a webserver to test the webservices - # Let's install Apache with. - - apache2 - # mod_php is not supported by Travis. Add fcgi. We install FPM later on. - - libapache2-mod-fastcgi - # We need pgloader for import mysql database into pgsql - - pgloader + # We need a webserver to test the webservices + # Let's install Apache with. + - apache2 + # mod_php is not supported by Travis. Add fcgi. We install FPM later on. + - libapache2-mod-fastcgi + # We need pgloader for import mysql database into pgsql + - pgloader -php: -- '5.6' -- '7.0' -- '7.1' -- '7.2' -- '7.3' -- '7.4' -- nightly env: global: - # Set to true for very verbose output - - DEBUG=false + # Set to true for very verbose output + - DEBUG=false jobs: - # MariaDB overrides MySQL installation so it's not possible to test both yet - #- DB=mariadb - - DB=mysql - - DB=postgresql + # MariaDB overrides MySQL installation so it's not possible to test both yet + #- DB=mariadb + - DB=mysql + - DB=postgresql # See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP #- WS=apache # See https://github.com/DracoBlue/travis-ci-nginx-php-fpm-test @@ -58,27 +73,27 @@ env: jobs: fast_finish: true allow_failures: - - php: nightly + - php: nightly # We exclude some combinations not usefull to save Travis CPU exclude: - - php: '7.0' - env: DB=mysql - - php: '7.1' - env: DB=mysql - - php: '7.2' - env: DB=mysql - - php: '7.3' - env: DB=mysql - - php: '7.0' - env: DB=postgresql - - php: '7.1' - env: DB=postgresql - - php: '7.2' - env: DB=postgresql - - php: '7.3' - env: DB=postgresql - - php: nightly - env: DB=postgresql + - php: '7.0' + env: DB=mysql + - php: '7.1' + env: DB=mysql + - php: '7.2' + env: DB=mysql + - php: '7.3' + env: DB=mysql + - php: '7.0' + env: DB=postgresql + - php: '7.1' + env: DB=postgresql + - php: '7.2' + env: DB=postgresql + - php: '7.3' + env: DB=postgresql + - php: nightly + env: DB=postgresql notifications: email: @@ -86,59 +101,59 @@ notifications: on_failure: never # [always|never|change] default: always irc: channels: - - "chat.freenode.net#dolibarr" + - "chat.freenode.net#dolibarr" on_success: change on_failure: always use_notice: true before_install: -- | - echo "Disabling Xdebug for composer" - export PHP_VERSION_NAME=$(phpenv version-name) - cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/conf.d/xdebug.ini /tmp/xdebug.ini - phpenv config-rm xdebug.ini - echo - -- | - if [ "$DB" = 'postgresql' ]; then - echo "Check pgloader version" - pgloader --version + - | + echo "Disabling Xdebug for composer" + export PHP_VERSION_NAME=$(phpenv version-name) + cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/conf.d/xdebug.ini /tmp/xdebug.ini + phpenv config-rm xdebug.ini echo - fi + + - | + if [ "$DB" = 'postgresql' ]; then + echo "Check pgloader version" + pgloader --version + echo + fi install: -- | - echo "Updating Composer" - rm $TRAVIS_BUILD_DIR/composer.json - rm $TRAVIS_BUILD_DIR/composer.lock - composer self-update - # To have composer making parallel downloads - composer global require hirak/prestissimo - composer -n init - composer -n config vendor-dir htdocs/includes - echo + - | + echo "Updating Composer" + rm $TRAVIS_BUILD_DIR/composer.json + rm $TRAVIS_BUILD_DIR/composer.lock + composer self-update + # To have composer making parallel downloads + composer global require hirak/prestissimo + composer -n init + composer -n config vendor-dir htdocs/includes + echo -- | - echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer - for $TRAVIS_PHP_VERSION" - if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \ - [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then - composer -n require phpunit/phpunit ^5 \ - php-parallel-lint/php-parallel-lint ^0 \ - php-parallel-lint/php-console-highlighter ^0 \ - squizlabs/php_codesniffer ^3 - fi - if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then - composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \ - php-parallel-lint/php-parallel-lint ^1 \ - php-parallel-lint/php-console-highlighter ^0 \ - squizlabs/php_codesniffer ^3 + - | + echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer - for $TRAVIS_PHP_VERSION" + if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \ + [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then + composer -n require phpunit/phpunit ^5 \ + php-parallel-lint/php-parallel-lint ^0 \ + php-parallel-lint/php-console-highlighter ^0 \ + squizlabs/php_codesniffer ^3 fi - echo + if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \ + php-parallel-lint/php-parallel-lint ^1 \ + php-parallel-lint/php-console-highlighter ^0 \ + squizlabs/php_codesniffer ^3 + fi + echo -- | - echo "Adding path of binaries tools installed by composer to the PATH" - export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" - echo + - | + echo "Adding path of binaries tools installed by composer to the PATH" + export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" + echo @@ -261,201 +276,201 @@ before_script: script: -- | - echo "Checking webserver availability by a wget -O - http://127.0.0.1" - # Ensure we stop on error with set -e - set +e - # The wget should return a page with line ' - wget -O - http://127.0.0.1 > test.html - head test.html - sudo cat /var/log/apache2/travis_error_log - set +e - echo + - | + echo "Checking webserver availability by a wget -O - http://127.0.0.1" + # Ensure we stop on error with set -e + set +e + # The wget should return a page with line ' + wget -O - http://127.0.0.1 > test.html + head test.html + sudo cat /var/log/apache2/travis_error_log + set +e + echo -- | - echo "Checking PHP syntax errors" - # Ensure we catch errors - set -e - #parallel-lint --exclude htdocs/includes --blame . - parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \ - --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \ - --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \ - --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \ - --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/tecnickcom/tcpdf/include/barcodes --exclude htdocs/includes/webmozart --blame . - set +e - echo + - | + echo "Checking PHP syntax errors" + # Ensure we catch errors + set -e + #parallel-lint --exclude htdocs/includes --blame . + parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \ + --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \ + --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \ + --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \ + --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/tecnickcom/tcpdf/include/barcodes --exclude htdocs/includes/webmozart --blame . + set +e + echo -- | - echo "Checking coding style (excluding Pull Requests builds)" - # Ensure we catch errors - set -e - # Exclusions are defined in the ruleset.xml file - #phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true . - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi - set +e - echo + - | + echo "Checking coding style (excluding Pull Requests builds)" + # Ensure we catch errors + set -e + # Exclusions are defined in the ruleset.xml file + #phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true . + if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi + set +e + echo -- | - export INSTALL_FORCED_FILE=htdocs/install/install.forced.php - echo "Setting up Dolibarr $INSTALL_FORCED_FILE to test installation" - # Ensure we catch errors - set +e - echo ' $INSTALL_FORCED_FILE - echo '$'force_install_noedit=2';' >> $INSTALL_FORCED_FILE - if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then - echo '$'force_install_type=\'mysqli\'';' >> $INSTALL_FORCED_FILE - fi - if [ "$DB" = 'postgresql' ]; then - echo '$'force_install_type=\'pgsql\'';' >> $INSTALL_FORCED_FILE - fi - echo '$'force_install_dbserver=\'127.0.0.1\'';' >> $INSTALL_FORCED_FILE - echo '$'force_install_database=\'travis\'';' >> $INSTALL_FORCED_FILE - echo '$'force_install_databaselogin=\'travis\'';' >> $INSTALL_FORCED_FILE - echo '$'force_install_databasepass=\'\'';' >> $INSTALL_FORCED_FILE - echo '$'force_install_port=\'5432\'';' >> $INSTALL_FORCED_FILE - echo '$'force_install_prefix=\'llx_\'';' >> $INSTALL_FORCED_FILE - echo '$'force_install_createdatabase=false';' >> $INSTALL_FORCED_FILE - echo '$'force_install_createuser=false';' >> $INSTALL_FORCED_FILE - echo '$'force_install_mainforcehttps=false';' >> $INSTALL_FORCED_FILE - echo '$'force_install_main_data_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $INSTALL_FORCED_FILE - #cat $INSTALL_FORCED_FILE + - | + export INSTALL_FORCED_FILE=htdocs/install/install.forced.php + echo "Setting up Dolibarr $INSTALL_FORCED_FILE to test installation" + # Ensure we catch errors + set +e + echo ' $INSTALL_FORCED_FILE + echo '$'force_install_noedit=2';' >> $INSTALL_FORCED_FILE + if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then + echo '$'force_install_type=\'mysqli\'';' >> $INSTALL_FORCED_FILE + fi + if [ "$DB" = 'postgresql' ]; then + echo '$'force_install_type=\'pgsql\'';' >> $INSTALL_FORCED_FILE + fi + echo '$'force_install_dbserver=\'127.0.0.1\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_database=\'travis\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_databaselogin=\'travis\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_databasepass=\'\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_port=\'5432\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_prefix=\'llx_\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_createdatabase=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_createuser=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_mainforcehttps=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_main_data_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $INSTALL_FORCED_FILE + #cat $INSTALL_FORCED_FILE -#- | -# echo "Installing Dolibarr" -# cd htdocs/install -# php step1.php $TRAVIS_BUILD_DIR/htdocs > $TRAVIS_BUILD_DIR/install.log -# php step2.php set >> $TRAVIS_BUILD_DIR/install.log -# if [ "$?" -ne "0" ]; then -# echo "SORRY, AN ERROR OCCURED DURING INSTALLATION PROCESS" -# cat $TRAVIS_BUILD_DIR/install.log -# exit 1 -# fi -# cd ../.. -# rm $INSTALL_FORCED_FILE -# #cat $TRAVIS_BUILD_DIR/install.log -# set +e -# echo + #- | + # echo "Installing Dolibarr" + # cd htdocs/install + # php step1.php $TRAVIS_BUILD_DIR/htdocs > $TRAVIS_BUILD_DIR/install.log + # php step2.php set >> $TRAVIS_BUILD_DIR/install.log + # if [ "$?" -ne "0" ]; then + # echo "SORRY, AN ERROR OCCURED DURING INSTALLATION PROCESS" + # cat $TRAVIS_BUILD_DIR/install.log + # exit 1 + # fi + # cd ../.. + # rm $INSTALL_FORCED_FILE + # #cat $TRAVIS_BUILD_DIR/install.log + # set +e + # echo -- | - echo "Setting up database to test migrations" - if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then - echo "MySQL" - mysql -e 'DROP DATABASE IF EXISTS travis;' - mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' - mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' - mysql -e 'FLUSH PRIVILEGES;' - mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql - fi - if [ "$DB" = 'postgresql' ]; then - #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql - #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr - echo pgloader mysql://root@127.0.0.1/travis postgresql:///travis - pgloader mysql://root@127.0.0.1/travis postgresql:///travis - echo 'ALTER SEQUENCE llx_accountingaccount_rowid_seq RENAME TO llx_accounting_account_rowid_seq' | psql travis - echo 'ALTER SEQUENCE llx_accounting_account_rowid_seq RESTART WITH 1000001;' | psql travis - #echo 'select * from INFORMATION_SCHEMA.COLUMNS where table_name = 'llx_accountingaccount' | psql travis - #echo 'select * from information_schema.table_constraints;' | psql travis - #echo 'ALTER TABLE "llx_accounting_account" DROP CONSTRAINT "idx_16390_primary"' | psql travis - fi - echo + - | + echo "Setting up database to test migrations" + if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then + echo "MySQL" + mysql -e 'DROP DATABASE IF EXISTS travis;' + mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' + mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' + mysql -e 'FLUSH PRIVILEGES;' + mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + fi + if [ "$DB" = 'postgresql' ]; then + #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr + echo pgloader mysql://root@127.0.0.1/travis postgresql:///travis + pgloader mysql://root@127.0.0.1/travis postgresql:///travis + echo 'ALTER SEQUENCE llx_accountingaccount_rowid_seq RENAME TO llx_accounting_account_rowid_seq' | psql travis + echo 'ALTER SEQUENCE llx_accounting_account_rowid_seq RESTART WITH 1000001;' | psql travis + #echo 'select * from INFORMATION_SCHEMA.COLUMNS where table_name = 'llx_accountingaccount' | psql travis + #echo 'select * from information_schema.table_constraints;' | psql travis + #echo 'ALTER TABLE "llx_accounting_account" DROP CONSTRAINT "idx_16390_primary"' | psql travis + fi + echo -- | - echo "Upgrading Dolibarr" - # Ensure we catch errors. Set this to +e if you want to go to the end to see log files. - set +e - cd htdocs/install - php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log - php upgrade2.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-2.log - php step5.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-3.log - php upgrade.php 3.6.0 3.7.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade360370.log - php upgrade2.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-2.log - php step5.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-3.log - php upgrade.php 3.7.0 3.8.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade370380.log - php upgrade2.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-2.log - php step5.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-3.log - php upgrade.php 3.8.0 3.9.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade380390.log - php upgrade2.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-2.log - php step5.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-3.log - php upgrade.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400.log - php upgrade2.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-2.log - php step5.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-3.log - php upgrade.php 4.0.0 5.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade400500.log - php upgrade2.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-2.log - php step5.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-3.log - php upgrade.php 5.0.0 6.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade500600.log - php upgrade2.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-2.log - php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log - php upgrade.php 6.0.0 7.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade600700.log - php upgrade2.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-2.log - php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log - php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log - php upgrade2.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-2.log - php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log - php upgrade.php 8.0.0 9.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade800900.log - php upgrade2.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-2.log - php step5.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-3.log - php upgrade.php 9.0.0 10.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade9001000.log - php upgrade2.php 9.0.0 10.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-2.log - php step5.php 9.0.0 10.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-3.log - php upgrade.php 10.0.0 11.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade10001100.log - php upgrade2.php 10.0.0 11.0.0 > $TRAVIS_BUILD_DIR/upgrade10001100-2.log - php step5.php 10.0.0 11.0.0 > $TRAVIS_BUILD_DIR/upgrade10001100-3.log - php upgrade.php 11.0.0 12.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade11001200.log - php upgrade2.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-2.log - php step5.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-3.log - php upgrade.php 12.0.0 13.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade12001300.log - php upgrade2.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-2.log - php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log + - | + echo "Upgrading Dolibarr" + # Ensure we catch errors. Set this to +e if you want to go to the end to see log files. + set +e + cd htdocs/install + php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log + php upgrade2.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-2.log + php step5.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-3.log + php upgrade.php 3.6.0 3.7.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade360370.log + php upgrade2.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-2.log + php step5.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-3.log + php upgrade.php 3.7.0 3.8.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade370380.log + php upgrade2.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-2.log + php step5.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-3.log + php upgrade.php 3.8.0 3.9.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade380390.log + php upgrade2.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-2.log + php step5.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-3.log + php upgrade.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400.log + php upgrade2.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-2.log + php step5.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-3.log + php upgrade.php 4.0.0 5.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade400500.log + php upgrade2.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-2.log + php step5.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-3.log + php upgrade.php 5.0.0 6.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade500600.log + php upgrade2.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-2.log + php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log + php upgrade.php 6.0.0 7.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade600700.log + php upgrade2.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-2.log + php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log + php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log + php upgrade2.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-2.log + php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log + php upgrade.php 8.0.0 9.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade800900.log + php upgrade2.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-2.log + php step5.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-3.log + php upgrade.php 9.0.0 10.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade9001000.log + php upgrade2.php 9.0.0 10.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-2.log + php step5.php 9.0.0 10.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-3.log + php upgrade.php 10.0.0 11.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade10001100.log + php upgrade2.php 10.0.0 11.0.0 > $TRAVIS_BUILD_DIR/upgrade10001100-2.log + php step5.php 10.0.0 11.0.0 > $TRAVIS_BUILD_DIR/upgrade10001100-3.log + php upgrade.php 11.0.0 12.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade11001200.log + php upgrade2.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-2.log + php step5.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-3.log + php upgrade.php 12.0.0 13.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade12001300.log + php upgrade2.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-2.log + php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log - # Enable modules not enabled into original dump - php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING > $TRAVIS_BUILD_DIR/enablemodule.log - echo $? - cd - - set +e - echo - #cat /tmp/dolibarr_install.log - cat $TRAVIS_BUILD_DIR/enablemodule.log + # Enable modules not enabled into original dump + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING > $TRAVIS_BUILD_DIR/enablemodule.log + echo $? + cd - + set +e + echo + #cat /tmp/dolibarr_install.log + cat $TRAVIS_BUILD_DIR/enablemodule.log -- | - echo "Unit testing" - # Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file. - set -e - phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php - phpunitresult=$? - echo "Phpunit return code = $phpunitresult" - set +e + - | + echo "Unit testing" + # Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file. + set -e + phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php + phpunitresult=$? + echo "Phpunit return code = $phpunitresult" + set +e after_script: -- | - echo "After script - Output lines of dolibarr.log" - ls $TRAVIS_BUILD_DIR/documents - #cat $TRAVIS_BUILD_DIR/documents/dolibarr.log - sudo tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log + - | + echo "After script - Output lines of dolibarr.log" + ls $TRAVIS_BUILD_DIR/documents + #cat $TRAVIS_BUILD_DIR/documents/dolibarr.log + sudo tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log after_success: -- | - echo Success + - | + echo Success after_failure: -- | - echo Failure detected, so we show samples of log to help diagnose - # This part of code is executed only if previous command that fails are enclosed with set +e - # Upgrade log files - for ficlog in `ls $TRAVIS_BUILD_DIR/*.log` - do - echo "Debugging informations for file $ficlog" - #cat $ficlog - done - # Apache log file - echo "Debugging informations for file apache error.log" - sudo cat /var/log/apache2/travis_error_log - if [ "$DEBUG" = true ]; then - # Dolibarr log file - echo "Debugging informations for file dolibarr.log (latest 50 lines)" - tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log - # Database log file - echo "Debugging informations for file mysql error.log" - sudo tail -n 50 /var/log/mysql/error.log - # TODO: PostgreSQL log file - echo - fi + - | + echo Failure detected, so we show samples of log to help diagnose + # This part of code is executed only if previous command that fails are enclosed with set +e + # Upgrade log files + for ficlog in `ls $TRAVIS_BUILD_DIR/*.log` + do + echo "Debugging informations for file $ficlog" + #cat $ficlog + done + # Apache log file + echo "Debugging informations for file apache error.log" + sudo cat /var/log/apache2/travis_error_log + if [ "$DEBUG" = true ]; then + # Dolibarr log file + echo "Debugging informations for file dolibarr.log (latest 50 lines)" + tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log + # Database log file + echo "Debugging informations for file mysql error.log" + sudo tail -n 50 /var/log/mysql/error.log + # TODO: PostgreSQL log file + echo + fi diff --git a/nightwatch.conf.js b/nightwatch.conf.js index 1c4b089baa9..8d92613d638 100644 --- a/nightwatch.conf.js +++ b/nightwatch.conf.js @@ -1,7 +1,6 @@ const admin_username = process.env.ADMIN_USERNAME || 'dolibarr'; const admin_password = process.env.ADMIN_PASSWORD || 'password'; const launch_url = process.env.LAUNCH_URL || 'http://localhost/dolibarr/htdocs/'; -const dol_api_key = process.env.DOLAPIKEY || 'superadminuser'; module.exports = { page_objects_path : './test/acceptance/pageObjects/', // jshint ignore:line src_folders : ['test'], @@ -13,8 +12,7 @@ module.exports = { globals : { backend_url : launch_url, adminUsername : admin_username, - adminPassword : admin_password, - dolApiKey : dol_api_key + adminPassword : admin_password }, desiredCapabilities : { browserName : 'chrome', diff --git a/package.json b/package.json index 7ea03c08bca..67f24dd541a 100644 --- a/package.json +++ b/package.json @@ -5,9 +5,10 @@ "nightwatch-api": "^3.0.1" }, "scripts": { - "test:e2e": "node_modules/cucumber/bin/cucumber-js --require test/acceptance/index.js --require test/acceptance/stepDefinitions" + "test:e2e": "node_modules/cucumber/bin/cucumber-js --require test/acceptance/index.js --require test/acceptance/stepDefinitions -f node_modules/cucumber-pretty" }, "dependencies": { + "cucumber-pretty": "^6.0.0", "node-fetch": "^2.6.1" } } diff --git a/test/acceptance/stepDefinitions/addUsersContext.js b/test/acceptance/stepDefinitions/addUsersContext.js index 6f1745bff94..22dc218d04a 100644 --- a/test/acceptance/stepDefinitions/addUsersContext.js +++ b/test/acceptance/stepDefinitions/addUsersContext.js @@ -2,6 +2,7 @@ const { Before, Given, When, Then, After } = require('cucumber'); const { client } = require('nightwatch-api'); const fetch = require('node-fetch'); let initialUsers = {}; +let dolApiKey = ''; Given('the administrator has logged in using the webUI', async function () { await client.page.loginPage().navigate().waitForLoginPage(); @@ -46,7 +47,7 @@ const getUsers = async function () { const url = client.globals.backend_url + 'api/index.php/users'; const users = {}; header['Accept'] = 'application/json'; - header['DOLAPIKEY'] = client.globals.dolApiKey; + header['DOLAPIKEY'] = dolApiKey; await fetch(url, { method: 'GET', headers: header @@ -64,7 +65,7 @@ const adminHasCreatedUser = async function (dataTable) { const header = {}; const url = client.globals.backend_url + 'api/index.php/users'; header['Accept'] = 'application/json'; - header['DOLAPIKEY'] = client.globals.dolApiKey; + header['DOLAPIKEY'] = dolApiKey; header['Content-Type'] = 'application/json'; const userDetails = dataTable.hashes(); for (const user of userDetails) { @@ -89,6 +90,24 @@ const adminHasCreatedUser = async function (dataTable) { } }; +Before(async () => { + const header = {} + const adminUsername = client.globals.adminUsername; + const adminPassword = client.globals.adminPassword; + const params = new URLSearchParams() + params.set('login', adminUsername) + params.set('password', adminPassword) + const apiKey = `http://localhost/dolibarr/htdocs/api/index.php/login?${params.toString()}`; + header['Accept'] = 'application/json' + await fetch(apiKey, { + method: 'GET', + headers: header + }) + .then(async (response) => { + const jsonResponse = await response.json() + dolApiKey = jsonResponse['success']['token'] + }) +}) Before(async () => { initialUsers = await getUsers(); }); @@ -98,7 +117,7 @@ After(async () => { const header = {}; const url = client.globals.backend_url + 'api/index.php/users/'; header['Accept'] = 'application/json'; - header['DOLAPIKEY'] = client.globals.dolApiKey; + header['DOLAPIKEY'] = dolApiKey; let found; for (const finaluser in finalUsers) { for (const initialuser in initialUsers) { From 7b4123cb78f2085b5746efaa443ae51feb739ca8 Mon Sep 17 00:00:00 2001 From: SwikritiT Date: Tue, 6 Oct 2020 13:14:41 +0545 Subject: [PATCH 3/4] git ignore Co-authored-by: Yamuna Adhikari --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index ac7a618c503..b49fdf8dc86 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,5 @@ yarn.lock #package-lock package-lock.json + +doc/install.lock From 475893f4de07b3c3185fe561944fa1a0e455d3ba Mon Sep 17 00:00:00 2001 From: SwikritiT Date: Thu, 8 Oct 2020 12:50:22 +0545 Subject: [PATCH 4/4] READ ME added Co-authored-by: Yamuna Adhikari --- .travis.yml | 559 ++++++++++++++++++++++++------------------------- test/README.md | 56 +++++ 2 files changed, 328 insertions(+), 287 deletions(-) create mode 100644 test/README.md diff --git a/.travis.yml b/.travis.yml index 36e3f42a9cb..c47e1b19598 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,63 +8,48 @@ dist: xenial #dist: bionic sudo: required -matrix: - include: - - language: php - php: - - '5.6' - - '7.0' - - '7.1' - - '7.2' - - '7.3' - - '7.4' - - nightly - - - language: node_js - node_js: - - '12.14.0' - before_install: - - docker run -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm --name selenium selenium/standalone-chrome-debug - install: - - npm install - script: yarn test:e2e test/acceptance/features - env: - global: - - LAUNCH_URL=http://127.0.0.1/$TRAVIS_BUILD_DIR/htdocs +language: php # Start on every boot services: - - memcached - - mysql - - postgresql - - docker +- memcached +- mysql +- postgresql addons: # Force postgresql to 9.4 (the oldest availablable on xenial) postgresql: '9.4' apt: sources: - # To use the last version of pgloader, we add repo of postgresql with a name available in http://apt.postgresql.org/pub/repos/apt/ - - pgdg-xenial + # To use the last version of pgloader, we add repo of postgresql with a name available in http://apt.postgresql.org/pub/repos/apt/ + - pgdg-xenial packages: - # We need a webserver to test the webservices - # Let's install Apache with. - - apache2 - # mod_php is not supported by Travis. Add fcgi. We install FPM later on. - - libapache2-mod-fastcgi - # We need pgloader for import mysql database into pgsql - - pgloader + # We need a webserver to test the webservices + # Let's install Apache with. + - apache2 + # mod_php is not supported by Travis. Add fcgi. We install FPM later on. + - libapache2-mod-fastcgi + # We need pgloader for import mysql database into pgsql + - pgloader +php: +- '5.6' +- '7.0' +- '7.1' +- '7.2' +- '7.3' +- '7.4' +- nightly env: global: - # Set to true for very verbose output - - DEBUG=false + # Set to true for very verbose output + - DEBUG=false jobs: - # MariaDB overrides MySQL installation so it's not possible to test both yet - #- DB=mariadb - - DB=mysql - - DB=postgresql + # MariaDB overrides MySQL installation so it's not possible to test both yet + #- DB=mariadb + - DB=mysql + - DB=postgresql # See https://docs.travis-ci.com/user/languages/php/#Apache-%2B-PHP #- WS=apache # See https://github.com/DracoBlue/travis-ci-nginx-php-fpm-test @@ -73,27 +58,27 @@ env: jobs: fast_finish: true allow_failures: - - php: nightly + - php: nightly # We exclude some combinations not usefull to save Travis CPU exclude: - - php: '7.0' - env: DB=mysql - - php: '7.1' - env: DB=mysql - - php: '7.2' - env: DB=mysql - - php: '7.3' - env: DB=mysql - - php: '7.0' - env: DB=postgresql - - php: '7.1' - env: DB=postgresql - - php: '7.2' - env: DB=postgresql - - php: '7.3' - env: DB=postgresql - - php: nightly - env: DB=postgresql + - php: '7.0' + env: DB=mysql + - php: '7.1' + env: DB=mysql + - php: '7.2' + env: DB=mysql + - php: '7.3' + env: DB=mysql + - php: '7.0' + env: DB=postgresql + - php: '7.1' + env: DB=postgresql + - php: '7.2' + env: DB=postgresql + - php: '7.3' + env: DB=postgresql + - php: nightly + env: DB=postgresql notifications: email: @@ -101,59 +86,59 @@ notifications: on_failure: never # [always|never|change] default: always irc: channels: - - "chat.freenode.net#dolibarr" + - "chat.freenode.net#dolibarr" on_success: change on_failure: always use_notice: true before_install: - - | - echo "Disabling Xdebug for composer" - export PHP_VERSION_NAME=$(phpenv version-name) - cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/conf.d/xdebug.ini /tmp/xdebug.ini - phpenv config-rm xdebug.ini - echo +- | + echo "Disabling Xdebug for composer" + export PHP_VERSION_NAME=$(phpenv version-name) + cp ~/.phpenv/versions/$PHP_VERSION_NAME/etc/conf.d/xdebug.ini /tmp/xdebug.ini + phpenv config-rm xdebug.ini + echo - - | - if [ "$DB" = 'postgresql' ]; then - echo "Check pgloader version" - pgloader --version - echo - fi +- | + if [ "$DB" = 'postgresql' ]; then + echo "Check pgloader version" + pgloader --version + echo + fi install: - - | - echo "Updating Composer" - rm $TRAVIS_BUILD_DIR/composer.json - rm $TRAVIS_BUILD_DIR/composer.lock - composer self-update - # To have composer making parallel downloads - composer global require hirak/prestissimo - composer -n init - composer -n config vendor-dir htdocs/includes - echo +- | + echo "Updating Composer" + rm $TRAVIS_BUILD_DIR/composer.json + rm $TRAVIS_BUILD_DIR/composer.lock + composer self-update + # To have composer making parallel downloads + composer global require hirak/prestissimo + composer -n init + composer -n config vendor-dir htdocs/includes + echo - - | - echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer - for $TRAVIS_PHP_VERSION" - if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \ - [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then - composer -n require phpunit/phpunit ^5 \ - php-parallel-lint/php-parallel-lint ^0 \ - php-parallel-lint/php-console-highlighter ^0 \ - squizlabs/php_codesniffer ^3 +- | + echo "Installing Composer dependencies - PHP Unit, Parallel Lint, PHP CodeSniffer - for $TRAVIS_PHP_VERSION" + if [ "$TRAVIS_PHP_VERSION" = '5.6' ] || [ "$TRAVIS_PHP_VERSION" = '7.0' ] || [ "$TRAVIS_PHP_VERSION" = '7.1' ] \ + [ "$TRAVIS_PHP_VERSION" = '7.2' ] || [ "$TRAVIS_PHP_VERSION" = '7.3' ] || [ "$TRAVIS_PHP_VERSION" = '7.4' ]; then + composer -n require phpunit/phpunit ^5 \ + php-parallel-lint/php-parallel-lint ^0 \ + php-parallel-lint/php-console-highlighter ^0 \ + squizlabs/php_codesniffer ^3 + fi + if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then + composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \ + php-parallel-lint/php-parallel-lint ^1 \ + php-parallel-lint/php-console-highlighter ^0 \ + squizlabs/php_codesniffer ^3 fi - if [ "$TRAVIS_PHP_VERSION" = 'nightly' ]; then - composer -n require --ignore-platform-reqs phpunit/phpunit ^5 \ - php-parallel-lint/php-parallel-lint ^1 \ - php-parallel-lint/php-console-highlighter ^0 \ - squizlabs/php_codesniffer ^3 - fi - echo + echo - - | - echo "Adding path of binaries tools installed by composer to the PATH" - export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" - echo +- | + echo "Adding path of binaries tools installed by composer to the PATH" + export PATH="$TRAVIS_BUILD_DIR/htdocs/includes/bin:$PATH" + echo @@ -276,201 +261,201 @@ before_script: script: - - | - echo "Checking webserver availability by a wget -O - http://127.0.0.1" - # Ensure we stop on error with set -e - set +e - # The wget should return a page with line ' - wget -O - http://127.0.0.1 > test.html - head test.html - sudo cat /var/log/apache2/travis_error_log - set +e - echo +- | + echo "Checking webserver availability by a wget -O - http://127.0.0.1" + # Ensure we stop on error with set -e + set +e + # The wget should return a page with line ' + wget -O - http://127.0.0.1 > test.html + head test.html + sudo cat /var/log/apache2/travis_error_log + set +e + echo - - | - echo "Checking PHP syntax errors" - # Ensure we catch errors - set -e - #parallel-lint --exclude htdocs/includes --blame . - parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \ - --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \ - --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \ - --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \ - --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/tecnickcom/tcpdf/include/barcodes --exclude htdocs/includes/webmozart --blame . - set +e - echo +- | + echo "Checking PHP syntax errors" + # Ensure we catch errors + set -e + #parallel-lint --exclude htdocs/includes --blame . + parallel-lint --exclude dev/namespacemig --exclude htdocs/includes/composer --exclude htdocs/includes/myclabs --exclude htdocs/includes/phpspec --exclude dev/initdata/dbf/includes \ + --exclude htdocs/includes/sabre --exclude htdocs/includes/phpoffice/phpexcel --exclude htdocs/includes/phpoffice/PhpSpreadsheet --exclude htdocs/includes/sebastian \ + --exclude htdocs/includes/squizlabs/php_codesniffer --exclude htdocs/includes/jakub-onderka --exclude htdocs/includes/php-parallel-lint --exclude htdocs/includes/symfony \ + --exclude htdocs/includes/mike42/escpos-php/example --exclude htdocs/includes/maximebf \ + --exclude htdocs/includes/phpunit/ --exclude htdocs/includes/tecnickcom/tcpdf/include/barcodes --exclude htdocs/includes/webmozart --blame . + set +e + echo - - | - echo "Checking coding style (excluding Pull Requests builds)" - # Ensure we catch errors - set -e - # Exclusions are defined in the ruleset.xml file - #phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true . - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi - set +e - echo +- | + echo "Checking coding style (excluding Pull Requests builds)" + # Ensure we catch errors + set -e + # Exclusions are defined in the ruleset.xml file + #phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true . + if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi + set +e + echo - - | - export INSTALL_FORCED_FILE=htdocs/install/install.forced.php - echo "Setting up Dolibarr $INSTALL_FORCED_FILE to test installation" - # Ensure we catch errors - set +e - echo ' $INSTALL_FORCED_FILE - echo '$'force_install_noedit=2';' >> $INSTALL_FORCED_FILE - if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then - echo '$'force_install_type=\'mysqli\'';' >> $INSTALL_FORCED_FILE - fi - if [ "$DB" = 'postgresql' ]; then - echo '$'force_install_type=\'pgsql\'';' >> $INSTALL_FORCED_FILE - fi - echo '$'force_install_dbserver=\'127.0.0.1\'';' >> $INSTALL_FORCED_FILE - echo '$'force_install_database=\'travis\'';' >> $INSTALL_FORCED_FILE - echo '$'force_install_databaselogin=\'travis\'';' >> $INSTALL_FORCED_FILE - echo '$'force_install_databasepass=\'\'';' >> $INSTALL_FORCED_FILE - echo '$'force_install_port=\'5432\'';' >> $INSTALL_FORCED_FILE - echo '$'force_install_prefix=\'llx_\'';' >> $INSTALL_FORCED_FILE - echo '$'force_install_createdatabase=false';' >> $INSTALL_FORCED_FILE - echo '$'force_install_createuser=false';' >> $INSTALL_FORCED_FILE - echo '$'force_install_mainforcehttps=false';' >> $INSTALL_FORCED_FILE - echo '$'force_install_main_data_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $INSTALL_FORCED_FILE - #cat $INSTALL_FORCED_FILE +- | + export INSTALL_FORCED_FILE=htdocs/install/install.forced.php + echo "Setting up Dolibarr $INSTALL_FORCED_FILE to test installation" + # Ensure we catch errors + set +e + echo ' $INSTALL_FORCED_FILE + echo '$'force_install_noedit=2';' >> $INSTALL_FORCED_FILE + if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ]; then + echo '$'force_install_type=\'mysqli\'';' >> $INSTALL_FORCED_FILE + fi + if [ "$DB" = 'postgresql' ]; then + echo '$'force_install_type=\'pgsql\'';' >> $INSTALL_FORCED_FILE + fi + echo '$'force_install_dbserver=\'127.0.0.1\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_database=\'travis\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_databaselogin=\'travis\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_databasepass=\'\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_port=\'5432\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_prefix=\'llx_\'';' >> $INSTALL_FORCED_FILE + echo '$'force_install_createdatabase=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_createuser=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_mainforcehttps=false';' >> $INSTALL_FORCED_FILE + echo '$'force_install_main_data_root=\'$TRAVIS_BUILD_DIR/htdocs\'';' >> $INSTALL_FORCED_FILE + #cat $INSTALL_FORCED_FILE - #- | - # echo "Installing Dolibarr" - # cd htdocs/install - # php step1.php $TRAVIS_BUILD_DIR/htdocs > $TRAVIS_BUILD_DIR/install.log - # php step2.php set >> $TRAVIS_BUILD_DIR/install.log - # if [ "$?" -ne "0" ]; then - # echo "SORRY, AN ERROR OCCURED DURING INSTALLATION PROCESS" - # cat $TRAVIS_BUILD_DIR/install.log - # exit 1 - # fi - # cd ../.. - # rm $INSTALL_FORCED_FILE - # #cat $TRAVIS_BUILD_DIR/install.log - # set +e - # echo +#- | +# echo "Installing Dolibarr" +# cd htdocs/install +# php step1.php $TRAVIS_BUILD_DIR/htdocs > $TRAVIS_BUILD_DIR/install.log +# php step2.php set >> $TRAVIS_BUILD_DIR/install.log +# if [ "$?" -ne "0" ]; then +# echo "SORRY, AN ERROR OCCURED DURING INSTALLATION PROCESS" +# cat $TRAVIS_BUILD_DIR/install.log +# exit 1 +# fi +# cd ../.. +# rm $INSTALL_FORCED_FILE +# #cat $TRAVIS_BUILD_DIR/install.log +# set +e +# echo - - | - echo "Setting up database to test migrations" - if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then - echo "MySQL" - mysql -e 'DROP DATABASE IF EXISTS travis;' - mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' - mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' - mysql -e 'FLUSH PRIVILEGES;' - mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql - fi - if [ "$DB" = 'postgresql' ]; then - #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql - #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr - echo pgloader mysql://root@127.0.0.1/travis postgresql:///travis - pgloader mysql://root@127.0.0.1/travis postgresql:///travis - echo 'ALTER SEQUENCE llx_accountingaccount_rowid_seq RENAME TO llx_accounting_account_rowid_seq' | psql travis - echo 'ALTER SEQUENCE llx_accounting_account_rowid_seq RESTART WITH 1000001;' | psql travis - #echo 'select * from INFORMATION_SCHEMA.COLUMNS where table_name = 'llx_accountingaccount' | psql travis - #echo 'select * from information_schema.table_constraints;' | psql travis - #echo 'ALTER TABLE "llx_accounting_account" DROP CONSTRAINT "idx_16390_primary"' | psql travis - fi - echo +- | + echo "Setting up database to test migrations" + if [ "$DB" = 'mysql' ] || [ "$DB" = 'mariadb' ] || [ "$DB" = 'postgresql' ]; then + echo "MySQL" + mysql -e 'DROP DATABASE IF EXISTS travis;' + mysql -e 'CREATE DATABASE IF NOT EXISTS travis;' + mysql -e 'GRANT ALL PRIVILEGES ON travis.* TO travis@127.0.0.1;' + mysql -e 'FLUSH PRIVILEGES;' + mysql -D travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + fi + if [ "$DB" = 'postgresql' ]; then + #pgsql travis < dev/initdemo/mysqldump_dolibarr_3.5.0.sql + #pgloader mysql://root:pass@127.0.0.1/base postgresql://dolibarrowner@127.0.0.1/dolibarr + echo pgloader mysql://root@127.0.0.1/travis postgresql:///travis + pgloader mysql://root@127.0.0.1/travis postgresql:///travis + echo 'ALTER SEQUENCE llx_accountingaccount_rowid_seq RENAME TO llx_accounting_account_rowid_seq' | psql travis + echo 'ALTER SEQUENCE llx_accounting_account_rowid_seq RESTART WITH 1000001;' | psql travis + #echo 'select * from INFORMATION_SCHEMA.COLUMNS where table_name = 'llx_accountingaccount' | psql travis + #echo 'select * from information_schema.table_constraints;' | psql travis + #echo 'ALTER TABLE "llx_accounting_account" DROP CONSTRAINT "idx_16390_primary"' | psql travis + fi + echo - - | - echo "Upgrading Dolibarr" - # Ensure we catch errors. Set this to +e if you want to go to the end to see log files. - set +e - cd htdocs/install - php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log - php upgrade2.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-2.log - php step5.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-3.log - php upgrade.php 3.6.0 3.7.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade360370.log - php upgrade2.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-2.log - php step5.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-3.log - php upgrade.php 3.7.0 3.8.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade370380.log - php upgrade2.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-2.log - php step5.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-3.log - php upgrade.php 3.8.0 3.9.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade380390.log - php upgrade2.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-2.log - php step5.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-3.log - php upgrade.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400.log - php upgrade2.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-2.log - php step5.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-3.log - php upgrade.php 4.0.0 5.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade400500.log - php upgrade2.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-2.log - php step5.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-3.log - php upgrade.php 5.0.0 6.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade500600.log - php upgrade2.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-2.log - php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log - php upgrade.php 6.0.0 7.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade600700.log - php upgrade2.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-2.log - php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log - php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log - php upgrade2.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-2.log - php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log - php upgrade.php 8.0.0 9.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade800900.log - php upgrade2.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-2.log - php step5.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-3.log - php upgrade.php 9.0.0 10.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade9001000.log - php upgrade2.php 9.0.0 10.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-2.log - php step5.php 9.0.0 10.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-3.log - php upgrade.php 10.0.0 11.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade10001100.log - php upgrade2.php 10.0.0 11.0.0 > $TRAVIS_BUILD_DIR/upgrade10001100-2.log - php step5.php 10.0.0 11.0.0 > $TRAVIS_BUILD_DIR/upgrade10001100-3.log - php upgrade.php 11.0.0 12.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade11001200.log - php upgrade2.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-2.log - php step5.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-3.log - php upgrade.php 12.0.0 13.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade12001300.log - php upgrade2.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-2.log - php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log +- | + echo "Upgrading Dolibarr" + # Ensure we catch errors. Set this to +e if you want to go to the end to see log files. + set +e + cd htdocs/install + php upgrade.php 3.5.0 3.6.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade350360.log + php upgrade2.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-2.log + php step5.php 3.5.0 3.6.0 > $TRAVIS_BUILD_DIR/upgrade350360-3.log + php upgrade.php 3.6.0 3.7.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade360370.log + php upgrade2.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-2.log + php step5.php 3.6.0 3.7.0 > $TRAVIS_BUILD_DIR/upgrade360370-3.log + php upgrade.php 3.7.0 3.8.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade370380.log + php upgrade2.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-2.log + php step5.php 3.7.0 3.8.0 > $TRAVIS_BUILD_DIR/upgrade370380-3.log + php upgrade.php 3.8.0 3.9.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade380390.log + php upgrade2.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-2.log + php step5.php 3.8.0 3.9.0 > $TRAVIS_BUILD_DIR/upgrade380390-3.log + php upgrade.php 3.9.0 4.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade390400.log + php upgrade2.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-2.log + php step5.php 3.9.0 4.0.0 > $TRAVIS_BUILD_DIR/upgrade390400-3.log + php upgrade.php 4.0.0 5.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade400500.log + php upgrade2.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-2.log + php step5.php 4.0.0 5.0.0 > $TRAVIS_BUILD_DIR/upgrade400500-3.log + php upgrade.php 5.0.0 6.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade500600.log + php upgrade2.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-2.log + php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log + php upgrade.php 6.0.0 7.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade600700.log + php upgrade2.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-2.log + php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log + php upgrade.php 7.0.0 8.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade700800.log + php upgrade2.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-2.log + php step5.php 7.0.0 8.0.0 > $TRAVIS_BUILD_DIR/upgrade700800-3.log + php upgrade.php 8.0.0 9.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade800900.log + php upgrade2.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-2.log + php step5.php 8.0.0 9.0.0 > $TRAVIS_BUILD_DIR/upgrade800900-3.log + php upgrade.php 9.0.0 10.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade9001000.log + php upgrade2.php 9.0.0 10.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-2.log + php step5.php 9.0.0 10.0.0 > $TRAVIS_BUILD_DIR/upgrade9001000-3.log + php upgrade.php 10.0.0 11.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade10001100.log + php upgrade2.php 10.0.0 11.0.0 > $TRAVIS_BUILD_DIR/upgrade10001100-2.log + php step5.php 10.0.0 11.0.0 > $TRAVIS_BUILD_DIR/upgrade10001100-3.log + php upgrade.php 11.0.0 12.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade11001200.log + php upgrade2.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-2.log + php step5.php 11.0.0 12.0.0 > $TRAVIS_BUILD_DIR/upgrade11001200-3.log + php upgrade.php 12.0.0 13.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade12001300.log + php upgrade2.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-2.log + php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log - # Enable modules not enabled into original dump - php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING > $TRAVIS_BUILD_DIR/enablemodule.log - echo $? - cd - - set +e - echo - #cat /tmp/dolibarr_install.log - cat $TRAVIS_BUILD_DIR/enablemodule.log + # Enable modules not enabled into original dump + php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKETSUP,MAIN_MODULE_ACCOUNTING > $TRAVIS_BUILD_DIR/enablemodule.log + echo $? + cd - + set +e + echo + #cat /tmp/dolibarr_install.log + cat $TRAVIS_BUILD_DIR/enablemodule.log - - | - echo "Unit testing" - # Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file. - set -e - phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php - phpunitresult=$? - echo "Phpunit return code = $phpunitresult" - set +e +- | + echo "Unit testing" + # Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file. + set -e + phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php + phpunitresult=$? + echo "Phpunit return code = $phpunitresult" + set +e after_script: - - | - echo "After script - Output lines of dolibarr.log" - ls $TRAVIS_BUILD_DIR/documents - #cat $TRAVIS_BUILD_DIR/documents/dolibarr.log - sudo tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log +- | + echo "After script - Output lines of dolibarr.log" + ls $TRAVIS_BUILD_DIR/documents + #cat $TRAVIS_BUILD_DIR/documents/dolibarr.log + sudo tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log after_success: - - | - echo Success +- | + echo Success after_failure: - - | - echo Failure detected, so we show samples of log to help diagnose - # This part of code is executed only if previous command that fails are enclosed with set +e - # Upgrade log files - for ficlog in `ls $TRAVIS_BUILD_DIR/*.log` - do - echo "Debugging informations for file $ficlog" - #cat $ficlog - done - # Apache log file - echo "Debugging informations for file apache error.log" - sudo cat /var/log/apache2/travis_error_log - if [ "$DEBUG" = true ]; then - # Dolibarr log file - echo "Debugging informations for file dolibarr.log (latest 50 lines)" - tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log - # Database log file - echo "Debugging informations for file mysql error.log" - sudo tail -n 50 /var/log/mysql/error.log - # TODO: PostgreSQL log file - echo - fi +- | + echo Failure detected, so we show samples of log to help diagnose + # This part of code is executed only if previous command that fails are enclosed with set +e + # Upgrade log files + for ficlog in `ls $TRAVIS_BUILD_DIR/*.log` + do + echo "Debugging informations for file $ficlog" + #cat $ficlog + done + # Apache log file + echo "Debugging informations for file apache error.log" + sudo cat /var/log/apache2/travis_error_log + if [ "$DEBUG" = true ]; then + # Dolibarr log file + echo "Debugging informations for file dolibarr.log (latest 50 lines)" + tail -n 50 $TRAVIS_BUILD_DIR/documents/dolibarr.log + # Database log file + echo "Debugging informations for file mysql error.log" + sudo tail -n 50 /var/log/mysql/error.log + # TODO: PostgreSQL log file + echo + fi diff --git a/test/README.md b/test/README.md new file mode 100644 index 00000000000..b3d550392c4 --- /dev/null +++ b/test/README.md @@ -0,0 +1,56 @@ +#Run End-to-End Tests + +###Run Selenium + +Selenium has been used for automating the browser. + +We can run selenium by two ways: + +* Usually, for running tests using selenium we download `selenium standalone server JAR file` and `chrome driver` and start selenium server with a command which usually looks like: + + `java -jar selenium-server-standalone-.jar -port ` + +* Run selenium in docker with + + `docker run -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug` + + OR + + `docker run -d --network="host" -v /dev/shm:/dev/shm selenium/standalone-chrome-debug` + + OR + + `docker run -d --network host -v /dev/shm:/dev/shm selenium/standalone-chrome-debug` + +###Run the acceptance tests + + * In `nightwatch.conf.js` file inside the root directory of the project and inside the configuration file following environment variable has been specified. We can change the default values according to our local configuration. + + ``` + const admin_username = process.env.ADMIN_USERNAME || 'dolibarr'; + + const admin_password = process.env.ADMIN_PASSWORD || 'password'; + + const launch_url = process.env.LAUNCH_URL || 'http://localhost/dolibarr/htdocs/'; + ``` + * You can run test using following commands + + `yarn run test:e2e test/acceptance/features/` + + For example: `yarn run test:e2e test/acceptance/features/addUsers.feature` + + OR + + `LAUNCH_URL='' ADMIN_USERNAME='' ADMIN_PASSWORD='' yarn run test:e2e test/acceptance/features/` + + The full script to run the acceptance tests is specified in `scripts` object of `package.json` file inside the project's root directory as : + + `"test:e2e": "node_modules/cucumber/bin/cucumber-js --require test/acceptance/index.js --require test/acceptance/stepDefinitions -f node_modules/cucumber-pretty"` + + After you run the above command you can see the test running. For that : + + * open `Remmina` (Remmina is a Remote Desktop Client and comes installed with Ubuntu) + + * choose `VNC` and enter `localhost` on the address bar + + * enter `secret` as the password