Skip to content

Commit

Permalink
chore: initial setup of apdex automation in cht-core (#9037)
Browse files Browse the repository at this point in the history
Co-authored-by: Rafa <[email protected]>
Co-authored-by: Jennifer Q <[email protected]>
  • Loading branch information
3 people authored Aug 30, 2024
1 parent 07b6c11 commit a211a7c
Show file tree
Hide file tree
Showing 15 changed files with 9,250 additions and 1,353 deletions.
9,152 changes: 7,799 additions & 1,353 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"unit-cht-deploy": "cd scripts/deploy && npm test",
"wdio-default-mobile-local": "export VERSION=$(node ./scripts/build/get-version.js) && ./scripts/build/build-service-images.sh && wdio run ./tests/e2e/default-mobile/wdio.conf.js --suite=all",
"wdio-local": "export VERSION=$(node ./scripts/build/get-version.js) && ./scripts/build/build-service-images.sh && wdio run ./tests/e2e/default/wdio.conf.js",
"apdex-test": "wdio run ./tests/performance/apdex-score/wdio.conf.js",
"-- CI SCRIPTS ": "-----------------------------------------------------------------------------------------------",
"build": "./scripts/build/build-ci.sh",
"ci-compile": "node scripts/ci/check-versions.js && node scripts/build/cli npmCiModules && npm run lint && npm run unit-nginx && npm run unit-haproxy && npm run unit-haproxy-healthcheck && npm run unit-cht-deploy && npm run build && npm run integration-api && npm run unit",
Expand Down Expand Up @@ -87,12 +88,14 @@
"@typescript-eslint/eslint-plugin": "7.5",
"@typescript-eslint/parser": "7.5",
"@wdio/allure-reporter": "^8.34.0",
"@wdio/appium-service": "^8.36.1",
"@wdio/cli": "^8.35.1",
"@wdio/devtools-service": "^8.35.1",
"@wdio/local-runner": "^8.35.1",
"@wdio/mocha-framework": "^8.35.0",
"@wdio/spec-reporter": "^8.32.4",
"allure-commandline": "^2.24.0",
"appium-uiautomator2-driver": "^3.0.0",
"browserify": "^17.0.0",
"browserify-ngannotate": "^2.0.0",
"chai": "^4.3.8",
Expand Down
41 changes: 41 additions & 0 deletions tests/page-objects/apdex/contacts.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const Page = require('@page-objects/apdex/page');
const CONTACT_LIST = 'contactList';
const CHW_AREA = 'chwArea';
const HOUSEHOLD = 'household';
const PATIENT = 'patient';
const PATIENT_REPORT = 'patientReport';
const PATIENT_CONTACT = 'patientContact';

class ContactsPage extends Page {

async loadContactList() {
await super.loadPage(CONTACT_LIST);
}

async loadChwArea() {
await super.loadPage(CHW_AREA);
}

async loadHousehold() {
await super.loadPage(HOUSEHOLD);
}

async loadPatient() {
await super.loadPage(PATIENT);
}

async searchContact() {
await super.searchPage(CONTACT_LIST);
}

async submitPatientReport() {
await super.loadForm(PATIENT_REPORT);
}

async createPatient() {
await super.loadForm(PATIENT_CONTACT);
}

}

module.exports = new ContactsPage();
36 changes: 36 additions & 0 deletions tests/page-objects/apdex/load.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const Page = require('@page-objects/apdex/page');
const CUSTOM_INSTANCE = 'Custom';

class LoadPage extends Page {

get inputInstanceUrl() {
return $('//android.widget.EditText[@resource-id="org.medicmobile.webapp.mobile:id/txtAppUrl"]');
}

get btnSave() {
return $('//android.widget.Button[@resource-id="org.medicmobile.webapp.mobile:id/btnSaveSettings"]');
}

async loadInstance() {
const isServerSettings = await super.isLinkExisting(CUSTOM_INSTANCE);
// Check if the app has opened and the custom linktext is displayed before proceeding
if (!isServerSettings) {
return;
}

await super.toggleAirplaneMode('off');
await super.clickLink(CUSTOM_INSTANCE);
await this.inputInstanceUrl.setValue(super.getSettingsProvider().getInstanceURL());
await this.btnSave.click();
}

async turnOnAirplaneMode() {
const commonElements = super.getSettingsProvider().getCommonElements();
const UI_ELEMENT = commonElements?.relaunchAppAssert || super.getLinkSelector('People');
await this.waitForDisplayedAndRetry(UI_ELEMENT);
await super.toggleAirplaneMode('on');
}

}

module.exports = new LoadPage();
29 changes: 29 additions & 0 deletions tests/page-objects/apdex/login.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const Page = require('@page-objects/apdex/page');

class LoginPage extends Page {

get inputUsername() {
return $('//android.view.View[@text="User name"]//parent::android.view.View/android.widget.EditText');
}

get inputPassword() {
return $('//*[@text="Password"]//parent::android.view.View/android.view.View/android.widget.EditText');
}

async login(userType, userRole) {
await this.inputUsername.waitForDisplayed();

const user = super.getSettingsProvider().getUser(userType, userRole);
await this.inputUsername.setValue(user.username);
await this.inputPassword.setValue(user.password);

await super.clickButton('Login');

if (super.getSettingsProvider().hasPrivacyPolicy()) {
await super.clickButton('Accept');
}
}

}

module.exports = new LoginPage();
12 changes: 12 additions & 0 deletions tests/page-objects/apdex/messages.page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const Page = require('@page-objects/apdex/page');
const MESSAGE_LIST = 'messageList';

class MessagesPage extends Page {

async loadMessageList() {
await super.loadPage(MESSAGE_LIST);
}

}

module.exports = new MessagesPage();
Loading

0 comments on commit a211a7c

Please sign in to comment.