Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed Oxygen Details from Update Facility form #7796

Closed
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions cypress/e2e/facility_spec/facility_creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ describe("Facility Creation", () => {
facilityPage.selectWard("4");
facilityPage.fillAddress(facilityAddress);
facilityPage.fillPhoneNumber(facilityNumber);
facilityPage.fillOxygenCapacity(oxygenCapacity);
facilityPage.fillExpectedOxygenRequirement(oxygenExpected);
facilityPage.fillBTypeCylinderCapacity(oxygenCapacity);
facilityPage.fillExpectedBTypeCylinderRequirement(oxygenExpected);
facilityPage.fillCTypeCylinderCapacity(oxygenCapacity);
facilityPage.fillExpectedCTypeCylinderRequirement(oxygenExpected);
facilityPage.fillDTypeCylinderCapacity(oxygenCapacity);
facilityPage.fillExpectedDTypeCylinderRequirement(oxygenExpected);
facilityPage.selectLocation("Kochi, Kerala");
facilityPage.submitForm();
cy.closeNotification();
Expand Down Expand Up @@ -191,11 +183,6 @@ describe("Facility Creation", () => {
expect(text).to.contain(feature);
});
});
facilityPage.getFacilityOxygenInfo().scrollIntoView();
facilityPage
.getFacilityOxygenInfo()
.contains(oxygenCapacity)
.should("be.visible");
facilityPage.getFacilityTotalBedCapacity().scrollIntoView();
facilityPage.getFacilityTotalBedCapacity().contains(totalCapacity);
facilityPage.getFacilityTotalBedCapacity().contains(totalOccupancy);
Expand Down Expand Up @@ -293,17 +280,9 @@ describe("Facility Creation", () => {
facilityPage.clickUpdateFacilityOption();
facilityPage.clickUpdateFacilityType("Primary Health Centres");
facilityPage.fillAddress(facilityUpdateAddress);
facilityPage.fillOxygenCapacity(oxygenCapacity);
facilityPage.fillExpectedOxygenRequirement(oxygenExpected);
facilityPage.selectLocation("Kochi, Kerala");
facilityPage.submitForm();
cy.url().should("not.include", "/update");
// verify the updated data
facilityPage.getFacilityOxygenInfo().scrollIntoView();
facilityPage
.getFacilityOxygenInfo()
.contains(oxygenCapacity)
.should("be.visible");
facilityPage.getAddressDetailsView().scrollIntoView();
facilityPage
.getAddressDetailsView()
Expand Down
35 changes: 35 additions & 0 deletions cypress/e2e/facility_spec/facility_manage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ describe("Facility Manage Functions", () => {
const currentOccupied = "80";
const totalUpdatedCapacity = "120";
const currentUpdatedOccupied = "100";
const totalOxygenCapacity = "100";
Copy link
Member

Choose a reason for hiding this comment

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

delete the existing unused constants or reuse them when you are modifying the existing test

Copy link
Contributor Author

@609harsh 609harsh Jun 1, 2024

Choose a reason for hiding this comment

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

new ones are added for oxygen and earlier ones are for doctor and bed. no constants are unused

const expectedBurnRate = "80";
const totalUpdatedOxygenCapacity = "120";
const updatedExpectedBurnRate = "100";

before(() => {
loginPage.loginAsDisctrictAdmin();
Expand Down Expand Up @@ -165,6 +169,37 @@ describe("Facility Manage Functions", () => {
);
});

it("Modify oxygen capacity in Facility detail page", () => {
facilityManage.clickFacilityAddOxygenTypeButton();
facilityPage.selectOxygenType("Liquid Oxygen");
facilityPage.fillTotalOxygenCapacity(totalOxygenCapacity);
facilityPage.fillExpectedBurnRate(expectedBurnRate);
facilityPage.saveAndExitOxygenCapacityForm();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Oxygen capacity added successfully",
);
cy.closeNotification();
facilityManage.verifyFacilityOxygenCapacity(totalOxygenCapacity);
facilityManage.verifyFacilityOxygenCapacity(expectedBurnRate);
// edit a existing bed
facilityManage.clickEditFacilityOxygenCapacity();
facilityPage.fillTotalOxygenCapacity(totalUpdatedOxygenCapacity);
facilityPage.fillExpectedBurnRate(updatedExpectedBurnRate);
facilityPage.clickoxygencapcityaddmore();
facilityManage.verifySuccessMessageVisibilityAndContent(
"Oxygen capacity updated successfully",
);
cy.closeNotification();
facilityManage.verifyFacilityOxygenCapacity(totalUpdatedOxygenCapacity);
facilityManage.verifyFacilityOxygenCapacity(updatedExpectedBurnRate);
// delete a bed
facilityManage.clickDeleteFacilityOxygenCapacity();
facilityManage.clickButtonWithText("Delete");
facilityManage.verifySuccessMessageVisibilityAndContent(
"Oxygen type deleted successfully",
);
});

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
54 changes: 20 additions & 34 deletions cypress/pageobject/Facility/FacilityCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ class FacilityPage {
cy.clickAndSelectOption("div#bed-type button", bedType);
}

selectOxygenType(oxygenType: string) {
cy.clickAndSelectOption("div#oxygen-type button", oxygenType);
}

isVisibleselectBedType() {
cy.get("div#bed-type button").should("be.visible");
}
Expand Down Expand Up @@ -98,39 +102,19 @@ class FacilityPage {
cy.get("input#count").click().clear().click().type(count);
}

fillOxygenCapacity(capacity: string) {
cy.get("#oxygen_capacity").click().clear().type(capacity);
}

fillExpectedOxygenRequirement(requirement: string) {
cy.get("#expected_oxygen_requirement").click().clear().type(requirement);
}

fillBTypeCylinderCapacity(capacity: string) {
cy.get("#type_b_cylinders").click().clear().type(capacity);
}

fillExpectedBTypeCylinderRequirement(requirement: string) {
cy.get("#expected_type_b_cylinders").focus().clear();
cy.get("#expected_type_b_cylinders").focus().type(requirement);
}

fillCTypeCylinderCapacity(capacity: string) {
cy.get("#type_c_cylinders").click().clear().type(capacity);
fillTotalOxygenCapacity(capacity: string) {
cy.get("input#total-oxygen-capacity")
.click()
.clear()
.click()
.type(capacity);
}

fillExpectedCTypeCylinderRequirement(requirement: string) {
cy.get("#expected_type_c_cylinders").focus().clear();
cy.get("#expected_type_c_cylinders").focus().type(requirement);
fillExpectedBurnRate(burnrate: string) {
cy.get("input#expected-burn-rate").click().clear().click().type(burnrate);
}

fillDTypeCylinderCapacity(capacity: string) {
cy.get("#type_d_cylinders").click().clear().type(capacity);
}

fillExpectedDTypeCylinderRequirement(requirement: string) {
cy.get("#expected_type_d_cylinders").focus().clear();
cy.get("#expected_type_d_cylinders").focus().type(requirement);
saveAndExitOxygenCapacityForm() {
cy.get("button#oxygen-capacity-save-and-exit").click();
}

saveAndExitDoctorForm() {
Expand Down Expand Up @@ -204,9 +188,9 @@ class FacilityPage {
return cy.get("#facility-available-features");
}

getFacilityOxygenInfo() {
return cy.get("#facility-oxygen-info");
}
// getFacilityOxygenInfo() {
// return cy.get("#facility-oxygen-info");
// }

clickResourceRequestOption() {
cy.get("#resource-request").contains("Resource Request").click();
Expand Down Expand Up @@ -274,7 +258,9 @@ class FacilityPage {
clickdoctorcapacityaddmore() {
cy.get("#doctor-save").click();
}

clickoxygencapcityaddmore() {
cy.get("#oxygen-capacity-save").click();
}
clickcancelbutton() {
cy.get("#cancel").click();
}
Expand Down
17 changes: 17 additions & 0 deletions cypress/pageobject/Facility/FacilityManage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,22 @@ class FacilityManage {
cy.get("#facility-add-bedtype").scrollIntoView();
cy.get("#facility-add-bedtype").click();
}

verifyFacilityOxygenCapacity(expectedCapacity) {
cy.get("#facility-oxygen-capacity-details").contains(expectedCapacity);
}

clickEditFacilityOxygenCapacity() {
cy.get("#edit-facility-oxygencapacity").click();
}

clickDeleteFacilityOxygenCapacity() {
cy.get("#delete-facility-oxygencapacity").click();
}

clickFacilityAddOxygenTypeButton() {
cy.get("#facility-add-oxygentype").scrollIntoView();
cy.get("#facility-add-oxygentype").click();
}
}
export default FacilityManage;
7 changes: 7 additions & 0 deletions src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,13 @@ export const getBedTypes = ({
];
};

export const OXYGEN_TYPES: Array<OptionsType> = [
{ id: 1, text: "Liquid Oxygen" },
{ id: 2, text: "Type B Cylinders" },
{ id: 3, text: "Type C Cylinders" },
{ id: 4, text: "Type D Cylinders" },
];

export const DOCTOR_SPECIALIZATION: Array<OptionsType> = [
{ id: 1, text: "General Medicine" },
{ id: 2, text: "Pulmonology" },
Expand Down
103 changes: 0 additions & 103 deletions src/Components/Facility/FacilityCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -463,32 +463,6 @@ export const FacilityCreate = (props: FacilityProps) => {
latitude: state.form.latitude,
longitude: state.form.longitude,
phone_number: parsePhoneNumber(state.form.phone_number),
oxygen_capacity: state.form.oxygen_capacity
? state.form.oxygen_capacity
: 0,
type_b_cylinders: state.form.type_b_cylinders
? state.form.type_b_cylinders
: 0,
type_c_cylinders: state.form.type_c_cylinders
? state.form.type_c_cylinders
: 0,
type_d_cylinders: state.form.type_d_cylinders
? state.form.type_d_cylinders
: 0,
expected_oxygen_requirement: state.form.expected_oxygen_requirement
? state.form.expected_oxygen_requirement
: 0,
expected_type_b_cylinders: state.form.expected_type_b_cylinders
? state.form.expected_type_b_cylinders
: 0,

expected_type_c_cylinders: state.form.expected_type_c_cylinders
? state.form.expected_type_c_cylinders
: 0,

expected_type_d_cylinders: state.form.expected_type_d_cylinders
? state.form.expected_type_d_cylinders
: 0,
};

const { res, data: requestData } = facilityId
Expand Down Expand Up @@ -844,79 +818,6 @@ export const FacilityCreate = (props: FacilityProps) => {
required
types={["mobile", "landline"]}
/>
<div className="grid grid-cols-1 gap-4 py-4 sm:grid-cols-2 md:col-span-2 xl:grid-cols-4">
<TextFormField
{...field("oxygen_capacity")}
type="number"
placeholder="0"
label={t("liquid_oxygen_capacity")}
trailingPadding=" "
trailing={<FieldUnit unit={t("litres")} />}
min={0}
/>
<TextFormField
{...field("expected_oxygen_requirement")}
type="number"
placeholder="0"
trailingPadding=" "
trailing={<FieldUnit unit={t("litres_per_day")} />}
label={t("expected_burn_rate")}
min={0}
/>

<TextFormField
{...field("type_b_cylinders")}
type="number"
placeholder="0"
trailingPadding=" "
trailing={<FieldUnit unit={t("cylinders")} />}
min={0}
/>
<TextFormField
{...field("expected_type_b_cylinders")}
type="number"
placeholder="0"
label={t("expected_burn_rate")}
trailingPadding=" "
trailing={<FieldUnit unit={t("cylinders_per_day")} />}
min={0}
/>
<TextFormField
{...field("type_c_cylinders")}
type="number"
placeholder="0"
trailingPadding=" "
trailing={<FieldUnit unit={t("cylinders")} />}
min={0}
/>
<TextFormField
{...field("expected_type_c_cylinders")}
type="number"
placeholder="0"
trailingPadding=" "
trailing={<FieldUnit unit={t("cylinders_per_day")} />}
label={t("expected_burn_rate")}
min={0}
/>
<TextFormField
{...field("type_d_cylinders")}
type="number"
placeholder="0"
trailingPadding=" "
trailing={<FieldUnit unit={t("cylinders")} />}
min={0}
/>
<TextFormField
{...field("expected_type_d_cylinders")}
type="number"
placeholder="0"
label={t("expected_burn_rate")}
trailingPadding=" "
trailing={<FieldUnit unit={t("cylinders_per_day")} />}
min={0}
/>
</div>

{kasp_enabled && (
<RadioFormField
{...field("kasp_empanelled")}
Expand Down Expand Up @@ -999,7 +900,3 @@ export const FacilityCreate = (props: FacilityProps) => {
);
}
};

const FieldUnit = ({ unit }: { unit: string }) => {
return <p className="mr-8 text-xs text-gray-700">{unit}</p>;
};
Loading
Loading