travis setup
Co-authored-by: Yamuna Adhikari <adhikariamuna4444@gmail.com>
This commit is contained in:
parent
1ef46d082c
commit
f343fbb55e
33
.travis.yml
33
.travis.yml
@ -8,13 +8,36 @@ 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
|
||||
- docker
|
||||
|
||||
addons:
|
||||
# Force postgresql to 9.4 (the oldest availablable on xenial)
|
||||
@ -32,14 +55,6 @@ addons:
|
||||
# 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:
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user