From 5502f1691adcb29da15a1a2ea05e178adf117ef4 Mon Sep 17 00:00:00 2001 From: Rithvik Nishad Date: Mon, 11 Nov 2024 11:01:14 +0530 Subject: [PATCH 1/3] fixes auto needs testing label (#9025) --- .github/workflows/auto-testing-label.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/auto-testing-label.yml b/.github/workflows/auto-testing-label.yml index 6c6fc1002a0..98cfd46dab3 100644 --- a/.github/workflows/auto-testing-label.yml +++ b/.github/workflows/auto-testing-label.yml @@ -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, From 68bfde477ed7f50af2f87e27ff2edb2a4b38cf6b Mon Sep 17 00:00:00 2001 From: Shaurya Gupta Date: Mon, 11 Nov 2024 11:52:47 +0530 Subject: [PATCH 2/3] Update tooltip position and rotation in Discussion Notes panel (#8938) --- .../Facility/PatientNotesSlideover.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/Facility/PatientNotesSlideover.tsx b/src/components/Facility/PatientNotesSlideover.tsx index 05deef36b91..89d38a5f168 100644 --- a/src/components/Facility/PatientNotesSlideover.tsx +++ b/src/components/Facility/PatientNotesSlideover.tsx @@ -161,15 +161,19 @@ export default function PatientNotesSlideover(props: PatientNotesProps) { id="expand_doctor_notes" className={classNames( "tooltip flex h-8 w-8 cursor-pointer items-center justify-center rounded bg-primary-800 text-secondary-100 text-opacity-70 hover:bg-primary-700 hover:text-opacity-100", - show && "rotate-180", )} onClick={() => setShow(!show)} > - + {t("minimize")} @@ -181,7 +185,12 @@ export default function PatientNotesSlideover(props: PatientNotesProps) { icon="l-times" className="tooltip text-lg transition-all delay-150 duration-300 ease-out" /> - + {t("close")} From cc9d0c977b3ebc03b4a86bb385bc03e299834f32 Mon Sep 17 00:00:00 2001 From: JavidSumra <112365664+JavidSumra@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:46:38 +0530 Subject: [PATCH 3/3] Add Cypress Test Suite for Facility Notice Board Functionality Verification (#9045) --- .../e2e/facility_spec/FacilityHomepage.cy.ts | 53 ++++++++++++++++- cypress/pageobject/Facility/FacilityHome.ts | 3 +- cypress/pageobject/Facility/FacilityNotify.ts | 58 +++++++++++++++++++ cypress/pageobject/Login/LoginPage.ts | 4 ++ cypress/pageobject/Users/ManageUserPage.ts | 8 +++ src/components/Common/Sidebar/SidebarItem.tsx | 2 + src/components/Facility/FacilityCard.tsx | 5 +- src/components/Notifications/NoticeBoard.tsx | 4 +- .../Notifications/NotificationsList.tsx | 5 +- 9 files changed, 135 insertions(+), 7 deletions(-) create mode 100644 cypress/pageobject/Facility/FacilityNotify.ts diff --git a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts index bc84aea4882..7db3b308a53 100644 --- a/cypress/e2e/facility_spec/FacilityHomepage.cy.ts +++ b/cypress/e2e/facility_spec/FacilityHomepage.cy.ts @@ -2,6 +2,7 @@ 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"; @@ -9,6 +10,7 @@ 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(); @@ -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(); @@ -30,6 +34,7 @@ describe("Facility Homepage Function", () => { beforeEach(() => { cy.restoreLocalStorage(); + cy.clearLocalStorage(/filters--.+/); cy.awaitUrl("/facility"); }); @@ -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"); @@ -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(); }); diff --git a/cypress/pageobject/Facility/FacilityHome.ts b/cypress/pageobject/Facility/FacilityHome.ts index dea7de0e7b6..30f51052370 100644 --- a/cypress/pageobject/Facility/FacilityHome.ts +++ b/cypress/pageobject/Facility/FacilityHome.ts @@ -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() { diff --git a/cypress/pageobject/Facility/FacilityNotify.ts b/cypress/pageobject/Facility/FacilityNotify.ts new file mode 100644 index 00000000000..08c44b32e84 --- /dev/null +++ b/cypress/pageobject/Facility/FacilityNotify.ts @@ -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); + } +} diff --git a/cypress/pageobject/Login/LoginPage.ts b/cypress/pageobject/Login/LoginPage.ts index cd5230a7772..38b8aeee2af 100644 --- a/cypress/pageobject/Login/LoginPage.ts +++ b/cypress/pageobject/Login/LoginPage.ts @@ -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; diff --git a/cypress/pageobject/Users/ManageUserPage.ts b/cypress/pageobject/Users/ManageUserPage.ts index 470862693a8..a3a6e72fbc3 100644 --- a/cypress/pageobject/Users/ManageUserPage.ts +++ b/cypress/pageobject/Users/ManageUserPage.ts @@ -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); } diff --git a/src/components/Common/Sidebar/SidebarItem.tsx b/src/components/Common/Sidebar/SidebarItem.tsx index 31f64754ffd..7262c6a103b 100644 --- a/src/components/Common/Sidebar/SidebarItem.tsx +++ b/src/components/Common/Sidebar/SidebarItem.tsx @@ -9,6 +9,7 @@ import useAppHistory from "@/hooks/useAppHistory"; export type SidebarIcon = React.ReactNode; type SidebarItemProps = { + id?: string; ref?: React.Ref; text: string; icon: SidebarIcon; @@ -31,6 +32,7 @@ const SidebarItemBase = forwardRef( return ( + Notify: {facility.name} } diff --git a/src/components/Notifications/NoticeBoard.tsx b/src/components/Notifications/NoticeBoard.tsx index e4472107c8f..e1f00075000 100644 --- a/src/components/Notifications/NoticeBoard.tsx +++ b/src/components/Notifications/NoticeBoard.tsx @@ -26,7 +26,9 @@ export const NoticeBoard = () => { className="overflow-hidden rounded shadow-md" >
-
{item.message}
+
+ {item.message} +
{formatName(item.caused_by)} -{" "} diff --git a/src/components/Notifications/NotificationsList.tsx b/src/components/Notifications/NotificationsList.tsx index 5d88cc8d603..0808877a444 100644 --- a/src/components/Notifications/NotificationsList.tsx +++ b/src/components/Notifications/NotificationsList.tsx @@ -115,7 +115,9 @@ const NotificationTile = ({ />
-
{result.message}
+
+ {result.message} +
{formatDateTime(result.created_date)} @@ -474,6 +476,7 @@ export default function NotificationsList({ <> setOpen(!open)} icon={} badgeCount={unreadCount}