diff --git a/testing/regression/cypress/e2e/features/nbs-classic/morbidityReportManagement.feature b/testing/regression/cypress/e2e/features/nbs-classic/morbidityReportManagement.feature new file mode 100644 index 0000000000..fab0f23146 --- /dev/null +++ b/testing/regression/cypress/e2e/features/nbs-classic/morbidityReportManagement.feature @@ -0,0 +1,141 @@ +Feature: Patient File - Event Management - Morbidity Report + + Background: + Given I am logged in as secure user + And the user navigate to the patient profile page for "63000" + And Click Events tab on Patient Profile Page + + Scenario: Add new morbidity report without investigation + When I check the current count of "Morbidity reports" in the Events tab + And user clicks on the "Add morbidity report" button within the Events tab + And I select "Botulism, foodborne" from the Condition dropdown menu + And I select "Cobb County" from the Jurisdiction dropdown menu + And I enter the current date in the Date of Morbidity Report field + And I enter "2" in the Facility and Provider Information field + And I click on the Code Lookup button + And I select "No" from the Pregnant dropdown menu + And I click the Submit button + And Click Events tab on Patient Profile Page + Then the "Morbidity reports" count should increase by 1 in the Events tab + + Scenario: Add new morbidity report and create investigation + When I check the current count of "Investigations" in the Events tab + And I check the current count of "Morbidity reports" in the Events tab + And user clicks on the "Add morbidity report" button within the Events tab + And I select "Botulism, foodborne" from the Condition dropdown menu + And I select "Cobb County" from the Jurisdiction dropdown menu + And I enter the current date in the Date of Morbidity Report field + And I enter "2" in the Facility and Provider Information field + And I click on the Code Lookup button + And I select "No" from the Pregnant dropdown menu + And I click the Submit and Create Investigation button + And I click the Submit button + And user clicks the "View File" link, the user is returned to Patient profile summary page + And Click Events tab on Patient Profile Page + Then the "Investigations" count should increase by 1 in the Events tab + And the "Morbidity reports" count should increase by 1 in the Events tab + + Scenario: Cancel creation of a new morbidity report + When I check the current count of "Morbidity reports" in the Events tab + And user clicks on the "Add morbidity report" button within the Events tab + And I select "Botulism, foodborne" from the Condition dropdown menu + And I click the Cancel button on the Morbidity Report page + And I confirm the submission by clicking "Ok" + And I click the Cancel button on the Morbidity Report page + Then the "Morbidity reports" count should remain the same in the Events tab + + Scenario: Edit existing morbidity report + When I count the number of treatments in the first morbidity report + And I click on the first morbidity report link in the Events tab and store its Event ID + And I click the Edit button on the Morbidity Report page + And I enter the current date in the Treatment Date field + And I select "Acyclovir, 800 mg, PO, BID, x 5 days" from the Treatment dropdown menu + And I click the Add Treatment button + And I click the Submit button + And user clicks the "View File" link, the user is returned to Patient profile summary page + And Click Events tab on Patient Profile Page + Then the treatment count should increase by 1 in the stored morbidity report + + Scenario: Print morbidity report + When I click on the first morbidity report link in the Events tab and store its Event ID + Then clicking the Print button should display the print preview + + Scenario: Transfer ownership of morbidity report + When I click on the first morbidity report link in the Events tab and store its Event ID + And I click the Transfer Ownership button on the Morbidity Report page + And I select "Gwinnett County" from the Jurisdiction dropdown menu + And I click the Submit button + And user clicks the "View File" link, the user is returned to Patient profile summary page + Then the saved morbidity report should have jurisdiction "Gwinnett County" + + Scenario: Create investigation from morbidity report + When I click on the first unassociated morbidity report link in the Events tab and store its Event ID + And I click the Create Investigation button on the Morbidity Report page + And I click the Submit button + And user clicks the "View File" link, the user is returned to Patient profile summary page + And Click Events tab on Patient Profile Page + Then the saved morbidity report should be associated with an investigation + + Scenario: Associate investigation from morbidity report + When user clicks on the "Add morbidity report" button within the Events tab + And I select "Botulism, foodborne" from the Condition dropdown menu + And I select "Cobb County" from the Jurisdiction dropdown menu + And I enter the current date in the Date of Morbidity Report field + And I enter "2" in the Facility and Provider Information field + And I click on the Code Lookup button + And I select "No" from the Pregnant dropdown menu + And I click the Submit button + And Click Events tab on Patient Profile Page + And I click on the first morbidity report link in the Events tab and store its Event ID + And I click the Associate Investigation button on the Morbidity Report page + And I check an investigation with the condition "Botulism, foodborne" + And I click the Submit button + And I store the Investigation ID from the association message + And user clicks the "View File" link, the user is returned to Patient profile summary page + And Click Events tab on Patient Profile Page + And I click on the stored Investigation ID in the Events tab + Then the stored morbidity report should be associated with the investigation + + Scenario: Mark morbidity report as reviewed + When user clicks on the "Add morbidity report" button within the Events tab + And I select "Botulism, foodborne" from the Condition dropdown menu + And I select "Cobb County" from the Jurisdiction dropdown menu + And I enter the current date in the Date of Morbidity Report field + And I enter "2" in the Facility and Provider Information field + And I click on the Code Lookup button + And I select "No" from the Pregnant dropdown menu + And I click the Submit button + And Click Events tab on Patient Profile Page + And I click on the first morbidity report link in the Events tab and store its Event ID + And I click the Mark as Reviewed button on the Morbidity Report page + And user clicks the "View File" link, the user is returned to Patient profile summary page + Then the stored morbidity report ID should not appear in the Documents Requiring Review section + + @skip-broken + # Unsure how to handle the popup for the Mark as Reviewed button, so skipping this test for now + Scenario: Mark morbidity report as reviewed - STD + When user clicks on the "Add morbidity report" button within the Events tab + And I select "AIDS" from the Condition dropdown menu + And I select "Cobb County" from the Jurisdiction dropdown menu + And I enter the current date in the Date of Morbidity Report field + And I enter "2" in the Facility and Provider Information field + And I click on the Code Lookup button + And I select "No" from the Pregnant dropdown menu + And I click the Submit button + And Click Events tab on Patient Profile Page + And I click on the first morbidity report link in the Events tab and store its Event ID + And I click the Mark as Reviewed button on the Morbidity Report page and handle the popup + + Scenario: Delete morbidity report + When user clicks on the "Add morbidity report" button within the Events tab + And I select "Botulism, foodborne" from the Condition dropdown menu + And I select "Cobb County" from the Jurisdiction dropdown menu + And I enter the current date in the Date of Morbidity Report field + And I enter "2" in the Facility and Provider Information field + And I click on the Code Lookup button + And I select "No" from the Pregnant dropdown menu + And I click the Submit button + And Click Events tab on Patient Profile Page + And I click on the first morbidity report link in the Events tab and store its Event ID + And I click the delete button on the Morbidity Report page + Then the stored morbidity report ID should not appear in the Morbidity Reports section of the Events tab \ No newline at end of file diff --git a/testing/regression/cypress/e2e/pages/eventsTab.page.js b/testing/regression/cypress/e2e/pages/eventsTab.page.js index cf8eb62622..ce4a059378 100644 --- a/testing/regression/cypress/e2e/pages/eventsTab.page.js +++ b/testing/regression/cypress/e2e/pages/eventsTab.page.js @@ -1,4 +1,57 @@ class EventsTabPage { + // Constants + static SPINNER_SELECTOR = '._indicator_1vvtd_1'; + static COUNT_BADGE_SELECTOR = '._title_r9t1e_16 ._default_rfc4h_1._small_rfc4h_64._regular_rfc4h_76'; + static MORBIDITY_TABLE_SELECTOR = '#morbidity-reports-table tbody tr'; + static TREATMENT_COLUMN = 6; + static JURISDICTION_COLUMN = 7; + static ASSOCIATED_COLUMN = 8; + + reportTypeIndexMap = { + "Investigations": 0, + "Lab reports": 1, + "Morbidity reports": 2, + "Vaccinations": 3, + "Birth records": 4, + "Treatments": 5, + "Documents": 6, + "Contacts named by patient": 7, + "Patient named by contacts": 8, + }; + + waitForSpinner(timeout = 10000) { + cy.get(EventsTabPage.SPINNER_SELECTOR, { timeout }) + .should('not.exist'); + } + + getCountBadge(reportIndex) { + return cy.get(EventsTabPage.COUNT_BADGE_SELECTOR).eq(reportIndex); + } + + extractAndStoreEventId($link) { + const eventId = $link.text().trim(); + Cypress.env('morbidityEventId', eventId); + cy.log('Stored morbidity event ID: ' + eventId); + return eventId; + } + + findRowByEventId(eventId) { + return cy.get(EventsTabPage.MORBIDITY_TABLE_SELECTOR) + .filter((index, row) => { + return Cypress.$(row).find('td:first-child a').text().trim() === eventId; + }) + .should('have.length', 1, 'Should find exactly one row with Event ID: ' + eventId); + } + + getTreatmentCount($td) { + const $list = $td.find('ul._treatments_t5nhh_1 li'); + return $list.length || 0; + } + + clickLink($link) { + cy.wrap($link).click(); + } + get table() { return "section"; } @@ -15,7 +68,6 @@ class EventsTabPage { .eq(conditionColumnIndex) .invoke('text') .then(text => { - if (text.includes(conditionText)) { cy.wrap($row) .find("input") @@ -23,29 +75,253 @@ class EventsTabPage { } }); }); -} + } validateTableColumns(tableName, dataTable) { const myArray = []; cy.contains("section", tableName).within(() => { cy.get("th") - .then((headerElements) => { - const headers = Cypress.$.map(headerElements, (headerElement) => { - return Cypress.$(headerElement).text().trim(); - }).filter(Boolean); - dataTable.rawTable.forEach((row) => { - const label = row[0]; - if ((label == "Investigation #") & (tableName === "Investigations")) { - myArray.push(""); - } - myArray.push(label); + .then((headerElements) => { + const headers = Cypress.$.map(headerElements, (headerElement) => { + return Cypress.$(headerElement).text().trim(); + }).filter(Boolean); + + dataTable.rawTable.forEach((row) => { + const label = row[0]; + if ((label == "Investigation #") & (tableName === "Investigations")) { + myArray.push(""); + } + myArray.push(label); + }); + + console.log("myArray", myArray); + console.log("headers", headers); + expect(headers).to.deep.equal(myArray); }); - console.log("myArray", myArray); - console.log("headers", headers); - expect(headers).to.deep.equal(myArray); + }); + } + + clickAddButton(buttonValue) { + cy.get('button').contains(buttonValue).click(); + } + + getReportCount(ReportType) { + const reportIndex = this.reportTypeIndexMap[ReportType]; + this.waitForSpinner(); + + this.getCountBadge(reportIndex) + .invoke('text') + .then(text => { + const count = parseInt(text.trim()); + Cypress.env(ReportType.trim() + 'Count', count); + cy.log('Saved ' + ReportType + ' count: ' + count); + }); + } + + verifyReportCountIncreased(ReportType) { + const reportIndex = this.reportTypeIndexMap[ReportType]; + this.waitForSpinner(); + + const initialCount = Cypress.env(ReportType.trim() + 'Count'); + + this.getCountBadge(reportIndex) + .invoke('text') + .then(text => { + const newCount = parseInt(text.trim(), 10); + cy.log(ReportType + ' - Initial: ' + initialCount + ', New: ' + newCount); + expect(newCount, ReportType + ' count should increase by 1') + .to.equal(initialCount + 1); + }); + } + + verifyReportCountUnchanged(ReportType) { + const reportIndex = this.reportTypeIndexMap[ReportType]; + this.waitForSpinner(); + + const initialCount = Cypress.env(ReportType.trim() + 'Count'); + + this.getCountBadge(reportIndex) + .invoke('text') + .then(text => { + const newCount = parseInt(text.trim(), 10); + cy.log(ReportType + ' - Initial: ' + initialCount + ', New: ' + newCount); + expect(newCount, ReportType + ' count should remain the same') + .to.equal(initialCount); + }); + } + + saveInitialTreatmentCount() { + this.waitForSpinner(); + + cy.get(EventsTabPage.MORBIDITY_TABLE_SELECTOR) + .first() + .find('td:nth-child(' + EventsTabPage.TREATMENT_COLUMN + ')') + .then($td => { + const count = this.getTreatmentCount($td); + Cypress.env('initialTreatmentCount', count); + cy.log('Initial treatment count in first morbidity report: ' + count); + }); + } + + verifyTreatmentCountIncreased() { + this.waitForSpinner(); + + const initialCount = Cypress.env('initialTreatmentCount'); + const eventId = Cypress.env('morbidityEventId'); + + cy.log('Looking for morbidity report with Event ID: ' + eventId); + + this.findRowByEventId(eventId) + .find('td:nth-child(' + EventsTabPage.TREATMENT_COLUMN + ')') + .find('ul._treatments_t5nhh_1 li') + .its('length') + .then(newCount => { + cy.log('Initial treatment count: ' + initialCount + ', New count: ' + newCount); + expect(newCount, 'Treatment count for ' + eventId + ' should increase by 1') + .to.equal(initialCount + 1); + }); + } + + clickFirstMorbidityReportLinkStoreEventID() { + this.waitForSpinner(); + + cy.get(EventsTabPage.MORBIDITY_TABLE_SELECTOR) + .first() + .scrollIntoView() + .should('be.visible') + .within(() => { + cy.get('td:first-child a') + .scrollIntoView() + .should('be.visible') + .then($link => { + this.extractAndStoreEventId($link); + this.clickLink($link); + }); + }); + } + + clickStoredMorbidityReport() { + this.waitForSpinner(); + + const eventId = Cypress.env('morbidityEventId'); + + cy.log('Looking for morbidity report with Event ID: ' + eventId); + + this.findRowByEventId(eventId) + .find('td:first-child a') + .scrollIntoView() + .should('be.visible') + .click(); + } + + + verifySavedMorbidityReportJurisdiction(expectedJurisdiction) { + this.waitForSpinner(); + + const eventId = Cypress.env('morbidityEventId'); + + cy.log('Looking for morbidity report with Event ID: ' + eventId); + + this.findRowByEventId(eventId) + .find('td:nth-child(' + EventsTabPage.JURISDICTION_COLUMN + ')') + .should('be.visible') + .invoke('text') + .then(text => { + const actualJurisdiction = text.trim(); + cy.log('Jurisdiction for ' + eventId + ': "' + actualJurisdiction + '" (expected: "' + expectedJurisdiction + '")'); + expect(actualJurisdiction).to.equal(expectedJurisdiction); }); - }) } + + verifyStoredMorbidityReportHasAssociation() { + this.waitForSpinner(); + + const eventId = Cypress.env('morbidityEventId'); + + expect(eventId, 'Morbidity event ID should exist').to.not.be.empty; + + cy.log('Looking for morbidity report with Event ID: ' + eventId); + + this.findRowByEventId(eventId) + .find('td:nth-child(' + EventsTabPage.ASSOCIATED_COLUMN + ')') + .should('be.visible') + .invoke('text') + .then(text => { + const associatedText = text.trim(); + cy.log('Associated with for ' + eventId + ': "' + associatedText + '"'); + expect(associatedText, 'Associated with should have an investigation ID') + .to.match(/CAS\d+/); + }); + } + + clickStoredInvestigationId() { + // Get the stored investigation ID + const investigationId = Cypress.env('investigationId'); + + // Wait for page to load + cy.get('._indicator_1vvtd_1', { timeout: 10000 }) + .should('not.exist'); + + // Find and click the investigation link in the Investigations table + cy.get('#investigations-table tbody tr') + .contains('td a', investigationId) + .should('be.visible') + .click(); + } + + clickFirstUnassociatedMorbidityReport() { + this.waitForSpinner(); + + cy.get(EventsTabPage.MORBIDITY_TABLE_SELECTOR) + .filter((index, row) => { + const associatedText = Cypress.$(row) + .find('td:nth-child(' + EventsTabPage.ASSOCIATED_COLUMN + ')') + .text() + .trim(); + return associatedText === '---'; + }) + .first() + .scrollIntoView() + .should('be.visible') + .within(() => { + cy.get('td:first-child a') + .scrollIntoView() + .should('be.visible') + .then($link => { + this.extractAndStoreEventId($link); + this.clickLink($link); + }); + }); + } + + verifyMorbidityEventIdNotInMorbidityReports() { + // Wait for page to load + cy.get('._indicator_1vvtd_1', { timeout: 10000 }) + .should('not.exist'); + + const eventId = Cypress.env('morbidityEventId'); + // Check the Morbidity Reports table + cy.get('#morbidity-reports-table') + .should('be.visible') + .within(() => { + // Check all Event ID links (first column) + cy.get('tbody tr td:first-child a') + .then($links => { + let found = false; + $links.each((index, link) => { + const linkText = Cypress.$(link).text().trim(); + if (linkText === eventId) { + found = true; + } + }); + + expect(found, 'Morbidity event ID should NOT appear in Morbidity Reports table') + .to.be.false; + + }); + }); + } + } -export default new EventsTabPage(); +export default new EventsTabPage(); \ No newline at end of file diff --git a/testing/regression/cypress/e2e/pages/nbs-classic/morbidityReportPage.js b/testing/regression/cypress/e2e/pages/nbs-classic/morbidityReportPage.js index 8a16059014..4500231bc4 100644 --- a/testing/regression/cypress/e2e/pages/nbs-classic/morbidityReportPage.js +++ b/testing/regression/cypress/e2e/pages/nbs-classic/morbidityReportPage.js @@ -3,13 +3,26 @@ class MorbidityReportPage { patientTab = "font.boldNineYellow"; reportInformationTab = "font.boldNineYellow"; conditionField = 'input[name="conditionCd_textbox"]'; - jurisdictionField = - 'input[name="morbidityReport.theObservationDT.jurisdictionCd_textbox"]'; + jurisdictionField = 'select[fieldlabel="Jurisdiction"]'; morbidityDateField = "#morbidityReport\\.theObservationDT\\.activityToTime_s"; + treatmentDateField = '#treatment_s\\[i\\]\\.treatmentVO_s\\[0\\]\\.treatmentAdministeredDT_s\\[0\\]\\.effectiveFromTime_s'; + treatmentDropdown = 'select[fieldlabel="Treatment"][validate="required"]'; + addTreatmentButton = 'input#BatchEntryAddButtonTreatment[value="Add Treatment"]'; facilityProviderField = 'input[name="entity-codeLookupText-Org-ReportingOrganizationUID"]'; codeLookupButton = 'input[value="Code Lookup"]'; + pregnantDropdown = 'select[fieldlabel="Is Patient Pregnant"][validate="pregnantMale"]'; submitButton = "#Submit"; + submitAndCreateInvestigationButton = 'input[type="image"][name="Submit and Create Investigation"]'; + cancelButton = "#Cancel"; + editButton = '#Edit'; + printButton = "#Print"; + deleteButton = "#Delete"; + transferOwnershipButton = "input[id='Transfer Ownership']"; + createInvestigationButton = "input[id='Create Investigation']"; + associateInvestigationButton = "input[id='Associate Investigation']"; + markAsReviewedButton = "input[id='Mark as Reviewed']"; + conditionCode = "#conditionCd"; // Patient entry fields patientLastNameField = "#entity\\.lastNm"; @@ -38,11 +51,40 @@ class MorbidityReportPage { } selectJurisdiction(jurisdiction) { - cy.get(this.jurisdictionField).type(jurisdiction).type("{enter}"); + cy.get(this.jurisdictionField).select(jurisdiction, {force: true}); + } + + storeCondition() { + cy.get(this.conditionCode) + .invoke('text') + .then(condition => { + Cypress.env('morbidityCondition', condition); + cy.log('Stored morbidity condition: ' + condition); + }); + } + + checkFirstInvestigationWithCondition(condition) { + // Find the first row with the matching condition + cy.get('table.dtTable tbody tr') + .filter((index, row) => { + // Find the condition column (4th column, index 3) + const conditionText = Cypress.$(row).find('td:nth-child(4)').text().trim(); + return conditionText === condition; + }) + .first() + .scrollIntoView() + .should('be.visible') + .within(() => { + // Find and check the checkbox in the first column + cy.get('td:first-child input[type="checkbox"]') + .should('exist') + .and('be.visible') + .check({ force: true }); + }); } clearJurisdiction() { - cy.get(this.jurisdictionField).clear(); + cy.get(this.jurisdictionField).select("", { force: true }); } enterMorbidityDate(date) { @@ -54,10 +96,31 @@ class MorbidityReportPage { cy.get(this.morbidityDateField).type(formattedDate); } + enterTreatmentDate(date) { + const [month, day, year] = date.split("/"); + const formattedDate = `${month.padStart(2, "0")}${day.padStart( + 2, + "0" + )}${year}`; + cy.get(this.treatmentDateField).type(formattedDate); + } + enterFacilityProvider(value) { cy.get(this.facilityProviderField).type(value); } + selectPregnant(value) { + cy.get(this.pregnantDropdown).select(value, { force: true }); + } + + selectTreatment(value) { + cy.get(this.treatmentDropdown).select(value, { force: true }); + } + + clickAddTreatment() { + cy.get(this.addTreatmentButton).click(); + } + clickCodeLookup() { cy.get(this.codeLookupButton).first().click(); } @@ -66,8 +129,102 @@ class MorbidityReportPage { cy.get(this.submitButton).click(); } + clickCancel() { + cy.get(this.cancelButton).click(); + } + + clickEdit() { + cy.get(this.editButton).click(); + } + + clickMarkAsReviewed() { + cy.get(this.markAsReviewedButton).first().click(); + } + + clickAndVerifyPrint() { + let printURL = '/nbs/LoadViewObservationMorb1.do?ContextAction=PrintPage'; + cy.window().then(win => { + cy.stub(win, 'open').as('open') + }); + cy.get(this.printButton).click(); + cy.get("@open").should("have.been.calledWith", printURL); + cy.request(printURL, { method: 'GET' }).then((response) => { + const contentType = response.headers['content-type']; + expect(contentType).to.include('application/pdf'); + }); + } + + clickTransferOwnership() { + cy.get(this.transferOwnershipButton).first().click(); + } + + clickCreateInvestigation() { + cy.get(this.createInvestigationButton).first().click(); + } + + clickAssociateInvestigation() { + cy.get(this.associateInvestigationButton).first().click(); + } + + clickSubmitAndCreateInvestigation() { + cy.get(this.submitAndCreateInvestigationButton).eq(0).click(); + } + + clickDelete() { + cy.get(this.deleteButton).first().click(); + } + confirmSubmission() { cy.on("window:confirm", () => true); // Automatically confirm the popup + // small buffer + cy.wait(500); + } + + storeInvestigationIdFromAssociationMessage() { + // Wait for the success message to appear + cy.get('#error1', { timeout: 10000 }) + .should('be.visible') + .invoke('text') + .then(text => { + // Extract the Investigation ID from parentheses + // Example: "Morbidity Report successfully associated to investigation: Botulism, foodborne (CAS10001000GA01)" + const match = text.match(/\(([^)]+)\)/); + + if (match && match[1]) { + const investigationId = match[1].trim(); + Cypress.env('investigationId', investigationId); + cy.log('Stored Investigation ID: ' + investigationId); + } else { + cy.log('No Investigation ID found in parentheses'); + throw new Error('Could not extract Investigation ID from: ' + text); + } + }); + } + + clickMarkAsReviewedAndHandlePopup() { + // Wait for page to load + cy.get('._indicator_1vvtd_1', { timeout: 10000 }) + .should('not.exist'); + + // Intercept the window.open call for the Mark as Reviewed popup + cy.window().then(win => { + const originalOpen = win.open; + cy.stub(win, 'open').callsFake((url, target, features) => { + cy.log('Mark as Reviewed popup URL intercepted: ' + url); + + // Instead of opening a new window, navigate to the URL in the same window + // This effectively "stubs" the popup and loads it on the same page + cy.visit(url); + win.markAsReviewed(); // Call the function to mark as reviewed + + }); + }); + + // Click the Mark as Reviewed button + cy.get('#Mark\\ as\\ Reviewed') + .should('be.visible') + .first() + .click(); } // Patient entry methods @@ -125,4 +282,5 @@ class MorbidityReportPage { cy.get("body").should("be.visible"); } } + export const morbidityReportPage = new MorbidityReportPage(); diff --git a/testing/regression/cypress/e2e/pages/nbs-classic/openInvestigation.page.js b/testing/regression/cypress/e2e/pages/nbs-classic/openInvestigation.page.js index e8d7d04d4c..207cd0fde4 100644 --- a/testing/regression/cypress/e2e/pages/nbs-classic/openInvestigation.page.js +++ b/testing/regression/cypress/e2e/pages/nbs-classic/openInvestigation.page.js @@ -187,7 +187,20 @@ class OpenInvestigationPage { clickSubmitBtnInCreateNotificationPage() { cy.get('#topcreatenotId input[type="button"][value="Submit"]').eq(0).click({ force: true }) } - } + + verifyMorbidityReportAssociation() { + const eventId = Cypress.env('morbidityEventId'); + cy.log('event ID is {}', eventId); + + // Find the second table in the Botulism tab (the Morbidity Reports table) + cy.get('#tabControlN108A0') + .find('table.TableInner') + .eq(1) // Second table (index 1) + .contains(eventId) + .should('exist') + } + +} export const openInvestigationPage = new OpenInvestigationPage(); \ No newline at end of file diff --git a/testing/regression/cypress/e2e/pages/patientProfile.page.js b/testing/regression/cypress/e2e/pages/patientProfile.page.js index 9231969591..bf8d4836ba 100644 --- a/testing/regression/cypress/e2e/pages/patientProfile.page.js +++ b/testing/regression/cypress/e2e/pages/patientProfile.page.js @@ -276,6 +276,58 @@ class PatientProfilePage { cy.get("img[name='INV107_button']").type('Cobb County'); cy.get("#SubmitTop").click(); } + + verifyMorbidityEventIdNotInDocumentsRequiringReview() { + // Wait for page to load + cy.get('._indicator_1vvtd_1', { timeout: 10000 }) + .should('not.exist'); + + const eventId = Cypress.env('morbidityEventId'); + + // Check if the Documents Requiring Review section exists + cy.get('body').then($body => { + const $table = $body.find('#documents-requiring-review-table'); + + if ($table.length === 0) { + // Table doesn't exist - pass + return; + } + + // Check if the table is visible or hidden + const isVisible = $table.is(':visible'); + + if (!isVisible) { + + const tableText = $table.text().trim(); + + if (tableText === '') { + // Table is empty - pass + return; + } + + // Table has data, check for the event ID + expect(tableText, 'Morbidity event ID should NOT appear in Documents Requiring Review') + .to.not.include(eventId); + return; + } + + // Table is visible, check its content + const tableText = $table.text().trim(); + + if (tableText === '' || tableText.includes('No data has been added')) { + // Table is empty - pass + cy.log('Documents Requiring Review table is empty - no documents to review'); + cy.log('Verified morbidity event ID is NOT in Documents Requiring Review: ' + eventId); + return; + } + + // Table has data, check for the event ID + expect(tableText, 'Morbidity event ID should NOT appear in Documents Requiring Review') + .to.not.include(eventId); + + }); + } + } export default new PatientProfilePage(); diff --git a/testing/regression/cypress/step_definitions/nbs-classic/dataEntry.steps.js b/testing/regression/cypress/step_definitions/nbs-classic/dataEntry.steps.js index 5922947606..28c57eb9bd 100644 --- a/testing/regression/cypress/step_definitions/nbs-classic/dataEntry.steps.js +++ b/testing/regression/cypress/step_definitions/nbs-classic/dataEntry.steps.js @@ -73,6 +73,14 @@ When("I click the submit button", () => { clickSubmitButton(); }); +When("I click the Cancel button on the Morbidity Report page", () => { + morbidityReportPage.clickCancel(); +}); + +When("I click the Submit and Create Investigation button", () => { + morbidityReportPage.clickSubmitAndCreateInvestigation(); +}); + When("I click on the Morbidity Report link", () => { morbidityReportPage.clickMorbidityReport(); }); @@ -105,6 +113,10 @@ When("I enter the current date in the Date of Morbidity Report field", () => { morbidityReportPage.enterMorbidityDate(today); }); +When("I select {string} from the Pregnant dropdown menu", (value) => { + morbidityReportPage.selectPregnant(value); +}); + When( "I enter {string} in the Facility and Provider Information field", (value) => { @@ -207,6 +219,63 @@ When("I enter patient first name {string} and last name {string}", (firstName, l morbidityReportPage.enterPatientBothNames(firstName, lastName); }); +When("I click the Edit button on the Morbidity Report page", () => { + morbidityReportPage.clickEdit(); +}); + +Then("clicking the Print button should display the print preview", () => { + morbidityReportPage.clickAndVerifyPrint(); +}); + +When("I enter the current date in the Treatment Date field", () => { + const today = new Date().toLocaleDateString("en-US"); + morbidityReportPage.enterTreatmentDate(today); +}); + +When("I select {string} from the Treatment dropdown menu", (treatment) => { + morbidityReportPage.selectTreatment(treatment); +}); + +When("I click the Add Treatment button", () => { + morbidityReportPage.clickAddTreatment(); +}); + +When("I click the Transfer Ownership button on the Morbidity Report page", () => { + morbidityReportPage.clickTransferOwnership(); +}); + +When("I click the Create Investigation button on the Morbidity Report page", () => { + morbidityReportPage.clickCreateInvestigation(); +}); + +When("I click the Associate Investigation button on the Morbidity Report page", () => { + morbidityReportPage.clickAssociateInvestigation(); +}); + +When("I store the morbidity report's condition", () => { + morbidityReportPage.storeCondition(); +}); + +When("I check an investigation with the condition {string}", (condition) => { + morbidityReportPage.checkFirstInvestigationWithCondition(condition); +}); + +When("I store the Investigation ID from the association message", () => { + morbidityReportPage.storeInvestigationIdFromAssociationMessage(); +}); + +When("I click the Mark as Reviewed button on the Morbidity Report page", () => { + morbidityReportPage.clickMarkAsReviewed(); +}); + +When("I click the Mark as Reviewed button on the Morbidity Report page and handle the popup", () => { + morbidityReportPage.clickMarkAsReviewedAndHandlePopup(); +}); + +When("I click the delete button on the Morbidity Report page", () => { + morbidityReportPage.clickDelete(); +}); + // 6: Verification Steps When("I go to the Home page", () => { diff --git a/testing/regression/cypress/step_definitions/nbs-classic/openInvestigation.steps.js b/testing/regression/cypress/step_definitions/nbs-classic/openInvestigation.steps.js index 86c4b1861c..5afcdf028b 100644 --- a/testing/regression/cypress/step_definitions/nbs-classic/openInvestigation.steps.js +++ b/testing/regression/cypress/step_definitions/nbs-classic/openInvestigation.steps.js @@ -155,3 +155,7 @@ Then('Click Create Notifications button from top action button group', () => { Then('Click Submit button in newly opened window Create Notification Page', () => { openInvestigationPage.clickSubmitBtnInCreateNotificationPage(); }); + +Then("the stored morbidity report should be associated with the investigation", () => { + openInvestigationPage.verifyMorbidityReportAssociation(); +}); diff --git a/testing/regression/cypress/step_definitions/patient.profile.step.js b/testing/regression/cypress/step_definitions/patient.profile.step.js index a58b42253e..793e475b63 100644 --- a/testing/regression/cypress/step_definitions/patient.profile.step.js +++ b/testing/regression/cypress/step_definitions/patient.profile.step.js @@ -1,5 +1,6 @@ import { Given, When, Then } from "@badeball/cypress-cucumber-preprocessor"; import PatientProfilePage from "cypress/e2e/pages/patientProfile.page"; +import eventsTabPage from "cypress/e2e/pages/eventsTab.page"; Then("I explor the patient profile", () => { PatientProfilePage.navigatePatinet() @@ -31,4 +32,56 @@ Then("I add invstigation - Amebiassis of patient", () => { Then("I add invstigation - Anaplasma phagocytophilum of patient", () => { PatientProfilePage.addPatientInvestigations_AnaplasmaPhagocytophilum() +}); + +When("user clicks on the {string} button within the Events tab", (buttonValue) => { + eventsTabPage.clickAddButton(buttonValue); +}); + +When("I check the current count of {string} in the Events tab", (reportType) => { + eventsTabPage.getReportCount(reportType); +}); + +Then("the {string} count should increase by 1 in the Events tab", (reportType) => { + eventsTabPage.verifyReportCountIncreased(reportType); +}); + +Then("the {string} count should remain the same in the Events tab", (reportType) => { + eventsTabPage.verifyReportCountUnchanged(reportType); +}); + +When("I click on the first morbidity report link in the Events tab and store its Event ID", () => { + eventsTabPage.clickFirstMorbidityReportLinkStoreEventID(); +}); + +When("I count the number of treatments in the first morbidity report", () => { + eventsTabPage.saveInitialTreatmentCount(); +}); + +Then("the treatment count should increase by 1 in the stored morbidity report", () => { + eventsTabPage.verifyTreatmentCountIncreased(); +}); + +Then("the saved morbidity report should have jurisdiction {string}", (expectedJurisdiction) => { + eventsTabPage.verifySavedMorbidityReportJurisdiction(expectedJurisdiction); +}); + +Then("the saved morbidity report should be associated with an investigation", () => { + eventsTabPage.verifyStoredMorbidityReportHasAssociation(); +}); + +When("I click on the stored Investigation ID in the Events tab", () => { + eventsTabPage.clickStoredInvestigationId(); +}); + +When("I click on the first unassociated morbidity report link in the Events tab and store its Event ID", () => { + eventsTabPage.clickFirstUnassociatedMorbidityReport(); +}); + +Then("the stored morbidity report ID should not appear in the Documents Requiring Review section", () => { + PatientProfilePage.verifyMorbidityEventIdNotInDocumentsRequiringReview(); +}); + +Then("the stored morbidity report ID should not appear in the Morbidity Reports section of the Events tab", () => { + eventsTabPage.verifyMorbidityEventIdNotInMorbidityReports(); }); \ No newline at end of file