Skip to content

Commit

Permalink
Merge branch 'develop' into issues/9053/prevent-negative-quantity-and…
Browse files Browse the repository at this point in the history
…-empty-description
  • Loading branch information
JavidSumra authored Nov 11, 2024
2 parents 5017f20 + 8a9078d commit f68d453
Show file tree
Hide file tree
Showing 34 changed files with 810 additions and 271 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-testing-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
}
if (isChangesRequired) {
await github.issues.createComment({
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
Expand Down
53 changes: 50 additions & 3 deletions cypress/e2e/facility_spec/FacilityHomepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import { AssetPagination } from "../../pageobject/Asset/AssetPagination";
import FacilityPage from "../../pageobject/Facility/FacilityCreation";
import FacilityHome from "../../pageobject/Facility/FacilityHome";
import FacilityNotify from "../../pageobject/Facility/FacilityNotify";
import LoginPage from "../../pageobject/Login/LoginPage";
import ManageUserPage from "../../pageobject/Users/ManageUserPage";
import { UserPage } from "../../pageobject/Users/UserSearch";

describe("Facility Homepage Function", () => {
const loginPage = new LoginPage();
const facilityHome = new FacilityHome();
const facilityNotify = new FacilityNotify();
const facilityPage = new FacilityPage();
const manageUserPage = new ManageUserPage();
const userPage = new UserPage();
Expand All @@ -22,6 +24,8 @@ describe("Facility Homepage Function", () => {
const district = "Ernakulam";
const localBody = "Aikaranad";
const facilityType = "Private Hospital";
const notificationErrorMsg = "Message cannot be empty";
const notificationMessage = "Test Notification";

before(() => {
loginPage.loginAsDistrictAdmin();
Expand All @@ -30,6 +34,7 @@ describe("Facility Homepage Function", () => {

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

Expand All @@ -41,9 +46,6 @@ describe("Facility Homepage Function", () => {
facilityHome.clickViewCnsButton();
facilityHome.verifyCnsUrl();
facilityHome.navigateBack();
// view notify button
facilityHome.clickFacilityNotifyButton();
facilityHome.verifyAndCloseNotifyModal();
// view facility button
facilityHome.clickViewFacilityDetails();
facilityPage.getFacilityName().should("be.visible");
Expand Down Expand Up @@ -134,6 +136,51 @@ describe("Facility Homepage Function", () => {
facilityHome.verifyLiveMonitorUrl();
});

it("Verify Notice Board Functionality", () => {
// search facility and verify it's loaded or not
manageUserPage.interceptFacilitySearchReq();
manageUserPage.typeFacilitySearch(facilityName);
manageUserPage.verifyFacilitySearchReq();
// verify facility name and card reflection
facilityNotify.verifyUrlContains("Dummy+Facility+40");
facilityPage.verifyFacilityBadgeContent(facilityName);
manageUserPage.assertFacilityInCard(facilityName);
// send notification to a facility
facilityHome.clickFacilityNotifyButton();
facilityNotify.verifyFacilityName(facilityName);
facilityNotify.fillNotifyText(notificationMessage);
facilityNotify.interceptPostNotificationReq();
cy.submitButton("Notify");
facilityNotify.verifyPostNotificationReq();
cy.verifyNotification("Facility Notified");
cy.closeNotification();
cy.wait(2000);
// Verify the frontend error on empty message
facilityHome.clickFacilityNotifyButton();
facilityNotify.verifyFacilityName(facilityName);
cy.submitButton("Notify");
facilityNotify.verifyErrorMessage(notificationErrorMsg);
// close pop-up and verify
facilityHome.verifyAndCloseNotifyModal();
// signout as district admin and login as a Nurse
loginPage.ensureLoggedIn();
loginPage.clickSignOutBtn();
loginPage.loginManuallyAsNurse();
// Verify Notice Board Reflection
facilityNotify.interceptGetNotificationReq("MESSAGE");
facilityNotify.visitNoticeBoard();
facilityNotify.verifyGetNotificationReq();
facilityNotify.verifyFacilityNoticeBoardMessage(notificationMessage);
facilityNotify.interceptGetNotificationReq();
// Verify Sidebar Notification Reflection
facilityNotify.openNotificationSlide();
facilityNotify.verifyGetNotificationReq();
cy.verifyContentPresence("#notification-slide-msg", [notificationMessage]);
facilityNotify.closeNotificationSlide();
loginPage.ensureLoggedIn();
loginPage.clickSignOutBtn();
});

afterEach(() => {
cy.saveLocalStorage();
});
Expand Down
1 change: 0 additions & 1 deletion cypress/e2e/patient_spec/PatientHomepage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ describe("Patient Homepage present functionalities", () => {
patientHome.typePatientAdmitedBeforeDate(patientFromDate);
patientHome.typePatientAdmitedAfterDate(patientToDate);
patientHome.clickPatientFilterApply();
patientHome.verifyTotalPatientCount("1");
// verify the badge and clear the count
patientHome.verifyPatientCreatedBeforeDate(patientToDateBadge);
patientHome.verifyPatientCreatedAfterDate(patientFromDateBadge);
Expand Down
40 changes: 40 additions & 0 deletions cypress/e2e/patient_spec/PatientInvestigation.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { PatientPage } from "pageobject/Patient/PatientCreation";
import PatientInvestigation from "pageobject/Patient/PatientInvestigation";

import LoginPage from "../../pageobject/Login/LoginPage";

describe("Patient Investigation Creation from Patient consultation page", () => {
const loginPage = new LoginPage();
const patientPage = new PatientPage();
const patientInvestigation = new PatientInvestigation();
const patientName = "Dummy Patient 12";

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

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

it("Create a investigation for a patient and verify its reflection", () => {
patientPage.visitPatient(patientName);
patientInvestigation.clickInvestigationTab();
patientInvestigation.clickLogLabResults();
patientInvestigation.selectInvestigationOption([
"Haematology",
"Urine Test",
]);
cy.submitButton("Save Investigation");
cy.verifyNotification("Please Enter at least one value");
cy.closeNotification();
// Temporary workflow for investigation since we dont have dummy data and moving away from existing module
});

afterEach(() => {
cy.saveLocalStorage();
});
});
3 changes: 2 additions & 1 deletion cypress/pageobject/Facility/FacilityHome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class FacilityHome {
}

clickFacilityNotifyButton() {
cy.get("#facility-notify").first().click();
cy.get("#facility-notify", { timeout: 10000 }).should("be.visible");
cy.get("#facility-notify").focus().click();
}

clickLiveMonitorButton() {
Expand Down
58 changes: 58 additions & 0 deletions cypress/pageobject/Facility/FacilityNotify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
export default class FacilityNotify {
verifyFacilityName(facilityName: string) {
cy.verifyContentPresence("#notify-facility-name", [facilityName]);
}

verifyErrorMessage(errorMessage: string) {
cy.verifyContentPresence(".error-text", [errorMessage]);
}

fillNotifyText(message: string) {
cy.get("#NotifyModalMessageInput").scrollIntoView();
cy.get("#NotifyModalMessageInput").click().type(message);
}

verifyFacilityNoticeBoardMessage(message: string) {
cy.get("#notification-message", { timeout: 10000 }).should("be.visible");
cy.verifyContentPresence("#notification-message", [message]);
}

openNotificationSlide() {
cy.get("#notification-slide-btn").should("be.visible").click();
}

closeNotificationSlide() {
cy.get("#close-slide-over").should("be.visible").click();
}

visitNoticeBoard() {
cy.get("a[href='/notice_board']").should("be.visible").click();
}

visitNotificationSideBar() {
cy.get("#notification-slide-btn").should("be.visible").click();
}

verifyUrlContains(substring: string) {
cy.url().should("include", substring);
}

interceptPostNotificationReq() {
cy.intercept("POST", "**/api/v1/notification/notify").as("notifyFacility");
}

verifyPostNotificationReq() {
cy.wait("@notifyFacility").its("response.statusCode").should("eq", 204);
}

interceptGetNotificationReq(event: string = "") {
cy.intercept(
"GET",
`**/api/v1/notification/?offset=0&event=${event}&*=SYSTEM`,
).as("getNotifications");
}

verifyGetNotificationReq() {
cy.wait("@getNotifications").its("response.statusCode").should("eq", 200);
}
}
4 changes: 4 additions & 0 deletions cypress/pageobject/Login/LoginPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class LoginPage {
cy.get("#sign-out-button").scrollIntoView();
cy.get("#sign-out-button").contains("Sign Out").should("exist");
}

clickSignOutBtn(): void {
cy.verifyAndClickElement("#sign-out-button", "Sign Out");
}
}

export default LoginPage;
10 changes: 8 additions & 2 deletions cypress/pageobject/Patient/PatientInvestigation.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
class PatientInvestigation {
clickAddInvestigation() {
cy.get("#investigation").scrollIntoView();
cy.verifyAndClickElement("#investigation", "Add Investigation");
}

clickInvestigationTab() {
cy.get("#consultation_tab_nav").scrollIntoView();
cy.verifyAndClickElement("#consultation_tab_nav", "Investigations");
}

Expand All @@ -19,6 +17,14 @@ class PatientInvestigation {
cy.get("#investigation-checkbox").click();
}

selectInvestigationOption(options: string[]) {
cy.clickAndMultiSelectOption("#investigations", options);
}

clickLogLabResults() {
cy.verifyAndClickElement("#log-lab-results", "Log Lab Results");
}

selectInvestigationFrequency(frequency: string) {
cy.get("#investigation-frequency").click();
cy.contains("button", frequency).should("be.visible").click();
Expand Down
8 changes: 8 additions & 0 deletions cypress/pageobject/Users/ManageUserPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ export class ManageUserPage {
cy.get("#search").click().type(facilityName);
}

interceptFacilitySearchReq() {
cy.intercept("GET", "**/api/v1/facility/**").as("searchFacility");
}

verifyFacilitySearchReq() {
cy.wait("@searchFacility").its("response.statusCode").should("eq", 200);
}

assertFacilityInCard(facilityName: string) {
cy.get("#facility-name-card").should("contain", facilityName);
}
Expand Down
Loading

0 comments on commit f68d453

Please sign in to comment.