Skip to content

Commit

Permalink
Merge branch 'develop' into notificationMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
khavinshankar committed May 30, 2023
2 parents 0fb883f + e3f2b5b commit 38c887b
Show file tree
Hide file tree
Showing 21 changed files with 403 additions and 373 deletions.
8 changes: 6 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { defineConfig } from "cypress";

import fs from "fs";

export default defineConfig({
projectId: "wf7d2m",
defaultCommandTimeout: 10000,
e2e: {
setupNodeEvents(on, _) {
setupNodeEvents(on, config) {
// implement node event listeners here

require("cypress-localstorage-commands/plugin")(on, config); // eslint-disable-line

on("task", {
readFileMaybe(filename) {
if (fs.existsSync(filename)) {
Expand All @@ -17,6 +19,8 @@ export default defineConfig({
return null;
},
});

return config;
},
baseUrl: "http://localhost:4000",
retries: 2,
Expand Down
46 changes: 23 additions & 23 deletions cypress/e2e/facility_spec/facility.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress";

class facility {
static create(facility) {
Expand Down Expand Up @@ -31,7 +31,7 @@ class facility {
features,
address,
pincode,
tel,
phone,
state,
district,
localbody,
Expand All @@ -47,63 +47,63 @@ class facility {
latitude,
longitude,
}) {
cy.get("[id=facility-type] > div > button").click();
cy.get("[id=facility_type] > div > button").click();
cy.get("div").contains(type).click();

cy.get("input[id=facility-name]").should("exist").type(name);
cy.get("input[id=name]").should("exist").type(name);

cy.get("[id=facility-features] > div > div > button").click();
cy.get("[id=features] > div > div > button").click();
cy.get("li").contains(features[0]).click();
cy.get("li").contains(features[1]).click();
cy.get("body").click();

cy.get("[id=facility-state] > div > button").click();
cy.get("[id=state] > div > button").click();
cy.get("div").contains(state).click();

cy.get("[id=facility-district] > div > button").click();
cy.get("[id=district] > div > button").click();
cy.get("div").contains(district).click();

cy.get("[id=facility-localbody] > div > button").click();
cy.get("[id=local_body] > div > button").click();
cy.get("div").contains(localbody).click();

cy.get("[id=facility-ward] > div > button").click();
cy.get("[id=ward] > div > button").click();
cy.get("div").contains(ward).click();

cy.get("textarea[id=facility-address]").should("exist").type(address);
cy.get("textarea[id=address]").should("exist").type(address);

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

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

cy.get("input[id=facility-oxygen_capacity]").clear().type(oxygen_capacity);
cy.get("input[id=facility-expected_oxygen_requirement]")
cy.get("input[id=oxygen_capacity]").clear().type(oxygen_capacity);
cy.get("input[id=expected_oxygen_requirement]")
.should("exist")
.clear()
.type(oxygen_requirement);

cy.get("input[id=facility-type_b_cylinders]")
cy.get("input[id=type_b_cylinders]")
.should("exist")
.clear()
.type(type_b_cylinders);
cy.get("input[id=facility-expected_type_b_cylinders]")
cy.get("input[id=expected_type_b_cylinders]")
.should("exist")
.clear()
.type(expected_type_b_cylinders);

cy.get("input[id=facility-type_c_cylinders]")
cy.get("input[id=type_c_cylinders]")
.should("exist")
.clear()
.type(type_c_cylinders);
cy.get("input[id=facility-expected_type_c_cylinders]")
cy.get("input[id=expected_type_c_cylinders]")
.should("exist")
.clear()
.type(expected_type_c_cylinders);

cy.get("input[id=facility-type_d_cylinders]")
cy.get("input[id=type_d_cylinders]")
.should("exist")
.clear()
.type(type_d_cylinders);
cy.get("input[id=facility-expected_type_d_cylinders]")
cy.get("input[id=expected_type_d_cylinders]")
.should("exist")
.clear()
.type(expected_type_d_cylinders);
Expand Down Expand Up @@ -138,7 +138,7 @@ describe("Facility", () => {
ward: "MANAKKAPADY",
address: "some address",
pincode: "884656",
tel: "9985784535",
phone: "9985784535",
oxygen_capacity: "20",
oxygen_requirement: "30",
type_b_cylinders: "20",
Expand Down Expand Up @@ -166,7 +166,7 @@ describe("Facility", () => {
cy.get("[id=area-of-specialization] > div > button").click();
cy.get("ul > li:nth-child(2)").click();
cy.get("[id=count]").type("15");
cy.get("[id=submit").click();
cy.get("[id=save-and-exit").click();

cy.verifyNotification("Doctor count added successfully");
cy.url().then((url) => {
Expand All @@ -185,7 +185,7 @@ describe("Facility", () => {
ward: "PAZHAMTHOTTAM",
address: " update",
pincode: "584675",
tel: "9985784535",
phone: "9985784535",
oxygen_capacity: "30",
oxygen_requirement: "40",
type_b_cylinders: "23",
Expand Down
18 changes: 16 additions & 2 deletions cypress/e2e/facility_spec/locations.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
import { afterEach, before, beforeEach, cy, describe, it } from "local-cypress";

describe("Location Management Section", () => {
before(() => {
Expand All @@ -18,8 +18,22 @@ describe("Location Management Section", () => {
cy.contains("Add New Location").click();
cy.get("[name='name']").type("Test Location");
cy.get("textarea[name='description']").type("Test Description");
cy.intercept(/\/api\/v1\/facility\/[\w-]+\/asset_location\//).as(
"addLocation"
);
cy.get("button").contains("Add Location").click();
cy.verifyNotification("Location created successfully");
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;
}
});
});

afterEach(() => {
Expand Down
198 changes: 99 additions & 99 deletions cypress/e2e/patient_spec/patient_crud.cy.ts
Original file line number Diff line number Diff line change
@@ -1,107 +1,107 @@
import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";
// import { cy, describe, before, beforeEach, it, afterEach } from "local-cypress";

const username = "devdistrictadmin";
const password = "Coronasafe@123";
const phone_number = "9" + parseInt((Math.random() * 10 ** 9).toString());
const emergency_phone_number = "9430123487";
const yearOfBirth = "1999";
let patient_url = "";
// const username = "devdistrictadmin";
// const password = "Coronasafe@123";
// const phone_number = "9" + parseInt((Math.random() * 10 ** 9).toString());
// const emergency_phone_number = "9430123487";
// const yearOfBirth = "1999";
// let patient_url = "";

const calculateAge = () => {
const currentYear = new Date().getFullYear();
return currentYear - parseInt(yearOfBirth);
};
// const calculateAge = () => {
// const currentYear = new Date().getFullYear();
// return currentYear - parseInt(yearOfBirth);
// };

describe("Patient Creation", () => {
before(() => {
cy.loginByApi(username, password);
cy.saveLocalStorage();
});
// describe("Patient Creation", () => {
// before(() => {
// cy.loginByApi(username, password);
// cy.saveLocalStorage();
// });

beforeEach(() => {
cy.restoreLocalStorage();
cy.awaitUrl("/");
});
// beforeEach(() => {
// cy.restoreLocalStorage();
// cy.awaitUrl("/");
// });

it("Create", () => {
cy.get("[id='facility-details']").first().click();
cy.get("button").should("contain", "Add Details of a Patient");
cy.get("button")
.contains("Add Details of a Patient")
.click({ force: true });
cy.get("[data-testid=phone-number] input").type(phone_number);
cy.get("[data-testid=date-of-birth] svg").click();
cy.get("div").contains(yearOfBirth).click();
cy.get("span").contains("OK").click();
cy.get("[data-testid=name] input").type("Test E2E User");
cy.get("[data-testid=Gender] select").select("Male");
cy.get("[data-testid=state] select").select("Kerala");
cy.get("[data-testid=district] select").select("Ernakulam");
cy.get("[data-testid=localbody] select").select(
"Alangad  Block Panchayat, Ernakulam District"
);
cy.get("[data-testid=current-address] textarea").type(
"Test Patient Address"
);
cy.get("[data-testid=permanent-address] input").check();
cy.get("[data-testid=ward-respective-lsgi] select").select(
"1: MANAKKAPADY"
);
cy.get("h1").contains("COVID Details").click({ force: true });
cy.get("select#test_type").select("ANTIGEN");
cy.get("[name='is_vaccinated']").check();
cy.get("[data-testid=pincode] input").type("159015");
cy.get("[name=medical_history_check_1]").check();
cy.get("[data-testid=blood-group] select").select("O+");
cy.get("[data-testid=emergency-phone-number] input").type(
emergency_phone_number,
{ delay: 100 }
);
cy.wait(1000);
cy.get("button").get("[data-testid=submit-button]").click();
cy.url().should("include", "/consultation");
cy.url().then((url) => {
cy.log(url);
patient_url = url.split("/").slice(0, -1).join("/");
cy.log(patient_url);
});
});
// it("Create", () => {
// cy.get("[id='facility-details']").first().click();
// cy.get("button").should("contain", "Add Details of a Patient");
// cy.get("button")
// .contains("Add Details of a Patient")
// .click({ force: true });
// cy.get("[data-testid=phone-number] input").type(phone_number);
// cy.get("[data-testid=date-of-birth] svg").click();
// cy.get("div").contains(yearOfBirth).click();
// cy.get("span").contains("OK").click();
// cy.get("[data-testid=name] input").type("Test E2E User");
// cy.get("[data-testid=Gender] select").select("Male");
// cy.get("[data-testid=state] select").select("Kerala");
// cy.get("[data-testid=district] select").select("Ernakulam");
// cy.get("[data-testid=localbody] select").select(
// "Alangad  Block Panchayat, Ernakulam District"
// );
// cy.get("[data-testid=current-address] textarea").type(
// "Test Patient Address"
// );
// cy.get("[data-testid=permanent-address] input").check();
// cy.get("[data-testid=ward-respective-lsgi] select").select(
// "1: MANAKKAPADY"
// );
// cy.get("h1").contains("COVID Details").click({ force: true });
// cy.get("select#test_type").select("ANTIGEN");
// cy.get("[name='is_vaccinated']").check();
// cy.get("[data-testid=pincode] input").type("159015");
// cy.get("[name=medical_history_check_1]").check();
// cy.get("[data-testid=blood-group] select").select("O+");
// cy.get("[data-testid=emergency-phone-number] input").type(
// emergency_phone_number,
// { delay: 100 }
// );
// cy.wait(1000);
// cy.get("button").get("[data-testid=submit-button]").click();
// cy.url().should("include", "/consultation");
// cy.url().then((url) => {
// cy.log(url);
// patient_url = url.split("/").slice(0, -1).join("/");
// cy.log(patient_url);
// });
// });

it("Dashboard", () => {
cy.awaitUrl(patient_url);
cy.url().should("include", "/patient/");
cy.get("[data-testid=patient-dashboard]").should("contain", calculateAge());
cy.get("[data-testid=patient-dashboard]").should(
"contain",
"Test E2E User"
);
cy.get("[data-testid=patient-dashboard]").should("contain", phone_number);
cy.get("[data-testid=patient-dashboard]").should(
"contain",
emergency_phone_number
);
cy.get("[data-testid=patient-dashboard]").should("contain", "1999");
cy.get("[data-testid=patient-dashboard]").should("contain", "O+");
});
// it("Dashboard", () => {
// cy.awaitUrl(patient_url);
// cy.url().should("include", "/patient/");
// cy.get("[data-testid=patient-dashboard]").should("contain", calculateAge());
// cy.get("[data-testid=patient-dashboard]").should(
// "contain",
// "Test E2E User"
// );
// cy.get("[data-testid=patient-dashboard]").should("contain", phone_number);
// cy.get("[data-testid=patient-dashboard]").should(
// "contain",
// emergency_phone_number
// );
// cy.get("[data-testid=patient-dashboard]").should("contain", "1999");
// cy.get("[data-testid=patient-dashboard]").should("contain", "O+");
// });

it("Edit", () => {
cy.awaitUrl(patient_url + "/update");
cy.get("[data-testid=state] select").should("contain", "Kerala");
cy.get("[data-testid=district] select").should("contain", "Ernakulam");
cy.get("[data-testid=localbody] select").should("contain", "Alangad");
cy.get("[data-testid=current-address] textarea").should(
"contain",
"Test Patient Address"
);
// cy.get("[data-testid=permanent-address] input").should("be.checked")
cy.get("[data-testid=ward-respective-lsgi] select").should(
"contain",
"MANAKKAPADY"
);
cy.get("[data-testid=pincode] input").should("have.value", "159015");
});
// it("Edit", () => {
// cy.awaitUrl(patient_url + "/update");
// cy.get("[data-testid=state] select").should("contain", "Kerala");
// cy.get("[data-testid=district] select").should("contain", "Ernakulam");
// cy.get("[data-testid=localbody] select").should("contain", "Alangad");
// cy.get("[data-testid=current-address] textarea").should(
// "contain",
// "Test Patient Address"
// );
// // cy.get("[data-testid=permanent-address] input").should("be.checked")
// cy.get("[data-testid=ward-respective-lsgi] select").should(
// "contain",
// "MANAKKAPADY"
// );
// cy.get("[data-testid=pincode] input").should("have.value", "159015");
// });

afterEach(() => {
cy.saveLocalStorage();
});
});
// afterEach(() => {
// cy.saveLocalStorage();
// });
// });
Loading

0 comments on commit 38c887b

Please sign in to comment.