Skip to content

Commit

Permalink
switch bed functionality test (#8613)
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 committed Sep 24, 2024
1 parent 5accddc commit 499e918
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
56 changes: 56 additions & 0 deletions cypress/e2e/patient_spec/PatientBedManagement.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import LoginPage from "../../pageobject/Login/LoginPage";
import { PatientPage } from "../../pageobject/Patient/PatientCreation";
import PatientLogupdate from "../../pageobject/Patient/PatientLogupdate";
import { PatientConsultationPage } from "../../pageobject/Patient/PatientConsultation";

describe("Patient swtich bed functionality", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientLogupdate = new PatientLogupdate();
const patientConsultationPage = new PatientConsultationPage();
const switchBedOne = "Dummy Bed 4";
const switchBedTwo = "Dummy Bed 1";
const switchBedThree = "Dummy Bed 3";
const switchPatientOne = "Dummy Patient 6";
const switchPatientTwo = "Dummy Patient 7";

before(() => {
loginPage.loginAsDisctrictAdmin();
cy.saveLocalStorage();
});

beforeEach(() => {
cy.restoreLocalStorage();
cy.clearLocalStorage(/filters--.+/);
cy.awaitUrl("/patients");
});

it("Assign a bed for a admitted patient from update consultation page", () => {
// Open the update consultation page and assign a bed
patientPage.visitPatient(switchPatientTwo);
patientConsultationPage.clickEditConsultationButton();
patientLogupdate.selectBed(switchBedThree);
// verify the notification
cy.verifyNotification("Bed allocated successfully");
});

it("Assign a bed for a admitted patient from patient dashboard", () => {
// Assign a bed to a patient
patientPage.visitPatient(switchPatientOne);
patientLogupdate.clickSwitchBed();
patientLogupdate.selectBed(switchBedOne);
cy.verifyNotification("Bed allocated successfully");
// Clear the bed and reassign
patientLogupdate.clickSwitchBed();
cy.get("#clear-button").click();
patientLogupdate.selectBed(switchBedTwo);
cy.verifyNotification("Bed allocated successfully");
// verify the card is reflected
patientLogupdate.clickSwitchBed();
cy.verifyContentPresence("#previousbed-list", [switchBedOne, switchBedTwo]);
});

afterEach(() => {
cy.saveLocalStorage();
});
});
6 changes: 5 additions & 1 deletion cypress/pageobject/Patient/PatientLogupdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ class PatientLogupdate {
cy.wait(2000);
}

clickSwitchBed() {
cy.get("#switch-bed").click();
}

selectRoundType(roundType: string) {
cy.clickAndSelectOption("#rounds_type", roundType);
}

selectBed(bed: string) {
cy.searchAndSelectOption("input[name='bed']", bed);
cy.submitButton("Update");
cy.get("#update-switchbed").click();
cy.wait(2000);
}

Expand Down
2 changes: 1 addition & 1 deletion src/CAREUI/display/Timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const TimelineContext = createContext("");

export default function Timeline({ className, children, name }: TimelineProps) {
return (
<div className={className} id="list">
<div className={className} id="previousbed-list">
<ol role="list" className="space-y-6">
<TimelineContext.Provider value={name}>
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Facility/Consultations/Beds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ const Beds = (props: BedsProps) => {
</div>
<div className="mt-4 flex flex-row justify-end">
<div>
<ButtonV2 variant="primary" type="submit">
<ButtonV2 variant="primary" type="submit" id="update-switchbed">
<CareIcon icon="l-bed" className="text-xl" />
Update
</ButtonV2>
Expand Down
1 change: 1 addition & 0 deletions src/Components/Patient/PatientInfoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export default function PatientInfoCard(props: {
)}
{consultation?.admitted && (
<ButtonV2
id="switch-bed"
ghost
onClick={() => setOpen(true)}
className="mt-1 px-[10px] py-1"
Expand Down

0 comments on commit 499e918

Please sign in to comment.