diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 892fea40ab3..b67b01cc863 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,9 +1,6 @@ -### WHAT -copilot:summary - ## Proposed Changes -- Fixes #issue? +- Fixes #issue_number - Change 1 - Change 2 - More? @@ -18,6 +15,3 @@ copilot:summary - [ ] Prep screenshot or demo video for changelog entry, and attach it to issue. - [ ] Request for Peer Reviews - [ ] Completion of QA - -### HOW -copilot:walkthrough diff --git a/.github/workflows/cypress.yaml b/.github/workflows/cypress.yaml index f04045d0c72..001ceda68dc 100644 --- a/.github/workflows/cypress.yaml +++ b/.github/workflows/cypress.yaml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - containers: [1,2,3,4,5,6,7,8] + containers: [1, 2, 3, 4, 5, 6, 7, 8] steps: - name: Checkout 📥 uses: actions/checkout@v3 @@ -32,9 +32,9 @@ jobs: run: | cd care make docker_config_file=docker-compose.pre-built.yaml up - while docker compose exec backend bash -c "python manage.py showmigrations 2>/dev/null | cat | grep -q '\[ \]'"; do + while docker compose exec celery-beat bash -c "python manage.py showmigrations 2>/dev/null | cat | grep -q '\[ \]'"; do >&2 echo "Migrations are not yet applied - sleeping" - sleep 5 + sleep 10 done echo "Migrations are applied" cd .. @@ -43,10 +43,16 @@ jobs: run: | cd care docker compose exec backend bash -c "python manage.py load_dummy_data" + docker restart care-backend-1 cd .. - - name: Check care is up ♻ - run: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 + - name: Wait for care to be up ♻ + uses: nick-fields/retry@v2 + with: + timeout_minutes: 1 + max_attempts: 5 + command: curl -o /dev/null -s -w "%{http_code}\n" http://localhost:9000 + on_retry_command: sleep 5 - name: Install dependencies 📦 run: npm install @@ -79,4 +85,3 @@ jobs: with: name: cypress-screenshots path: cypress/screenshots - diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 3c9d6aa28cb..b90adb20138 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -35,7 +35,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Cache Docker layers - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ hashFiles('package-lock.json', 'Dockerfile') }} @@ -87,7 +87,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Cache Docker layers - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ hashFiles('package-lock.json', 'Dockerfile') }} @@ -149,7 +149,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Cache Docker layers - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ hashFiles('package-lock.json', 'Dockerfile') }} @@ -188,6 +188,9 @@ jobs: needs: build-staging name: Deploy to staging GCP cluster runs-on: ubuntu-latest + - uses: actions/setup-node@v3 + with: + node-version: '20' environment: name: Staging-GCP url: https://care-staging.ohc.network/ @@ -201,20 +204,20 @@ jobs: ref: main # Setup gcloud CLI - - uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 + - uses: google-github-actions/setup-gcloud@v2 with: service_account_key: ${{ secrets.GKE_SA_KEY }} project_id: ${{ secrets.GKE_PROJECT }} # Get the GKE credentials so we can deploy to the cluster - - uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e + - uses: google-github-actions/get-gke-credentials@v2 with: cluster_name: ${{ secrets.GKE_CLUSTER }} location: ${{ secrets.GKE_ZONE }} credentials: ${{ secrets.GKE_SA_KEY }} - name: install kubectl - uses: azure/setup-kubectl@v3.0 + uses: azure/setup-kubectl@v3 with: version: "v1.23.6" id: install @@ -230,6 +233,9 @@ jobs: needs: build-production name: Deploy to GKE Manipur runs-on: ubuntu-latest + - uses: actions/setup-node@v3 + with: + node-version: '20' environment: name: Production-Manipur url: https://care.mn.gov.in @@ -243,20 +249,20 @@ jobs: ref: main # Setup gcloud CLI - - uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 + - uses: google-github-actions/setup-gcloud@v2 with: service_account_key: ${{ secrets.GKE_SA_KEY }} project_id: ${{ secrets.GKE_PROJECT }} # Get the GKE credentials so we can deploy to the cluster - - uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e + - uses: google-github-actions/get-gke-credentials@v2 with: cluster_name: ${{ secrets.GKE_CLUSTER }} location: ${{ secrets.GKE_ZONE }} credentials: ${{ secrets.GKE_SA_KEY }} - name: install kubectl - uses: azure/setup-kubectl@v3.0 + uses: azure/setup-kubectl@v3 with: version: "v1.23.6" id: install @@ -272,6 +278,9 @@ jobs: needs: build-production name: Deploy to GKE Karnataka runs-on: ubuntu-latest + - uses: actions/setup-node@v3 + with: + node-version: '20' environment: name: Production-Karnataka url: https://karnataka.care @@ -285,20 +294,20 @@ jobs: ref: main # Setup gcloud CLI - - uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 + - uses: google-github-actions/setup-gcloud@v2 with: service_account_key: ${{ secrets.GKE_SA_KEY }} project_id: ${{ secrets.GKE_PROJECT }} # Get the GKE credentials so we can deploy to the cluster - - uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e + - uses: google-github-actions/get-gke-credentials@v2 with: cluster_name: ${{ secrets.GKE_CLUSTER }} location: ${{ secrets.GKE_ZONE }} credentials: ${{ secrets.GKE_SA_KEY }} - name: install kubectl - uses: azure/setup-kubectl@v3.0 + uses: azure/setup-kubectl@v3 with: version: "v1.23.6" id: install @@ -314,6 +323,9 @@ jobs: needs: build-production name: Deploy to GKE Sikkim runs-on: ubuntu-latest + - uses: actions/setup-node@v3 + with: + node-version: '20' environment: name: Production-Sikkim url: https://care.sikkim.gov.in @@ -327,20 +339,20 @@ jobs: ref: main # Setup gcloud CLI - - uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 + - uses: google-github-actions/setup-gcloud@v2 with: service_account_key: ${{ secrets.GKE_SA_KEY }} project_id: ${{ secrets.GKE_PROJECT }} # Get the GKE credentials so we can deploy to the cluster - - uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e + - uses: google-github-actions/get-gke-credentials@v2 with: cluster_name: ${{ secrets.GKE_CLUSTER }} location: ${{ secrets.GKE_ZONE }} credentials: ${{ secrets.GKE_SA_KEY }} - name: install kubectl - uses: azure/setup-kubectl@v3.0 + uses: azure/setup-kubectl@v3 with: version: "v1.23.6" id: install @@ -356,6 +368,9 @@ jobs: needs: build-production name: Deploy to GKE Assam runs-on: ubuntu-latest + - uses: actions/setup-node@v3 + with: + node-version: '20' environment: name: Production-Assam url: https://care.assam.gov.in @@ -369,20 +384,20 @@ jobs: ref: main # Setup gcloud CLI - - uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 + - uses: google-github-actions/setup-gcloud@v2 with: service_account_key: ${{ secrets.GKE_SA_KEY }} project_id: ${{ secrets.GKE_PROJECT }} # Get the GKE credentials so we can deploy to the cluster - - uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e + - uses: google-github-actions/get-gke-credentials@v2 with: cluster_name: ${{ secrets.GKE_CLUSTER }} location: ${{ secrets.GKE_ZONE }} credentials: ${{ secrets.GKE_SA_KEY }} - name: install kubectl - uses: azure/setup-kubectl@v3.0 + uses: azure/setup-kubectl@v3 with: version: "v1.23.6" id: install @@ -398,6 +413,9 @@ jobs: needs: build-production name: Deploy to GKE Nagaland runs-on: ubuntu-latest + - uses: actions/setup-node@v3 + with: + node-version: '20' environment: name: Production - Nagaland url: https://care.nagaland.gov.in @@ -411,20 +429,20 @@ jobs: ref: main # Setup gcloud CLI - - uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 + - uses: google-github-actions/setup-gcloud@v2 with: service_account_key: ${{ secrets.GKE_SA_KEY }} project_id: ${{ secrets.GKE_PROJECT }} # Get the GKE credentials, so we can deploy to the cluster - - uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e + - uses: google-github-actions/get-gke-credentials@v2 with: cluster_name: ${{ secrets.GKE_CLUSTER }} location: ${{ secrets.GKE_ZONE }} credentials: ${{ secrets.GKE_SA_KEY }} - name: install kubectl - uses: azure/setup-kubectl@v3.0 + uses: azure/setup-kubectl@v3 with: version: "v1.23.6" id: install @@ -440,6 +458,9 @@ jobs: needs: build-production name: Deploy to GKE Meghalaya runs-on: ubuntu-latest + - uses: actions/setup-node@v3 + with: + node-version: '20' environment: name: Production-Meghalaya url: https://care.meghealth.gov.in @@ -453,20 +474,20 @@ jobs: ref: main # Setup gcloud CLI - - uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7 + - uses: google-github-actions/setup-gcloud@v2 with: service_account_key: ${{ secrets.GKE_SA_KEY }} project_id: ${{ secrets.GKE_PROJECT }} # Get the GKE credentials, so we can deploy to the cluster - - uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e + - uses: google-github-actions/get-gke-credentials@v2 with: cluster_name: ${{ secrets.GKE_CLUSTER }} location: ${{ secrets.GKE_ZONE }} credentials: ${{ secrets.GKE_SA_KEY }} - name: install kubectl - uses: azure/setup-kubectl@v3.0 + uses: azure/setup-kubectl@v3 with: version: "v1.23.6" id: install diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index ce4bd271cf7..2bf60f375fc 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -17,12 +17,12 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: - node-version: "18" + node-version: '20' - name: Install dependencies run: npm ci diff --git a/.github/workflows/ossar-analysis.yml b/.github/workflows/ossar-analysis.yml index c213148091f..4e806124e77 100644 --- a/.github/workflows/ossar-analysis.yml +++ b/.github/workflows/ossar-analysis.yml @@ -17,7 +17,7 @@ jobs: steps: # Checkout your code repository to scan - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. @@ -30,7 +30,7 @@ jobs: # Run open source static analysis tools - name: Run OSSAR - uses: github/ossar-action@v1 + uses: github/ossar-action@fae13e456b9973657a670eef6bccc3a4c2b5153d id: ossar # Upload results to the Security tab diff --git a/.github/workflows/thank-you.yml b/.github/workflows/thank-you.yml index cd36e64d888..c8104ad73a5 100644 --- a/.github/workflows/thank-you.yml +++ b/.github/workflows/thank-you.yml @@ -1,7 +1,7 @@ name: Say thanks for the contributors on: - pull_request: + pull_request_target: types: - closed diff --git a/cypress/e2e/external_results_spec/filter.cy.ts b/cypress/e2e/external_results_spec/filter.cy.ts index 577b6a46d98..3dd18704a46 100644 --- a/cypress/e2e/external_results_spec/filter.cy.ts +++ b/cypress/e2e/external_results_spec/filter.cy.ts @@ -20,7 +20,7 @@ describe("External Results Filters", () => { cy.get("#local_bodies").click(); cy.get("#wards").click(); cy.get("[role='option']").should("be.visible"); - cy.contains("[role='option']", "12").click(); + cy.contains("[role='option']", "4").click(); cy.contains("Apply").click(); }); diff --git a/cypress/e2e/facility_spec/facility_creation.cy.ts b/cypress/e2e/facility_spec/facility_creation.cy.ts index 9fe78f84256..f8001584ac3 100644 --- a/cypress/e2e/facility_spec/facility_creation.cy.ts +++ b/cypress/e2e/facility_spec/facility_creation.cy.ts @@ -120,6 +120,8 @@ describe("Facility Creation", () => { cy.get("[role='option']").contains(featureText).click(); }); facilityPage.fillPincode("682001"); + facilityPage.selectStateOnPincode("Kerala"); + facilityPage.selectDistrictOnPincode("Ernakulam"); facilityPage.selectLocalBody("Aluva"); facilityPage.selectWard("4"); facilityPage.fillAddress(facilityAddress); @@ -190,6 +192,8 @@ describe("Facility Creation", () => { facilityPage.visitCreateFacilityPage(); facilityPage.fillFacilityName(facilityName); facilityPage.fillPincode("682001"); + facilityPage.selectStateOnPincode("Kerala"); + facilityPage.selectDistrictOnPincode("Ernakulam"); facilityPage.selectLocalBody("Aluva"); facilityPage.selectWard("4"); facilityPage.fillAddress(facilityAddress); @@ -217,7 +221,6 @@ describe("Facility Creation", () => { .should("be.visible"); // verify the facility homepage cy.visit("/facility"); - cy.clearAllFilters(); manageUserPage.typeFacilitySearch(facilityName); facilityPage.verifyFacilityBadgeContent(facilityName); manageUserPage.assertFacilityInCard(facilityName); @@ -228,6 +231,8 @@ describe("Facility Creation", () => { facilityPage.visitCreateFacilityPage(); facilityPage.fillFacilityName(facilityName); facilityPage.fillPincode("682001"); + facilityPage.selectStateOnPincode("Kerala"); + facilityPage.selectDistrictOnPincode("Ernakulam"); facilityPage.selectLocalBody("Aluva"); facilityPage.selectWard("4"); facilityPage.fillAddress(facilityAddress); diff --git a/cypress/e2e/facility_spec/locations.cy.ts b/cypress/e2e/facility_spec/locations.cy.ts index 59651c7c7c9..26364048ca2 100644 --- a/cypress/e2e/facility_spec/locations.cy.ts +++ b/cypress/e2e/facility_spec/locations.cy.ts @@ -1,6 +1,42 @@ import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; +import { AssetPage } from "../../pageobject/Asset/AssetCreation"; +import { UserCreationPage } from "../../pageobject/Users/UserCreation"; +import FacilityPage from "../../pageobject/Facility/FacilityCreation"; +import FacilityLocation from "../../pageobject/Facility/FacilityLocation"; +// import { AssetPagination } from "../../pageobject/Asset/AssetPagination"; describe("Location Management Section", () => { + const assetPage = new AssetPage(); + const userCreationPage = new UserCreationPage(); + const facilityPage = new FacilityPage(); + const facilityLocation = new FacilityLocation(); + // const assetPagination = new AssetPagination(); + const EXPECTED_LOCATION_ERROR_MESSAGES = [ + "Name is required", + "Location Type is required", + ]; + const EXPECTED_BED_ERROR_MESSAGES = [ + "Please enter a name", + "Please select a bed type", + ]; + const locationName = "Test-location"; + const locationDescription = "Test Description"; + const locationType = "WARD"; + const locationMiddleware = "dev_middleware.coronasafe.live"; + const locationModifiedName = "Test Modified location"; + const locationModifiedDescription = "Test Modified Description"; + const locationModifiedType = "ICU"; + const locationModifiedMiddleware = "dev-middleware.coronasafe.live"; + const bedName = "Test Bed"; + const bedDescrption = "test description"; + const bedType = "ICU"; + const bedStatus = "Vacant"; + const bedModifiedName = "test modified bed"; + const bedModifiedDescrption = "test modified description"; + const bedModifiedType = "Isolation"; + const numberOfBeds = 10; + // const numberOfModifiedBeds = 25; + before(() => { cy.loginByApi("devdistrictadmin", "Coronasafe@123"); cy.saveLocalStorage(); @@ -20,28 +56,95 @@ describe("Location Management Section", () => { cy.get("[id=location-management]").click(); }); - it("Adds Location", () => { - cy.contains("Add New Location").click(); - cy.get("[name='name']").type("Test Location"); - cy.get("textarea[name='description']").type("Test Description"); - cy.get("#location-type").click(); - cy.get("#location-type-option-ICU").click(); - cy.intercept(/\/api\/v1\/facility\/[\w-]+\/asset_location\//).as( - "addLocation" - ); - cy.get("button").contains("Add Location").click(); - cy.wait("@addLocation").then((interception) => { - switch (interception?.response?.statusCode) { - case 201: - cy.verifyNotification("Location created successfully"); - return; - case 400: - cy.verifyNotification( - "Name - Asset location with this name and facility already exists." - ); - return; - } - }); + it("Adds Location to a facility and modify it", () => { + // add a new location form mandatory error + facilityLocation.clickAddNewLocationButton(); + assetPage.clickassetupdatebutton(); + userCreationPage.verifyErrorMessages(EXPECTED_LOCATION_ERROR_MESSAGES); + // create a new location + facilityPage.fillFacilityName(locationName); + facilityLocation.fillDescription(locationDescription); + facilityLocation.selectLocationType(locationType); + facilityLocation.fillMiddlewareAddress(locationMiddleware); + assetPage.clickassetupdatebutton(); + // verify the reflection + facilityLocation.verifyLocationName(locationName); + facilityLocation.verifyLocationType(locationType); + facilityLocation.verifyLocationDescription(locationDescription); + facilityLocation.verifyLocationMiddleware(locationMiddleware); + // modify the existing data + facilityLocation.clickEditLocationButton(); + facilityPage.fillFacilityName(locationModifiedName); + facilityLocation.fillDescription(locationModifiedDescription); + facilityLocation.selectLocationType(locationModifiedType); + facilityLocation.fillMiddlewareAddress(locationModifiedMiddleware); + assetPage.clickassetupdatebutton(); + // verify the reflection + facilityLocation.verifyLocationName(locationModifiedName); + facilityLocation.verifyLocationType(locationModifiedType); + facilityLocation.verifyLocationDescription(locationModifiedDescription); + facilityLocation.verifyLocationMiddleware(locationModifiedMiddleware); + }); + + it("Add Multiple Bed to a facility location and delete a bed", () => { + // create multiple bed and verify + facilityLocation.clickManageBedButton(); + facilityLocation.clickAddBedButton(); + facilityLocation.enterBedName(bedName); + facilityLocation.enterBedDescription(bedDescrption); + facilityLocation.selectBedType(bedType); + facilityLocation.setMultipleBeds(numberOfBeds); + assetPage.clickassetupdatebutton(); + // verify the bed creation + facilityLocation.verifyBedBadge(bedType); + facilityLocation.verifyBedBadge(bedStatus); + facilityLocation.verifyIndividualBedName(bedName, numberOfBeds); + // delete a bed and verify it + facilityLocation.deleteFirstBed(); + facilityLocation.deleteBedRequest(); + assetPage.clickassetupdatebutton(); + facilityLocation.deleteBedRequest(); + }); + + // it("Add Multiple Bed to a facility location and verify pagination", () => { + // // bed creation + // facilityLocation.clickManageBedButton(); + // facilityLocation.clickAddBedButton(); + // facilityLocation.enterBedName(bedModifiedName); + // facilityLocation.enterBedDescription(bedModifiedDescrption); + // facilityLocation.selectBedType(bedModifiedType); + // facilityLocation.setMultipleBeds(numberOfModifiedBeds); + // assetPage.clickassetupdatebutton(); + // // pagination + // assetPagination.navigateToNextPage(); + // assetPagination.navigateToPreviousPage(); + // }); need to be unblocked upon issue #6906 is solved + + it("Add Single Bed to a facility location and modify it", () => { + // mandatory field verification in bed creation + facilityLocation.clickManageBedButton(); + facilityLocation.clickAddBedButton(); + assetPage.clickassetupdatebutton(); + userCreationPage.verifyErrorMessages(EXPECTED_BED_ERROR_MESSAGES); + // create a new single bed and verify + facilityLocation.enterBedName(bedName); + facilityLocation.enterBedDescription(bedDescrption); + facilityLocation.selectBedType(bedType); + assetPage.clickassetupdatebutton(); + // Verify the bed creation + facilityLocation.verifyBedNameBadge(bedName); + facilityLocation.verifyBedBadge(bedType); + facilityLocation.verifyBedBadge(bedStatus); + // edit the created bed + facilityLocation.clickEditBedButton(); + facilityLocation.enterBedName(bedModifiedName); + facilityLocation.enterBedDescription(bedModifiedDescrption); + facilityLocation.selectBedType(bedModifiedType); + assetPage.clickassetupdatebutton(); + // verify the modification + facilityLocation.verifyBedNameBadge(bedModifiedName); + facilityLocation.verifyBedBadge(bedModifiedType); + facilityLocation.verifyBedBadge(bedStatus); }); afterEach(() => { diff --git a/cypress/e2e/patient_spec/patient_crud.cy.ts b/cypress/e2e/patient_spec/patient_crud.cy.ts index b9843c1556d..06a27333b9e 100644 --- a/cypress/e2e/patient_spec/patient_crud.cy.ts +++ b/cypress/e2e/patient_spec/patient_crud.cy.ts @@ -2,6 +2,7 @@ import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress"; import LoginPage from "../../pageobject/Login/LoginPage"; import { PatientPage } from "../../pageobject/Patient/PatientCreation"; import { UpdatePatientPage } from "../../pageobject/Patient/PatientUpdate"; +import FacilityPage from "../../pageobject/Facility/FacilityCreation"; import { PatientConsultationPage } from "../../pageobject/Patient/PatientConsultation"; import { emergency_phone_number, @@ -19,6 +20,7 @@ describe("Patient Creation with consultation", () => { const patientPage = new PatientPage(); const updatePatientPage = new UpdatePatientPage(); const patientConsultationPage = new PatientConsultationPage(); + const facilityPage = new FacilityPage(); before(() => { loginPage.loginAsDisctrictAdmin(); @@ -42,10 +44,13 @@ describe("Patient Creation with consultation", () => { "Male", "Test Patient Address", "682001", - "1: PAZHAMTHOTTAM", "O+", "01012001" ); + facilityPage.selectStateOnPincode("Kerala"); + facilityPage.selectDistrictOnPincode("Ernakulam"); + facilityPage.selectLocalBody("Aluva"); + facilityPage.selectWard("4"); patientPage.clickCreatePatient(); patientPage.verifyPatientIsCreated(); diff --git a/cypress/e2e/patient_spec/patient_manage.cy.ts b/cypress/e2e/patient_spec/patient_manage.cy.ts index 89d00b6bb9f..6c58767c06b 100644 --- a/cypress/e2e/patient_spec/patient_manage.cy.ts +++ b/cypress/e2e/patient_spec/patient_manage.cy.ts @@ -36,7 +36,7 @@ describe("Patient", () => { // commented out the shifting request, as logic need to be re-visited it("Post doctor notes for an already created patient", () => { - patientPage.visitPatient(); + patientPage.visitPatient("Dummy Patient 3"); patientConsultationPage.visitDoctorNotesPage(); patientConsultationPage.addDoctorsNotes("Test Doctor Notes"); patientConsultationPage.postDoctorNotes(); @@ -46,7 +46,7 @@ describe("Patient", () => { }); it("Edit prescription for an already created patient", () => { - patientPage.visitPatient(); + patientPage.visitPatient("Dummy Patient 4"); patientConsultationPage.visitEditPrescriptionPage(); patientConsultationPage.clickAddPrescription(); patientConsultationPage.interceptMediaBase(); @@ -59,14 +59,14 @@ describe("Patient", () => { }); it("Upload consultations file ", () => { - patientPage.visitPatient(); + patientPage.visitPatient("Dummy Patient 5"); patientConsultationPage.visitFilesPage(); patientConsultationPage.uploadFile(); patientConsultationPage.clickUploadFile(); }); it("Discharge a patient", () => { - patientPage.visitPatient(); + patientPage.visitPatient("Dummy Patient 6"); patientConsultationPage.clickDischargePatient(); patientConsultationPage.selectDischargeReason("Recovered"); patientConsultationPage.addDischargeNotes("Discharge notes"); diff --git a/cypress/pageobject/Facility/FacilityCreation.ts b/cypress/pageobject/Facility/FacilityCreation.ts index c13f5beac8e..608dd9c357b 100644 --- a/cypress/pageobject/Facility/FacilityCreation.ts +++ b/cypress/pageobject/Facility/FacilityCreation.ts @@ -402,6 +402,40 @@ class FacilityPage { .its("response.statusCode") .should("eq", 201); } + + getStateElement() { + return cy.get("#state"); + } + + getDistrictElement() { + return cy.get("#district"); + } + + selectStateOnPincode(stateName) { + this.getStateElement() + .scrollIntoView() + .should("be.visible") + .then(($element) => { + const text = $element.text(); + if (!text.includes(stateName)) { + this.getStateElement().click(); + cy.get("li[role=option]").contains(stateName).click(); + } + }); + } + + selectDistrictOnPincode(districtName) { + this.getDistrictElement() + .scrollIntoView() + .should("be.visible") + .then(($element) => { + const text = $element.text(); + if (!text.includes(districtName)) { + this.getDistrictElement().click(); + cy.get("li[role=option]").contains(districtName).click(); + } + }); + } } export default FacilityPage; diff --git a/cypress/pageobject/Facility/FacilityLocation.ts b/cypress/pageobject/Facility/FacilityLocation.ts new file mode 100644 index 00000000000..d3eebdaf4ff --- /dev/null +++ b/cypress/pageobject/Facility/FacilityLocation.ts @@ -0,0 +1,105 @@ +class FacilityLocation { + clickAddNewLocationButton() { + cy.get("#add-new-location").click(); + } + + clickEditLocationButton() { + cy.get("#edit-location-button").click(); + } + + clickEditBedButton() { + cy.get("#edit-bed-button").click(); + } + + fillDescription(description: string) { + cy.get("#description").clear().click().type(description); + } + + selectLocationType(type: string) { + cy.get("#location-type").click(); + cy.get("li[role=option]").contains(type).click(); + } + + fillMiddlewareAddress(address: string) { + cy.get("#location-middleware-address").clear().click().type(address); + } + + verifyLocationName(name: string) { + cy.get("#view-location-name").contains(name); + } + + verifyLocationType(type: string) { + cy.get("#location-type").contains(type); + } + + verifyLocationDescription(description: string) { + cy.get("#view-location-description").contains(description); + } + + verifyLocationMiddleware(middleware: string) { + cy.get("#view-location-middleware").contains(middleware); + } + + clickManageBedButton() { + cy.get("#manage-bed-button").first().click(); + } + + clickAddBedButton() { + cy.get("#add-new-bed").click(); + } + + enterBedName(name: string) { + cy.get("#bed-name").clear().click().type(name); + } + + enterBedDescription(description: string) { + cy.get("#bed-description").clear().click().type(description); + } + + selectBedType(type: string) { + cy.get("#bed-type").click(); + cy.get("li[role=option]").contains(type).click(); + } + + setMultipleBeds(numberOfBeds: number) { + if (numberOfBeds > 1) { + cy.get("#multiplebed-checkbox").click(); + cy.get("#numberofbed") + .click() + .clear() + .click() + .type(numberOfBeds.toString()); + } + } + + verifyBedBadge(badge: string) { + cy.get("#view-bedbadges").contains(badge); + } + + verifyBedNameBadge(name: string) { + cy.get("#view-bed-name").contains(name); + } + + verifyIndividualBedName(baseName: string, totalBeds: number) { + for (let i = 1; i <= totalBeds; i++) { + const expectedName = `${baseName} ${i}`; + cy.get("p#view-bed-name.inline.break-words.text-xl.capitalize") + .should("be.visible") + .contains(expectedName); + } + } + + deleteFirstBed() { + cy.get("#delete-bed-button").first().click(); + } + + deleteBedRequest() { + cy.intercept("DELETE", "**/api/v1/bed/**").as("deleteRequest"); + } + + deleteBedResponse() { + cy.wait("@deleteRequest").its("response.statusCode").should("eq", 204); + } +} + +export default FacilityLocation; diff --git a/cypress/pageobject/Patient/PatientConsultation.ts b/cypress/pageobject/Patient/PatientConsultation.ts index 26d75feba2e..7528b30da06 100644 --- a/cypress/pageobject/Patient/PatientConsultation.ts +++ b/cypress/pageobject/Patient/PatientConsultation.ts @@ -103,7 +103,8 @@ export class PatientConsultationPage { } visitFilesPage() { - cy.get("a").contains("Files").click(); + cy.get("#consultation_tab_nav").scrollIntoView(); + cy.get("#consultation_tab_nav").contains("Files").click(); } uploadFile() { @@ -199,11 +200,13 @@ export class PatientConsultationPage { } visitDoctorNotesPage() { + cy.get("#patient_doctor_notes").scrollIntoView(); cy.get("#patient_doctor_notes").click(); } addDoctorsNotes(notes: string) { - cy.get("#doctor_notes_textarea").type(notes); + cy.get("#doctor_notes_textarea").scrollIntoView(); + cy.get("#doctor_notes_textarea").click().type(notes); } postDoctorNotes() { @@ -213,6 +216,7 @@ export class PatientConsultationPage { } clickDischargePatient() { + cy.get("#show-more").scrollIntoView(); cy.get("#show-more").click(); cy.contains("p", "Discharge from CARE").click(); } @@ -248,6 +252,7 @@ export class PatientConsultationPage { } visitEditPrescriptionPage() { + cy.get("#consultation_tab_nav").scrollIntoView(); cy.get("#consultation_tab_nav").contains("Medicines").click(); cy.get("a[href='prescriptions']").first().click(); } diff --git a/cypress/pageobject/Patient/PatientCreation.ts b/cypress/pageobject/Patient/PatientCreation.ts index 47bf9c913ad..4e2f92ac040 100644 --- a/cypress/pageobject/Patient/PatientCreation.ts +++ b/cypress/pageobject/Patient/PatientCreation.ts @@ -10,10 +10,14 @@ export class PatientPage { cy.wait("@getFacilities").its("response.statusCode").should("eq", 200); } - visitPatient() { + visitPatient(patientName) { + cy.get("#name").click().type(patientName); cy.intercept("GET", "**/api/v1/consultation/**").as("getPatient"); - cy.get("[data-cy='patient']").first().click(); + cy.get("#patient-name-list").contains(patientName).click(); cy.wait("@getPatient").its("response.statusCode").should("eq", 200); + cy.get("#patient-name-consultation") + .should("be.visible") + .contains(patientName); } selectFacility(facilityName: string) { @@ -41,7 +45,6 @@ export class PatientPage { gender: string, address: string, pincode: string, - wardName: string, bloodGroup: string, dateOfBirth: string ) { @@ -58,16 +61,6 @@ export class PatientPage { cy.get("[data-testid=current-address] textarea").type(address); cy.get("[data-testid=permanent-address] input").check(); cy.get("#pincode").type(pincode); - cy.get("[data-testid=localbody] button") - .click() - .then(() => { - cy.get("[role='option']").first().click(); - }); - cy.get("[data-testid=ward-respective-lsgi] button") - .click() - .then(() => { - cy.get("[role='option']").contains(wardName).click(); - }); cy.get("[name=medical_history_check_1]").check(); cy.get("[data-testid=blood-group] button") .click() diff --git a/cypress/pageobject/Users/ManageUserPage.ts b/cypress/pageobject/Users/ManageUserPage.ts index b79b96447f0..d3f7e17e7d5 100644 --- a/cypress/pageobject/Users/ManageUserPage.ts +++ b/cypress/pageobject/Users/ManageUserPage.ts @@ -94,6 +94,7 @@ export class ManageUserPage { } typeFacilitySearch(facilityName) { + cy.get("#search").click().clear(); cy.get("#search").click().type(facilityName); } diff --git a/cypress/pageobject/Users/UserSearch.ts b/cypress/pageobject/Users/UserSearch.ts index 4956532277f..12ac64c51b3 100644 --- a/cypress/pageobject/Users/UserSearch.ts +++ b/cypress/pageobject/Users/UserSearch.ts @@ -104,9 +104,25 @@ export class UserPage { cy.url().should("include", `page=${pageNumber}`); } - verifyMultipleBadgesWithSameId(expectedContents: string[]) { - cy.get("#user-view-name").each((el, index) => { - expect(el.text().trim()).to.equal(expectedContents[index]); + verifyMultipleBadgesWithSameId(alreadylinkedusersviews: string[]) { + cy.get("#user-view-name").then(($elements) => { + const userViews = $elements + .map((_, el) => Cypress.$(el).text().trim()) + .get(); + let foundMatches = 0; + + alreadylinkedusersviews.forEach((expectedContent) => { + const index = userViews.findIndex((actualContent) => + actualContent.includes(expectedContent) + ); + if (index !== -1) { + userViews.splice(index, 1); // Remove the matched element + foundMatches++; + } + if (foundMatches === alreadylinkedusersviews.length) { + return false; // Break the loop if all matches are found + } + }); }); } } diff --git a/index.html b/index.html index 58cb9fffcd1..83c80ef3214 100644 --- a/index.html +++ b/index.html @@ -34,7 +34,34 @@
- +