Skip to content

Commit

Permalink
Merge pull request #5713 from coronasafe/develop
Browse files Browse the repository at this point in the history
Production Release; June Week 3
  • Loading branch information
mathew-alex authored Jun 17, 2023
2 parents e713b2d + 326c3e4 commit a5a507b
Show file tree
Hide file tree
Showing 76 changed files with 1,418 additions and 2,056 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:

jobs:
cypress-run:
permissions: write-all
if: github.repository == 'coronasafe/care_fe'
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -58,6 +59,20 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: --max_old_space_size=4096

- name: Remove cypress passed label on failure 🏷️
uses: actions-ecosystem/action-remove-labels@v1
if: failure()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: cypress passed

- name: Add cypress passed label on success 🏷️
uses: actions-ecosystem/action-add-labels@v1
if: success()
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: cypress passed

- name: Remove cypress failed label on success 🏷️
uses: actions-ecosystem/action-remove-labels@v1
if: success()
Expand Down
76 changes: 67 additions & 9 deletions cypress/e2e/assets_spec/assets.cy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
/// <reference types="cypress" />

import { cy, describe, before, beforeEach, it } from "local-cypress";
import { v4 as uuidv4 } from "uuid";

describe("Assets List", () => {
const phone_number = "9999999999";
const serial_no = parseInt((Math.random() * 10 ** 10).toString());

describe("Asset", () => {
before(() => {
cy.loginByApi("devdistrictadmin", "Coronasafe@123");
cy.saveLocalStorage();
Expand All @@ -13,6 +17,64 @@ describe("Assets List", () => {
cy.awaitUrl("/assets");
});

it("Create an Asset", () => {
cy.get("button").should("contain", "Create Asset");
cy.get("[data-testid=create-asset-buttom] button").click();
cy.get("input[name='facilities']")
.type("Dummy Facility 1")
.then(() => {
cy.get("[role='option']").contains("Dummy Facility 1").click();
});
cy.get("button").should("contain", "Select");
cy.get("button").get("#submit").click();
cy.get("[data-testid=asset-name-input] input").type("New Test Asset");
cy.get("[data-testid=asset-location-input] input")
.type("Camera Locat")
.then(() => {
cy.get("[role='option']").contains("Camera Locations").click();
});
cy.get("[data-testid=asset-type-input] button")
.click()
.then(() => {
cy.get("[role='option']").contains("Internal").click();
});
cy.get("[data-testid=asset-class-input] button")
.click()
.then(() => {
cy.get("[role='option']").contains("ONVIF Camera").click();
});
cy.get("[data-testid=asset-description-input] textarea").type(
"Test Description"
);
cy.get("[data-testid=asset-working-status-input] li")
.contains("Working")
.click();
const qr_id = uuidv4();
cy.get("[data-testid=asset-qr-id-input] input").type(qr_id);
cy.get("[data-testid=asset-manufacturer-input] input").type(
"Manufacturer's Name"
);
cy.get("[data-testid=asset-warranty-input] input").type("2025-12-25");
cy.get("[data-testid=asset-support-name-input] input").type(
"Customer Support's Name"
);
cy.get("#customer-support-phone-div").type(phone_number);
cy.get("[data-testid=asset-support-email-input] input").type(
"[email protected]"
);
cy.get("[data-testid=asset-vendor-name-input] input").type("Vendor's Name");
cy.get("[data-testid=asset-serial-number-input] input").type(serial_no);
cy.get("[data-testid=asset-last-serviced-on-input] input").type(
"2021-12-25"
);
cy.get("[data-testid=asset-notes-input] textarea").type(
"Test note for asset creation!"
);
cy.wait(500);
cy.get("#submit").contains("Create Asset").click();
cy.verifyNotification("Asset created successfully");
});

it("Search Asset Name", () => {
const initialUrl = cy.url();
cy.get("[name='search']").type("dummy camera 30");
Expand All @@ -30,13 +92,9 @@ describe("Assets List", () => {

it("Next/Previous Page", () => {
// only works for desktop mode
cy.get("button")
.should("contain", "Next")
.contains("Next")
.click({ force: true });
cy.get("button")
.should("contain", "Previous")
.contains("Previous")
.click({ force: true });
cy.get("button#next-pages").click();
cy.url().should("include", "page=2");
cy.get("button#prev-pages").click();
cy.url().should("include", "page=1");
});
});
4 changes: 2 additions & 2 deletions cypress/e2e/external_results_spec/external_result.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ describe("Edit Profile Testing", () => {

it("Search by phone number", () => {
cy.intercept(/\/api\/v1\/external_result/).as("external_result");
cy.get("[placeholder='Search by Phone Number']").type("4738743424");
cy.get("[placeholder='Search by Phone Number']").type("7387434255");
cy.wait("@external_result").then((interception) => {
expect(interception.response.statusCode).to.equal(200);
});
cy.url().should("include", "%2B914738743424");
cy.url().should("include", "%2B91+73874+34255");
});

it("import", () => {
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/facility_spec/facility.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class facility {
}

static update(facility) {
cy.get("[id=manage-facility-dropdown]").should("exist").click();
cy.get("[id=manage-facility-dropdown]").click();
cy.get("[id=update-facility]").click();
cy.url().should("include", "update");
this.fillForm({
Expand Down Expand Up @@ -73,7 +73,7 @@ class facility {

cy.get("input[id=pincode]").should("exist").clear().type(pincode);

cy.get("input[name=phone_number]").should("exist").type(phone);
cy.get("input[name=phone_number]").should("exist").clear().type(phone);

cy.get("input[id=oxygen_capacity]").clear().type(oxygen_capacity);
cy.get("input[id=expected_oxygen_requirement]")
Expand Down Expand Up @@ -138,7 +138,7 @@ describe("Facility", () => {
ward: "MANAKKAPADY",
address: "some address",
pincode: "884656",
phone: "9985784535",
phone: "+919985784535",
oxygen_capacity: "20",
oxygen_requirement: "30",
type_b_cylinders: "20",
Expand Down Expand Up @@ -185,7 +185,7 @@ describe("Facility", () => {
ward: "PAZHAMTHOTTAM",
address: " update",
pincode: "584675",
phone: "9985784535",
phone: "+919985784535",
oxygen_capacity: "30",
oxygen_requirement: "40",
type_b_cylinders: "23",
Expand Down
56 changes: 53 additions & 3 deletions cypress/e2e/patient_spec/patient_crud.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("Patient Creation with consultation", () => {
cy.get("#phone_number-div").type(phone_number);
cy.get("#emergency_phone_number-div").type(emergency_phone_number);
cy.get("[data-testid=date-of-birth] button").click();
cy.get("div").contains("1").click();
cy.get("#date-1").click();
cy.get("[data-testid=name] input").type("Test E2E User");
cy.get("[data-testid=Gender] button")
.click()
Expand Down Expand Up @@ -64,7 +64,8 @@ describe("Patient Creation with consultation", () => {
.then(() => {
cy.get("[role='option']").contains("O+").click();
});
cy.get("button").get("[data-testid=submit-button]").click();
cy.get("button[data-testid='submit-button']").click();

cy.get("h2").should("contain", "Create Consultation");
cy.url().should("include", "/patient");
cy.url().then((url) => {
Expand Down Expand Up @@ -94,7 +95,27 @@ describe("Patient Creation with consultation", () => {

it("Edit the patient details", () => {
cy.awaitUrl(patient_url + "/update");
cy.get("[data-testid=name] input").clear().type("Test E2E User Editted");
cy.get("[data-testid=name] input").clear().type("Test E2E User Edited");
cy.get("#emergency_phone_number-div")
.clear()
.then(() => {
cy.get("#emergency_phone_number__country").select("IN");
});
cy.get("#emergency_phone_number-div").type("9120330220");
cy.get("#address").clear().type("Test Patient Address Edited");
cy.get("#present_health").type("Severe Cough");
cy.get("#ongoing_medication").type("Paracetamol");
cy.get("#allergies").type("Dust");
cy.get("[name=medical_history_check_1]").uncheck();
cy.get("[name=medical_history_check_2]").check();
cy.get("#medical_history_2").type("2 months ago");
cy.get("[name=medical_history_check_3]").check();
cy.get("#medical_history_3").type("1 month ago");
cy.get("button").get("[data-testid=add-insurance-button]").click();
cy.get("#subscriber_id").type("SUB123");
cy.get("#policy_id").type("P123");
cy.get("#insurer_id").type("GICOFINDIA");
cy.get("#insurer_name").type("GICOFINDIA");
cy.get("button").get("[data-testid=submit-button]").click();
cy.url().should("include", "/patient");
cy.url().then((url) => {
Expand All @@ -104,6 +125,34 @@ describe("Patient Creation with consultation", () => {
});
});

it("Patient Detail verification post edit", () => {
cy.log(patient_url);
cy.awaitUrl(patient_url);
cy.url().should("include", "/facility/");
cy.get("[data-testid=patient-dashboard]").should(
"contain",
"Test E2E User Edited"
);
cy.get("[data-testid=patient-dashboard]").should(
"contain",
"+919120330220"
);
const patientDetails_values: string[] = [
"Test Patient Address Edited",
"Severe Cough",
"Paracetamol",
"Dust",
"Diabetes",
"2 months ago",
"Heart Disease",
"1 month ago",
];

patientDetails_values.forEach((value) => {
cy.get("[data-testid=patient-details]").should("contain", value);
});
});

it("Create a New consultation to existing patient", () => {
cy.visit(patient_url + "/consultation");
cy.get("#consultation_status")
Expand Down Expand Up @@ -156,6 +205,7 @@ describe("Patient Creation with consultation", () => {
cy.get("button#submit").should("be.visible").click();
cy.get("[data-testid='return-to-patient-dashboard']").click();
});

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
34 changes: 30 additions & 4 deletions cypress/e2e/resource_spec/filter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,42 @@ describe("Resource filter", () => {

it("filter by created date", () => {
cy.intercept(/\/api\/v1\/resource/).as("resource_filter");
cy.get("[name='created_date_after']").type("22/05/2020");
cy.get("[name='created_date_before']").type("09/09/2021");
cy.get("[name='created_date_after']").click();
cy.get(
"[role='button'][aria-label='Move backward to switch to the previous month.']"
).click();
cy.get("td[tabindex='-1']")
.first()
.then(($td) => {
$td[0].click();

cy.get("td[tabindex='-1']")
.eq(14)
.then(($td2) => {
$td2[0].click();
});
});
cy.contains("Apply").click();
cy.wait("@resource_filter");
});

it("filter by modified date", () => {
cy.intercept(/\/api\/v1\/resource/).as("resource_filter");
cy.get("[name='modified_date_after']").type("22/05/2020");
cy.get("[name='modified_date_before']").type("09/09/2021");
cy.get("[name='modified_date_after']").click();
cy.get(
"[role='button'][aria-label='Move backward to switch to the previous month.']"
).click();
cy.get("td[tabindex='-1']")
.first()
.then(($td) => {
$td[0].click();

cy.get("td[tabindex='-1']")
.eq(14)
.then(($td2) => {
$td2[0].click();
});
});
cy.contains("Apply").click();
cy.wait("@resource_filter");
});
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/resource_spec/resources.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ describe("Resource Page", () => {
cy.wait("@resource").then((interception) => {
expect(interception.response.statusCode).to.equal(200);
});
cy.contains("Active").should("have.class", "bg-gray-200");
cy.contains("Completed").should("have.class", "bg-white");
cy.contains("Active").should("have.class", "text-primary-500");
cy.contains("Completed").should("have.class", "text-white");
cy.intercept(/\/api\/v1\/resource/).as("resource");
cy.contains("Active").click();
cy.wait("@resource").then((interception) => {
expect(interception.response.statusCode).to.equal(200);
});
cy.contains("Active").should("have.class", "bg-white");
cy.contains("Completed").should("have.class", "bg-gray-200");
cy.contains("Active").should("have.class", "text-white");
cy.contains("Completed").should("have.class", "text-primary-500");
});

it("switch between list view and board view", () => {
Expand Down
15 changes: 12 additions & 3 deletions cypress/e2e/sample_test_spec/filter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@ describe("Sample Filter", () => {
});

it("Filter by Status", () => {
cy.get("[name='status']").select("APPROVED");
cy.get("#status").click();
cy.get("li[role='option']")
.contains(/^APPROVED$/)
.click();
});

it("Filter by Asset Type", () => {
cy.get("[name='result']").select("POSITIVE");
cy.get("#result").click();
cy.get("li[role='option']")
.contains(/^POSITIVE$/)
.click();
});

it("Filter by sample type", () => {
cy.get("[name='sample_type']").select("Biopsy");
cy.get("#sample_type").click();
cy.get("li[role='option']")
.contains(/^Biopsy$/)
.click();
});

afterEach(() => {
Expand Down
7 changes: 5 additions & 2 deletions cypress/e2e/shifting_spec/filter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ describe("Shifting section filter", () => {

it("filter by assigned to user", () => {
cy.intercept(/\/api\/v1\/users/).as("users_filter");
cy.get("[name='assigned_to']").type("cypress").wait("@users_filter");
cy.get("[name='assigned_to']").type("{downarrow}{enter}");
cy.get("[id='assigned_to']")
.wait(100)
.type("cypress")
.wait("@users_filter");
cy.get("[id='assigned_to']").wait(100).type("{downarrow}{enter}");
cy.contains("Apply").click();
});

Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/shifting_spec/shifting.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ describe("Shifting Page", () => {
it("switch between active/archived", () => {
cy.intercept(/\/api\/v1\/shift/).as("shifting");
cy.contains("Archived").click().wait("@shifting");
cy.contains("Active").should("have.class", "bg-gray-200");
cy.contains("Archived").should("have.class", "bg-white");
cy.contains("Active").should("have.class", "text-primary-500");
cy.contains("Archived").should("have.class", "text-white");
cy.intercept(/\/api\/v1\/shift/).as("shifting");
cy.contains("Active").click().wait("@shifting");
cy.contains("Active").should("have.class", "bg-white");
cy.contains("Archived").should("have.class", "bg-gray-200");
cy.contains("Active").should("have.class", "text-white");
cy.contains("Archived").should("have.class", "text-primary-500");
});

afterEach(() => {
Expand Down
Loading

1 comment on commit a5a507b

@vercel
Copy link

@vercel vercel bot commented on a5a507b Jun 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

care-storybook – ./

care-storybook-git-master-coronasafe.vercel.app
care-storybook-coronasafe.vercel.app

Please sign in to comment.