Skip to content

Commit

Permalink
ci: enable custom runs (#70)
Browse files Browse the repository at this point in the history
* feat: extract user variable

* fix: using # in aliases to avoid file deletion

* fix: added preinstall step

* fix: package name

* fix: jira service

* lodash replaced with deepmerge

* import replaced by const

* remove _

* test

* wdio

* revert

* remove local service

* fix

* define jiraService

* change selector

* fix

* fix

* removes log line

* fix

* test

* tesr

* wdio.conf

* test

* test

* test

* test

* fix

* test

* define jira servrice

* test

te

* test

* test

* isEnabled

* fix

* clean up
  • Loading branch information
vilkg authored Mar 24, 2021
1 parent 7b7d849 commit 89cbc5f
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 342 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@wdio/spec-reporter": "^6.8.1",
"@wdio/sync": "^6.10.4",
"chromedriver": "^86.0.0",
"deepmerge": "^4.2.2",
"moment": "^2.27.0",
"wdio-applitools-cucumber-service": "^1.0.6",
"wdio-chromedriver-service": "^6.0.4",
Expand All @@ -33,11 +34,12 @@
"request": "^2.88.0"
},
"_moduleAliases": {
"@support": "./support",
"@page_objects": "./page_objects"
"#support": "./support",
"#page_objects": "./page_objects"
},
"_moduleAliasIgnoreWarning": true,
"scripts": {
"preinstall": "command -v link-module-alias && link-module-alias clean || true",
"postinstall": "link-module-alias",
"lint": "./node_modules/eslint/bin/eslint.js . --fix",
"browserstack": "./node_modules/.bin/wdio wdio.remote.conf.js",
Expand Down
2 changes: 1 addition & 1 deletion page_objects/Dashboard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Page from './Page';
import { waitForElementToExist, waitForVisible } from '@support/wait';
import { waitForElementToExist, waitForVisible } from '#support/wait';

class Dashboard extends Page {
get headerDiv () { return browser.$('[data-test="dashboards-bar"]'); }
Expand Down
2 changes: 1 addition & 1 deletion page_objects/Login.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Page from './Page';
import { waitForElementToExist, waitForVisible } from '@support/wait';
import { waitForElementToExist, waitForVisible } from '#support/wait';

class Login extends Page {
get loginForm () { return browser.$('#loginForm'); }
Expand Down
2 changes: 1 addition & 1 deletion page_objects/capture/CaptureHeaderBar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Page from '../Page'
import { waitForWindowToLoad } from '@support/wait'
import { waitForWindowToLoad } from '#support/wait'

class CaptureHeaderBar extends Page {
get newEventButton() {
Expand Down
4 changes: 2 additions & 2 deletions page_objects/capture/CaptureIndexPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Page from '../Page'
import { waitForWindowToLoad, waitForElementToExist } from '@support/wait'
import { waitForWindowToLoad, waitForElementToExist } from '#support/wait'

class CaptureIndexPage extends Page {
get orgUnits() {
Expand Down Expand Up @@ -32,7 +32,7 @@ class CaptureIndexPage extends Page {
}

selectProgram(name) {
waitForElementToExist('#program-selector .Select-placeholder');
waitForElementToExist(browser.$('#program-selector .Select-placeholder'));
browser.$('#program-selector .Select-placeholder').click();
browser.$('.Select-menu-outer').$('//*[contains(text(), "' + name + '")]').click();

Expand Down
2 changes: 1 addition & 1 deletion page_objects/capture/CaptureNewEventForm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Page from '../Page'
import { waitForWindowToLoad, waitForVisible, waitForClickable } from '@support/wait'
import { waitForWindowToLoad, waitForVisible, waitForClickable } from '#support/wait'
import CaptureCommentsSection from './CaptureCommentsSection';
var moment = require('moment');

Expand Down
2 changes: 1 addition & 1 deletion page_objects/capture/CaptureViewEventPage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Page from '../Page'
import { waitForWindowToLoad} from '@support/wait';
import { waitForWindowToLoad} from '#support/wait';
class CaptureViewEventPage extends Page {
open(eventId) {
super.open('dhis-web-capture/#/viewEvent?viewEventId=' + eventId);
Expand Down
2 changes: 1 addition & 1 deletion services/wdio-jira-integration-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class WdioJiraService {
}

_configure() {
if (!this.options.isEnabled) {
if (!this.options.isEnabled || this.options.isEnabled == 'false') {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion step_definitions/Then.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Then } from 'cucumber';
import { checkTitle } from '@support/check';
import { checkTitle } from '#support/check';

Then(
/^I expect that the title is( not)* "([^"]*)?"$/,
Expand Down
6 changes: 3 additions & 3 deletions step_definitions/dhis2/apps/analyticsApps.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getFilteredConsoleLog, getConsoleLog, saveScreenshot } from '@support/action';
import { waitForVisible, waitForWindowToLoad } from '@support/wait';
import { getFilteredConsoleLog, getConsoleLog, saveScreenshot } from '#support/action';
import { waitForVisible, waitForWindowToLoad } from '#support/wait';
import { Given, Then } from 'cucumber';
import { reportStep } from '@support/reporting'
import { reportStep } from '#support/reporting'

let listOfFavorites = [];
let appName = '';
Expand Down
6 changes: 3 additions & 3 deletions step_definitions/dhis2/apps/apps.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getConsoleLog, getFilteredConsoleLog, saveScreenshot } from '@support/action';
import { waitForVisible, waitForWindowToLoad } from '@support/wait';
import { getConsoleLog, getFilteredConsoleLog, saveScreenshot } from '#support/action';
import { waitForVisible, waitForWindowToLoad } from '#support/wait';
import { Given, Then } from 'cucumber';
import { reportStep } from '@support/reporting'
import { reportStep } from '#support/reporting'

const listOfApps = ['dhis-web-dataentry/index.action', 'dhis-web-approval/index.action'];
Given(/^I have a list of installed core apps$/, () => {
Expand Down
4 changes: 2 additions & 2 deletions step_definitions/dhis2/capture/capture.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Given, Then, When } from 'cucumber';
import { captureHeaderBar, captureIndexPage, captureNewEventForm, captureViewEventPage, captureCommentsSection } from '@page_objects/capture';
import { waitForWindowToLoad } from '@support/wait';
import { captureHeaderBar, captureIndexPage, captureNewEventForm, captureViewEventPage, captureCommentsSection } from '#page_objects/capture';
import { waitForWindowToLoad } from '#support/wait';

Given(/^I open the capture app/, () => {
captureIndexPage.open();
Expand Down
10 changes: 5 additions & 5 deletions step_definitions/dhis2/dashboard/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { dashboardPage } from '@page_objects/Dashboard';
import { isVisible } from '@support/check';
import { getConsoleLog, getFilteredConsoleLog, saveScreenshot } from '@support/action';
import { waitForElementToExist, waitForWindowToLoad } from '@support/wait';
import { dashboardPage } from '#page_objects/Dashboard';
import { isVisible } from '#support/check';
import { getConsoleLog, getFilteredConsoleLog, saveScreenshot } from '#support/action';
import { waitForElementToExist, waitForWindowToLoad } from '#support/wait';
import { Then } from 'cucumber';
import { reportStep } from '@support/reporting'
import { reportStep } from '#support/reporting'

Then(
/^I expect that header is visible$/,
Expand Down
47 changes: 24 additions & 23 deletions step_definitions/dhis2/given.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
import { Given } from 'cucumber';

import { isVisible} from '@support/check';
import { waitForVisible } from '@support/wait';
import { isVisible} from '#support/check';
import { waitForVisible } from '#support/wait';

import { login } from '@support/action';
import { dashboardPage } from '@page_objects/Dashboard';
import { login } from '#support/action';
import { dashboardPage } from '#page_objects/Dashboard';

Given(
/^I am logged in$/,
() => {
// login as standard user
login('system', 'System123');
waitForVisible(dashboardPage.mainPageDiv);
isVisible(dashboardPage.mainPageDiv);
}
);
Given(
/^I am logged in$/,
() => {
// login as standard user
login(browser.config.superUser, browser.config.superUserPassword);
waitForVisible(dashboardPage.mainPageDiv);
isVisible(dashboardPage.mainPageDiv);
}
);

Given(
/^I am authenticated$/,
() => {
login('system', 'System123');
Given(
/^I am authenticated$/,
() => {
login(browser.config.superUser, browser.config.superUserPassword);

browser.waitUntil(() => {
const url = browser.getUrl();
return url.indexOf('dhis-web') > -1 && url.indexOf('#') > -1 && url.indexOf('login.action') === -1;
}, 10000);
}
);

browser.waitUntil(() => {
const url = browser.getUrl();
return url.indexOf('dhis-web') > -1 && url.indexOf('#') > -1 && url.indexOf('login.action') === -1;
}, 10000);
}
);
10 changes: 5 additions & 5 deletions step_definitions/dhis2/then.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Then } from 'cucumber';
import { isVisible} from '@support/check';
import { waitForElementToExist } from '@support/wait';
import { logout } from '@support/action';
import { loginPage } from '@page_objects/Login';
import { dashboardPage } from '@page_objects/Dashboard';
import { isVisible} from '#support/check';
import { waitForElementToExist } from '#support/wait';
import { logout } from '#support/action';
import { loginPage } from '#page_objects/Login';
import { dashboardPage } from '#page_objects/Dashboard';

Then(
/^I should( not)? be authenticated$/,
Expand Down
2 changes: 1 addition & 1 deletion step_definitions/dhis2/when.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { login} from '@support/action';
import { login} from '#support/action';
import { When } from 'cucumber';

When(
Expand Down
2 changes: 1 addition & 1 deletion support/action/dhis2/login.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { loginPage } from '@page_objects/Login';
import { loginPage } from '#page_objects/Login';

module.exports = (username, password) => {
loginPage.doLogin(username, password);
Expand Down
2 changes: 1 addition & 1 deletion support/reporting/reportStep.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { saveScreenshot } from '@support/action';
import { saveScreenshot } from '#support/action';
import fs from 'fs';

module.exports = (stepName, expectedResult, status, allureContent) => {
Expand Down
1 change: 0 additions & 1 deletion support/wait/waitForWindowToLoad.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module.exports = () => {

if (newSource === source) {
if (retries <= 0) {
console.log('finished waiting')
return true;
}
retries--;
Expand Down
13 changes: 12 additions & 1 deletion wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const drivers = {
chrome: { version: '88.0.4324.96' }, // https://chromedriver.chromium.org/
}
exports.config = {
superUser: process.env.SUPER_USER || 'system',
superUserPassword: process.env.SUPER_USER_PASSWORD || 'System123',
//
// ====================
// Runner Configuration
Expand Down Expand Up @@ -94,7 +96,7 @@ exports.config = {

services: [
[ jiraService, {
isEnabled: true,
isEnabled: process.env.JIRA_ENABLED || true,
instanceUrl: "https://jira.dhis2.org",
username: process.env.JIRA_USERNAME,
password: process.env.JIRA_PASSWORD,
Expand Down Expand Up @@ -285,6 +287,15 @@ exports.config = {
// Suites
// ======
suites: {
smoke: [
'./features/apps/dataVisualiser.feature',
'./features/apps/eventVisualiser.feature',
'./features/apps/eventsReport.feature',
'./features/apps/maps.feature',
'./features/apps/pivotTables.feature',
'./features/apps/apps.feature',
'./features/dashboardPage.feature'
],
login: [
'./features/loginPage.feature'
],
Expand Down
Loading

0 comments on commit 89cbc5f

Please sign in to comment.