Skip to content

Commit

Permalink
Merge branch 'develop' into FIx-ohcnetwork#7244
Browse files Browse the repository at this point in the history
  • Loading branch information
AshrafMd-1 authored Mar 8, 2024
2 parents fb885a4 + 83dc92f commit 8111318
Show file tree
Hide file tree
Showing 28 changed files with 9,482 additions and 5,857 deletions.
46 changes: 45 additions & 1 deletion .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,25 @@ jobs:
max_attempts: 5
command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000
on_retry_command: sleep 5

- name: Determine PR Origin
id: pr_origin
run: echo "::set-output name=is_forked::$( echo ${{ github.event.pull_request.head.repo.fork }})"

- name: Install dependencies 📦
run: npm install

- name: Build & Compile rescript files ⚙️
run: "npm run build"

- name: Cypress run 🥬
- name: Install Specific Chrome Version
run: |
sudo apt-get install -y wget
sudo wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt-get install ./google-chrome-stable_current_amd64.deb
- name: Cypress run for Non-Forked PRs 🥬
if: steps.pr_origin.outputs.is_forked == 'false'
uses: cypress-io/github-action@v5
with:
env: SKIP_PREFLIGHT_CHECK=true
Expand All @@ -60,6 +71,7 @@ jobs:
browser: chrome
record: true
parallel: true
group: "UI-Chrome"
env:
CARE_API: http://localhost:9000
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
Expand All @@ -68,9 +80,41 @@ jobs:
COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}}
COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}}

- name: Cypress run for Forked PRs 🥬
if: steps.pr_origin.outputs.is_forked == 'true'
uses: cypress-io/github-action@v5
with:
env: SKIP_PREFLIGHT_CHECK=true
install: false
start: "npx vite preview --host"
wait-on: "http://localhost:4000"
wait-on-timeout: 300
browser: chrome
record: true
parallel: true
group: "UI-Chrome"
env:
CYPRESS_SPLIT_TESTS: "true"
CARE_API: http://localhost:9000
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: --max_old_space_size=4096
COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}}
COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}}
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}

- name: Upload cypress screenshots on failure 📸
uses: actions/upload-artifact@v3
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots

- name: Upload cypress videos 📹
uses: actions/upload-artifact@v3
if: steps.pr_origin.outputs.is_forked == 'true'
with:
name: cypress-videos
path: cypress/videos

6 changes: 6 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from "cypress";
import fs from "fs";
import cypressSplit from "cypress-split";

export default defineConfig({
projectId: "wf7d2m",
Expand All @@ -19,6 +20,11 @@ export default defineConfig({
return null;
},
});

if (process.env.CYPRESS_SPLIT_TESTS === "true") {
cypressSplit(on, config);
}

return config;
},
baseUrl: "http://localhost:4000",
Expand Down
16 changes: 14 additions & 2 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
// FacilityCreation
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
import {
cy,
describe,
before,
beforeEach,
it,
afterEach,
expect,
} from "local-cypress";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import LoginPage from "../../pageobject/Login/LoginPage";
import FacilityHome from "../../pageobject/Facility/FacilityHome";
Expand Down Expand Up @@ -38,6 +46,7 @@ describe("Facility Creation", () => {
const initialTriageValue = "60";
const modifiedTriageValue = "50";
const facilityErrorMessage = [
"Required",
"Required",
"Invalid Pincode",
"Required",
Expand Down Expand Up @@ -115,6 +124,7 @@ describe("Facility Creation", () => {
facilityPage.submitForm();
userCreationPage.verifyErrorMessages(facilityErrorMessage);
facilityPage.fillFacilityName(facilityName);
facilityPage.clickUpdateFacilityType("Primary Health Centres");
facilityPage.clickfacilityfeatureoption();
facilityFeature.forEach((featureText) => {
cy.get("[role='option']").contains(featureText).click();
Expand Down Expand Up @@ -202,6 +212,7 @@ describe("Facility Creation", () => {
it("Create a new facility with single bed and doctor capacity", () => {
facilityPage.visitCreateFacilityPage();
facilityPage.fillFacilityName(facilityName);
facilityPage.clickUpdateFacilityType("Primary Health Centres");
facilityPage.fillPincode("682001");
facilityPage.selectStateOnPincode("Kerala");
facilityPage.selectDistrictOnPincode("Ernakulam");
Expand Down Expand Up @@ -241,6 +252,7 @@ describe("Facility Creation", () => {
it("Create a new facility with no bed and doctor capacity", () => {
facilityPage.visitCreateFacilityPage();
facilityPage.fillFacilityName(facilityName);
facilityPage.clickUpdateFacilityType("Primary Health Centres");
facilityPage.fillPincode("682001");
facilityPage.selectStateOnPincode("Kerala");
facilityPage.selectDistrictOnPincode("Ernakulam");
Expand Down Expand Up @@ -279,7 +291,7 @@ describe("Facility Creation", () => {
facilityPage.visitUpdateFacilityPage(facilityUrl1);
facilityPage.clickManageFacilityDropdown();
facilityPage.clickUpdateFacilityOption();
facilityPage.clickUpdateFacilityType("Govt Hospital");
facilityPage.clickUpdateFacilityType("Primary Health Centres");
facilityPage.fillAddress(facilityUpdateAddress);
facilityPage.fillOxygenCapacity(oxygenCapacity);
facilityPage.fillExpectedOxygenRequirement(oxygenExpected);
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/patient_spec/patient_consultation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("Patient Consultation in multiple combination", () => {
const patientWeight = "70";
const patientHeight = "170";
const medicineOne = "DOLO";
const patientIpNumber = "192.168";
const patientIpNumber = Math.random().toString(36).substring(7);

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand All @@ -59,7 +59,7 @@ describe("Patient Consultation in multiple combination", () => {
patientConsultationPage.selectConsultationStatus(
"Outpatient/Emergency Room"
);
patientConsultationPage.selectSymptoms("ASYMPTOMATIC");
cy.clickAndSelectOption("#symptoms", "ASYMPTOMATIC");
patientConsultationPage.typePatientIllnessHistory(patientIllnessHistory);
patientConsultationPage.typePatientExaminationHistory(
patientExaminationHistory
Expand Down Expand Up @@ -175,7 +175,7 @@ describe("Patient Consultation in multiple combination", () => {
"Outpatient/Emergency Room"
);
// Asymptomatic
patientConsultationPage.selectSymptoms("ASYMPTOMATIC");
cy.clickAndSelectOption("#symptoms", "ASYMPTOMATIC");
// CRITICAL category
patientConsultationPage.selectPatientCategory("Critical");
patientConsultationPage.selectPatientSuggestion("Declare Death");
Expand Down Expand Up @@ -233,7 +233,7 @@ describe("Patient Consultation in multiple combination", () => {
);
patientConsultationPage.selectPatientWard("Dummy Location 1");
// Asymptomatic
patientConsultationPage.selectSymptoms("ASYMPTOMATIC");
cy.clickAndSelectOption("#symptoms", "ASYMPTOMATIC");
// Abnormal category
patientConsultationPage.selectPatientCategory("Abnormal");
patientConsultationPage.selectPatientSuggestion("Domiciliary Care");
Expand Down
12 changes: 3 additions & 9 deletions cypress/e2e/users_spec/user_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ describe("Manage User", () => {
userPage.typeInSearchInput(usernameforworkinghour);
userPage.checkUsernameText(usernameforworkinghour);
manageUserPage.clicklinkedskillbutton();
manageUserPage.typeSkill(linkedskill);
manageUserPage.selectFacilityFromDropdown(linkedskill);
manageUserPage.selectSkillFromDropdown(linkedskill);
manageUserPage.clickAddSkillButton();
manageUserPage.clickCloseSlideOver();
cy.wait(5000);
Expand All @@ -60,17 +59,15 @@ describe("Manage User", () => {
userPage.typeInSearchInput(usernametolinkskill);
userPage.checkUsernameText(usernametolinkskill);
manageUserPage.clicklinkedskillbutton();
manageUserPage.typeSkill(linkedskill);
manageUserPage.selectFacilityFromDropdown(linkedskill);
manageUserPage.selectSkillFromDropdown(linkedskill);
manageUserPage.clickAddSkillButton();
manageUserPage.clickCloseSlideOver();
cy.wait(5000); // temporary hack to fix the failure
manageUserPage.clicklinkedskillbutton();
manageUserPage.assertSkillInAddedUserSkills(linkedskill);
manageUserPage.clickUnlinkSkill();
manageUserPage.clickSubmit();
manageUserPage.typeSkill(linkedskill);
manageUserPage.selectFacilityFromDropdown(linkedskill);
manageUserPage.selectSkillFromDropdown(linkedskill);
manageUserPage.clickAddSkillButton();
manageUserPage.clickCloseSlideOver();
// verifying the doctor connect
Expand Down Expand Up @@ -105,7 +102,6 @@ describe("Manage User", () => {
manageUserPage.assertHomeFacility("No Home Facility");
// Link a new facility and ensure it is under linked facility - doctor username (1)
manageUserPage.clickFacilitiesTab();
manageUserPage.typeFacilityName(facilitytolinkusername);
manageUserPage.selectFacilityFromDropdown(facilitytolinkusername);
manageUserPage.clickLinkFacility();
manageUserPage.assertLinkedFacility(facilitytolinkusername);
Expand All @@ -117,7 +113,6 @@ describe("Manage User", () => {
userPage.typeInSearchInput(usernametolinkfacilitydoc2);
userPage.checkUsernameText(usernametolinkfacilitydoc2);
manageUserPage.clickFacilitiesTab();
manageUserPage.typeFacilityName(facilitytolinkusername);
manageUserPage.selectFacilityFromDropdown(facilitytolinkusername);
manageUserPage.clickLinkFacility();
manageUserPage.clickHomeFacilityIcon();
Expand All @@ -134,7 +129,6 @@ describe("Manage User", () => {
userPage.typeInSearchInput(usernametolinkfacilitydoc3);
userPage.checkUsernameText(usernametolinkfacilitydoc3);
manageUserPage.clickFacilitiesTab();
manageUserPage.typeFacilityName(facilitytolinkusername);
manageUserPage.selectFacilityFromDropdown(facilitytolinkusername);
manageUserPage.clickLinkFacility();
manageUserPage.clickUnlinkFacilityButton();
Expand Down
3 changes: 1 addition & 2 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ class FacilityPage {
}

selectBedType(bedType: string) {
cy.get("div#bed-type button").click();
cy.get("[role='option']").contains(bedType).click();
cy.clickAndSelectOption("div#bed-type button", bedType);
}

isVisibleselectBedType() {
Expand Down
14 changes: 5 additions & 9 deletions cypress/pageobject/Users/ManageUserPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ export class ManageUserPage {
cy.get("#facilities").click();
}

typeFacilityName(facilityName) {
cy.get("input[name='facility']").click().type(facilityName);
selectFacilityFromDropdown(facilityName) {
cy.searchAndSelectOption("input[name='facility']", facilityName);
}

selectFacilityFromDropdown(facilityName) {
cy.get("[role='option']").contains(facilityName).click();
selectSkillFromDropdown(skill) {
cy.searchAndSelectOption("input[name='skill']", skill);
}

clickLinkFacility() {
Expand All @@ -36,7 +36,7 @@ export class ManageUserPage {
}

assertFacilityNotInDropdown(facilityName) {
this.typeFacilityName(facilityName);
cy.get("input[name='facility']").click().type(facilityName);
cy.get("[role='option']").should("not.exist");
}

Expand Down Expand Up @@ -129,10 +129,6 @@ export class ManageUserPage {
.should("have.length", 1);
}

typeSkill(skillName) {
cy.get("#select-skill").click().type(skillName);
}

clickDoctorConnectButton() {
cy.get("#doctor-connect-patient-button").click();
}
Expand Down
Loading

0 comments on commit 8111318

Please sign in to comment.