From dd4e28f8b768696f28ab6106b030b1392e532809 Mon Sep 17 00:00:00 2001 From: fazilqa <127263470+fazilqa@users.noreply.github.com> Date: Mon, 23 Dec 2024 13:20:49 -0800 Subject: [PATCH] 65012 custom date advanced search (#33734) * create spec file * add tests * parametrize methods * add error validation and clear filter tests * update constants * add search results test * add more error tests * update advanced-filter tests * add custom date range filter tests for other folders * add axeCheck --- .../tests/e2e/pages/PatientSearchPage.js | 106 +++++++++++++++- ...-custom-date-custom-folder.cypress.spec.js | 117 ++++++++++++++++++ ...-filter-custom-date-drafts.cypress.spec.js | 116 +++++++++++++++++ ...d-filter-custom-date-inbox.cypress.spec.js | 113 +++++++++++++++++ ...ed-filter-custom-date-sent.cypress.spec.js | 117 ++++++++++++++++++ ...d-filter-custom-date-trash.cypress.spec.js | 116 +++++++++++++++++ ...nced-filter-custom-folder.cypress.spec.js} | 8 ++ ...ng-advanced-filter-drafts.cypress.spec.js} | 12 ++ ...ing-advanced-filter-inbox.cypress.spec.js} | 14 ++- ...ging-advanced-filter-sent.cypress.spec.js} | 8 ++ ...ing-advanced-filter-trash.cypress.spec.js} | 8 ++ .../tests/e2e/utils/constants.js | 8 ++ 12 files changed, 737 insertions(+), 6 deletions(-) create mode 100644 src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-custom-folder.cypress.spec.js create mode 100644 src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-drafts.cypress.spec.js create mode 100644 src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-inbox.cypress.spec.js create mode 100644 src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-sent.cypress.spec.js create mode 100644 src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-trash.cypress.spec.js rename src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/{secure-messaging-advanced-search-custom-folder.cypress.spec.js => secure-messaging-advanced-filter-custom-folder.cypress.spec.js} (94%) rename src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/{secure-messaging-advanced-search-drafts.cypress.spec.js => secure-messaging-advanced-filter-drafts.cypress.spec.js} (90%) rename src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/{secure-messaging-advanced-search-inbox.cypress.spec.js => secure-messaging-advanced-filter-inbox.cypress.spec.js} (89%) rename src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/{secure-messaging-advanced-search-sent.cypress.spec.js => secure-messaging-advanced-filter-sent.cypress.spec.js} (93%) rename src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/{secure-messaging-advanced-search-trash.cypress.spec.js => secure-messaging-advanced-filter-trash.cypress.spec.js} (93%) diff --git a/src/applications/mhv-secure-messaging/tests/e2e/pages/PatientSearchPage.js b/src/applications/mhv-secure-messaging/tests/e2e/pages/PatientSearchPage.js index 0bff7d893ac2..c5f753a671c6 100644 --- a/src/applications/mhv-secure-messaging/tests/e2e/pages/PatientSearchPage.js +++ b/src/applications/mhv-secure-messaging/tests/e2e/pages/PatientSearchPage.js @@ -137,15 +137,113 @@ class PatientSearchPage { const extractedDate = dateString.split(' at ')[0]; // "November 29, 2024" const parsedDate = new Date(extractedDate); - // calculate three months back from the current date - const threeMonthsBack = new Date(); - threeMonthsBack.setMonth(threeMonthsBack.getMonth() - numberOfMonth); + // calculate a few months back from the current date + const backDate = new Date(); + backDate.setMonth(backDate.getMonth() - numberOfMonth); // assert the date is within the last 3 months - expect(parsedDate).to.be.gte(threeMonthsBack); + expect(parsedDate).to.be.gte(backDate); }); }); }; + + verifyStartDateFormElements = () => { + cy.get(Locators.BLOCKS.FILTER_START_DATE, { includeShadowDom: true }) + .find(`.required`) + .should(`be.visible`) + .and(`have.text`, `(*Required)`); + + cy.get(Locators.BLOCKS.FILTER_START_DATE) + .shadow() + .find(`.select-month`) + .should(`be.visible`); + cy.get(Locators.BLOCKS.FILTER_START_DATE) + .shadow() + .find(`.select-day`) + .should(`be.visible`); + cy.get(Locators.BLOCKS.FILTER_START_DATE) + .shadow() + .find(`.input-year`) + .should(`be.visible`); + }; + + verifyEndDateFormElements = () => { + cy.get(Locators.BLOCKS.FILTER_END_DATE, { includeShadowDom: true }) + .find(`.required`) + .should(`be.visible`) + .and(`have.text`, `(*Required)`); + + cy.get(Locators.BLOCKS.FILTER_END_DATE) + .shadow() + .find(`.select-month`) + .should(`be.visible`); + cy.get(Locators.BLOCKS.FILTER_END_DATE) + .shadow() + .find(`.select-day`) + .should(`be.visible`); + cy.get(Locators.BLOCKS.FILTER_END_DATE) + .shadow() + .find(`.input-year`) + .should(`be.visible`); + }; + + verifyMonthFilterRange = number => { + cy.get(Locators.BLOCKS.FILTER_START_DATE) + .find(`[name="discharge-dateMonth"]`) + .find(`option`) + .should(`have.length`, number); + }; + + verifyDayFilterRange = number => { + cy.get(Locators.BLOCKS.FILTER_START_DATE) + .find(`[name="discharge-dateDay"]`) + .find(`option`) + .should(`have.length`, number); + }; + + selectStartMonth = month => { + cy.get(Locators.BLOCKS.FILTER_START_DATE) + .find(`[name="discharge-dateMonth"]`) + .select(month); + }; + + selectEndMonth = month => { + cy.get(Locators.BLOCKS.FILTER_END_DATE) + .find(`[name="discharge-dateMonth"]`) + .select(month); + }; + + selectStartDay = day => { + cy.get(Locators.BLOCKS.FILTER_START_DATE) + .find(`[name="discharge-dateDay"]`) + .select(day); + }; + + selectEndDay = day => { + cy.get(Locators.BLOCKS.FILTER_END_DATE) + .find(`[name="discharge-dateDay"]`) + .select(day); + }; + + getStartYear = year => { + cy.get(Locators.BLOCKS.FILTER_START_DATE) + .find(`[name="discharge-dateYear"]`) + .type(year); + }; + + getEndYear = year => { + cy.get(Locators.BLOCKS.FILTER_END_DATE) + .find(`[name="discharge-dateYear"]`) + .type(year); + }; + + getRequiredFieldError = selector => { + return cy + .get(selector) + .find(`#error-message`) + .should(`be.visible`); + }; + // retrieveMessages = function (folderID) { // folderInfo.data.attributes.folderId = folderID; // cy.intercept( diff --git a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-custom-folder.cypress.spec.js b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-custom-folder.cypress.spec.js new file mode 100644 index 000000000000..81d93ee075fc --- /dev/null +++ b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-custom-folder.cypress.spec.js @@ -0,0 +1,117 @@ +import { format, subMonths } from 'date-fns'; +import SecureMessagingSite from '../sm_site/SecureMessagingSite'; +import PatientInboxPage from '../pages/PatientInboxPage'; +import { AXE_CONTEXT, Locators, Alerts } from '../utils/constants'; +import PatientSearchPage from '../pages/PatientSearchPage'; +import FolderLoadPage from '../pages/FolderLoadPage'; +import PatientMessageCustomFolderPage from '../pages/PatientMessageCustomFolderPage'; + +describe('SM INBOX ADVANCED CUSTOM DATE RANGE SEARCH', () => { + beforeEach(() => { + SecureMessagingSite.login(); + PatientInboxPage.loadInboxMessages(); + FolderLoadPage.loadFolders(); + PatientMessageCustomFolderPage.loadMessages(); + PatientInboxPage.openAdvancedSearch(); + PatientInboxPage.selectDateRange('Custom'); + }); + + it('verify advanced filter form elements', () => { + PatientSearchPage.verifyStartDateFormElements(); + PatientSearchPage.verifyEndDateFormElements(); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify month and day range', () => { + PatientSearchPage.verifyMonthFilterRange(14); + PatientSearchPage.verifyDayFilterRange(2); + + PatientSearchPage.selectStartMonth(`February`); + PatientSearchPage.verifyDayFilterRange(31); + + PatientSearchPage.selectStartMonth(`June`); + PatientSearchPage.verifyDayFilterRange(32); + + PatientSearchPage.selectStartMonth(`October`); + PatientSearchPage.verifyDayFilterRange(33); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it(`verify errors`, () => { + cy.get(Locators.BUTTONS.FILTER).click(); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_START_DATE, + ).should(`have.text`, Alerts.DATE_FILTER.EMPTY_START_DATE); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_END_DATE, + ).should(`have.text`, Alerts.DATE_FILTER.EMPTY_END_DATE); + + PatientSearchPage.selectStartMonth('April'); + PatientSearchPage.selectEndMonth('February'); + cy.get(Locators.BUTTONS.FILTER).click(); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_START_DATE, + ).should(`include.text`, Alerts.DATE_FILTER.INVALID_START_DATE); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_END_DATE, + ).should(`include.text`, Alerts.DATE_FILTER.INVALID_END_DATE); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify clear filters button', () => { + PatientSearchPage.selectStartMonth(`February`); + PatientSearchPage.selectStartDay(`2`); + PatientSearchPage.selectEndMonth('April'); + PatientSearchPage.selectEndDay(`11`); + cy.get(Locators.CLEAR_FILTERS).click(); + cy.get(Locators.FIELDS.DATE_RANGE_OPTION).should( + `have.attr`, + `value`, + `any`, + ); + cy.get(Locators.BLOCKS.FILTER_START_DATE).should(`not.exist`); + cy.get(Locators.BLOCKS.FILTER_END_DATE).should(`not.exist`); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify search results', () => { + const searchResultResponse = PatientSearchPage.createDateSearchMockResponse( + 2, + 1, + ); + const currentYear = format(new Date(), 'yyyy'); + const startMonth = format(subMonths(new Date(), 2), 'MMMM'); + const endMonth = format(new Date(), 'MMMM'); + + PatientSearchPage.selectStartMonth(startMonth); + PatientSearchPage.selectStartDay(`1`); + PatientSearchPage.getStartYear(currentYear); + PatientSearchPage.selectEndMonth(endMonth); + PatientSearchPage.selectEndDay(`11`); + PatientSearchPage.getEndYear(currentYear); + + PatientInboxPage.clickFilterMessagesButton(searchResultResponse); + + PatientSearchPage.verifySearchResponseLength(searchResultResponse); + PatientSearchPage.verifyMessageDate(2); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + `${startMonth} 1st ${currentYear} to ${endMonth} 11th ${currentYear}`, + ); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); +}); diff --git a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-drafts.cypress.spec.js b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-drafts.cypress.spec.js new file mode 100644 index 000000000000..7fb2b9028553 --- /dev/null +++ b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-drafts.cypress.spec.js @@ -0,0 +1,116 @@ +import { format, subMonths } from 'date-fns'; +import SecureMessagingSite from '../sm_site/SecureMessagingSite'; +import PatientInboxPage from '../pages/PatientInboxPage'; +import { AXE_CONTEXT, Locators, Alerts } from '../utils/constants'; +import PatientSearchPage from '../pages/PatientSearchPage'; +import FolderLoadPage from '../pages/FolderLoadPage'; + +describe('SM DRAFTS ADVANCED CUSTOM DATE RANGE SEARCH', () => { + beforeEach(() => { + SecureMessagingSite.login(); + PatientInboxPage.loadInboxMessages(); + FolderLoadPage.loadFolders(); + FolderLoadPage.loadDraftMessages(); + PatientInboxPage.openAdvancedSearch(); + PatientInboxPage.selectDateRange('Custom'); + }); + + it('verify advanced filter form elements', () => { + PatientSearchPage.verifyStartDateFormElements(); + PatientSearchPage.verifyEndDateFormElements(); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify month and day range', () => { + PatientSearchPage.verifyMonthFilterRange(14); + PatientSearchPage.verifyDayFilterRange(2); + + PatientSearchPage.selectStartMonth(`February`); + PatientSearchPage.verifyDayFilterRange(31); + + PatientSearchPage.selectStartMonth(`June`); + PatientSearchPage.verifyDayFilterRange(32); + + PatientSearchPage.selectStartMonth(`October`); + PatientSearchPage.verifyDayFilterRange(33); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it(`verify errors`, () => { + cy.get(Locators.BUTTONS.FILTER).click(); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_START_DATE, + ).should(`have.text`, Alerts.DATE_FILTER.EMPTY_START_DATE); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_END_DATE, + ).should(`have.text`, Alerts.DATE_FILTER.EMPTY_END_DATE); + + PatientSearchPage.selectStartMonth('April'); + PatientSearchPage.selectEndMonth('February'); + cy.get(Locators.BUTTONS.FILTER).click(); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_START_DATE, + ).should(`include.text`, Alerts.DATE_FILTER.INVALID_START_DATE); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_END_DATE, + ).should(`include.text`, Alerts.DATE_FILTER.INVALID_END_DATE); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify clear filters button', () => { + PatientSearchPage.selectStartMonth(`February`); + PatientSearchPage.selectStartDay(`2`); + PatientSearchPage.selectEndMonth('April'); + PatientSearchPage.selectEndDay(`11`); + cy.get(Locators.CLEAR_FILTERS).click(); + cy.get(Locators.FIELDS.DATE_RANGE_OPTION).should( + `have.attr`, + `value`, + `any`, + ); + cy.get(Locators.BLOCKS.FILTER_START_DATE).should(`not.exist`); + cy.get(Locators.BLOCKS.FILTER_END_DATE).should(`not.exist`); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify search results', () => { + const searchResultResponse = PatientSearchPage.createDateSearchMockResponse( + 2, + 1, + ); + const currentYear = format(new Date(), 'yyyy'); + const startMonth = format(subMonths(new Date(), 2), 'MMMM'); + const endMonth = format(new Date(), 'MMMM'); + + PatientSearchPage.selectStartMonth(startMonth); + PatientSearchPage.selectStartDay(`1`); + PatientSearchPage.getStartYear(currentYear); + PatientSearchPage.selectEndMonth(endMonth); + PatientSearchPage.selectEndDay(`11`); + PatientSearchPage.getEndYear(currentYear); + + PatientInboxPage.clickFilterMessagesButton(searchResultResponse); + + PatientSearchPage.verifySearchResponseLength(searchResultResponse); + PatientSearchPage.verifyMessageDate(2); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + `${startMonth} 1st ${currentYear} to ${endMonth} 11th ${currentYear}`, + ); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); +}); diff --git a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-inbox.cypress.spec.js b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-inbox.cypress.spec.js new file mode 100644 index 000000000000..5fbcc311ec94 --- /dev/null +++ b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-inbox.cypress.spec.js @@ -0,0 +1,113 @@ +import { format, subMonths } from 'date-fns'; +import SecureMessagingSite from '../sm_site/SecureMessagingSite'; +import PatientInboxPage from '../pages/PatientInboxPage'; +import { AXE_CONTEXT, Locators, Alerts } from '../utils/constants'; +import PatientSearchPage from '../pages/PatientSearchPage'; + +describe('SM INBOX ADVANCED CUSTOM DATE RANGE SEARCH', () => { + beforeEach(() => { + SecureMessagingSite.login(); + PatientInboxPage.loadInboxMessages(); + PatientInboxPage.openAdvancedSearch(); + PatientInboxPage.selectDateRange('Custom'); + }); + + it('verify advanced filter form elements', () => { + PatientSearchPage.verifyStartDateFormElements(); + PatientSearchPage.verifyEndDateFormElements(); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify month and day range', () => { + PatientSearchPage.verifyMonthFilterRange(14); + PatientSearchPage.verifyDayFilterRange(2); + + PatientSearchPage.selectStartMonth(`February`); + PatientSearchPage.verifyDayFilterRange(31); + + PatientSearchPage.selectStartMonth(`June`); + PatientSearchPage.verifyDayFilterRange(32); + + PatientSearchPage.selectStartMonth(`October`); + PatientSearchPage.verifyDayFilterRange(33); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it(`verify errors`, () => { + cy.get(Locators.BUTTONS.FILTER).click(); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_START_DATE, + ).should(`have.text`, Alerts.DATE_FILTER.EMPTY_START_DATE); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_END_DATE, + ).should(`have.text`, Alerts.DATE_FILTER.EMPTY_END_DATE); + + PatientSearchPage.selectStartMonth('April'); + PatientSearchPage.selectEndMonth('February'); + cy.get(Locators.BUTTONS.FILTER).click(); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_START_DATE, + ).should(`include.text`, Alerts.DATE_FILTER.INVALID_START_DATE); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_END_DATE, + ).should(`include.text`, Alerts.DATE_FILTER.INVALID_END_DATE); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify clear filters button', () => { + PatientSearchPage.selectStartMonth(`February`); + PatientSearchPage.selectStartDay(`2`); + PatientSearchPage.selectEndMonth('April'); + PatientSearchPage.selectEndDay(`11`); + cy.get(Locators.CLEAR_FILTERS).click(); + cy.get(Locators.FIELDS.DATE_RANGE_OPTION).should( + `have.attr`, + `value`, + `any`, + ); + cy.get(Locators.BLOCKS.FILTER_START_DATE).should(`not.exist`); + cy.get(Locators.BLOCKS.FILTER_END_DATE).should(`not.exist`); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify search results', () => { + const searchResultResponse = PatientSearchPage.createDateSearchMockResponse( + 2, + 1, + ); + const currentYear = format(new Date(), 'yyyy'); + const startMonth = format(subMonths(new Date(), 2), 'MMMM'); + const endMonth = format(new Date(), 'MMMM'); + + PatientSearchPage.selectStartMonth(startMonth); + PatientSearchPage.selectStartDay(`1`); + PatientSearchPage.getStartYear(currentYear); + PatientSearchPage.selectEndMonth(endMonth); + PatientSearchPage.selectEndDay(`11`); + PatientSearchPage.getEndYear(currentYear); + + PatientInboxPage.clickFilterMessagesButton(searchResultResponse); + + PatientSearchPage.verifySearchResponseLength(searchResultResponse); + PatientSearchPage.verifyMessageDate(2); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + `${startMonth} 1st ${currentYear} to ${endMonth} 11th ${currentYear}`, + ); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); +}); diff --git a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-sent.cypress.spec.js b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-sent.cypress.spec.js new file mode 100644 index 000000000000..ae806e3bb1f6 --- /dev/null +++ b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-sent.cypress.spec.js @@ -0,0 +1,117 @@ +import { format, subMonths } from 'date-fns'; +import SecureMessagingSite from '../sm_site/SecureMessagingSite'; +import PatientInboxPage from '../pages/PatientInboxPage'; +import { AXE_CONTEXT, Locators, Alerts } from '../utils/constants'; +import PatientSearchPage from '../pages/PatientSearchPage'; +import FolderLoadPage from '../pages/FolderLoadPage'; +import PatentMessageSentPage from '../pages/PatientMessageSentPage'; + +describe('SM SENT ADVANCED CUSTOM DATE RANGE SEARCH', () => { + beforeEach(() => { + SecureMessagingSite.login(); + PatientInboxPage.loadInboxMessages(); + FolderLoadPage.loadFolders(); + PatentMessageSentPage.loadMessages(); + PatientInboxPage.openAdvancedSearch(); + PatientInboxPage.selectDateRange('Custom'); + }); + + it('verify advanced filter form elements', () => { + PatientSearchPage.verifyStartDateFormElements(); + PatientSearchPage.verifyEndDateFormElements(); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify month and day range', () => { + PatientSearchPage.verifyMonthFilterRange(14); + PatientSearchPage.verifyDayFilterRange(2); + + PatientSearchPage.selectStartMonth(`February`); + PatientSearchPage.verifyDayFilterRange(31); + + PatientSearchPage.selectStartMonth(`June`); + PatientSearchPage.verifyDayFilterRange(32); + + PatientSearchPage.selectStartMonth(`October`); + PatientSearchPage.verifyDayFilterRange(33); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it(`verify errors`, () => { + cy.get(Locators.BUTTONS.FILTER).click(); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_START_DATE, + ).should(`have.text`, Alerts.DATE_FILTER.EMPTY_START_DATE); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_END_DATE, + ).should(`have.text`, Alerts.DATE_FILTER.EMPTY_END_DATE); + + PatientSearchPage.selectStartMonth('April'); + PatientSearchPage.selectEndMonth('February'); + cy.get(Locators.BUTTONS.FILTER).click(); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_START_DATE, + ).should(`include.text`, Alerts.DATE_FILTER.INVALID_START_DATE); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_END_DATE, + ).should(`include.text`, Alerts.DATE_FILTER.INVALID_END_DATE); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify clear filters button', () => { + PatientSearchPage.selectStartMonth(`February`); + PatientSearchPage.selectStartDay(`2`); + PatientSearchPage.selectEndMonth('April'); + PatientSearchPage.selectEndDay(`11`); + cy.get(Locators.CLEAR_FILTERS).click(); + cy.get(Locators.FIELDS.DATE_RANGE_OPTION).should( + `have.attr`, + `value`, + `any`, + ); + cy.get(Locators.BLOCKS.FILTER_START_DATE).should(`not.exist`); + cy.get(Locators.BLOCKS.FILTER_END_DATE).should(`not.exist`); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify search results', () => { + const searchResultResponse = PatientSearchPage.createDateSearchMockResponse( + 2, + 1, + ); + const currentYear = format(new Date(), 'yyyy'); + const startMonth = format(subMonths(new Date(), 2), 'MMMM'); + const endMonth = format(new Date(), 'MMMM'); + + PatientSearchPage.selectStartMonth(startMonth); + PatientSearchPage.selectStartDay(`1`); + PatientSearchPage.getStartYear(currentYear); + PatientSearchPage.selectEndMonth(endMonth); + PatientSearchPage.selectEndDay(`11`); + PatientSearchPage.getEndYear(currentYear); + + PatientInboxPage.clickFilterMessagesButton(searchResultResponse); + + PatientSearchPage.verifySearchResponseLength(searchResultResponse); + PatientSearchPage.verifyMessageDate(2); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + `${startMonth} 1st ${currentYear} to ${endMonth} 11th ${currentYear}`, + ); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); +}); diff --git a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-trash.cypress.spec.js b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-trash.cypress.spec.js new file mode 100644 index 000000000000..d18858ca46ce --- /dev/null +++ b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-date-trash.cypress.spec.js @@ -0,0 +1,116 @@ +import { format, subMonths } from 'date-fns'; +import SecureMessagingSite from '../sm_site/SecureMessagingSite'; +import PatientInboxPage from '../pages/PatientInboxPage'; +import { AXE_CONTEXT, Locators, Alerts } from '../utils/constants'; +import PatientSearchPage from '../pages/PatientSearchPage'; +import FolderLoadPage from '../pages/FolderLoadPage'; + +describe('SM TRASH ADVANCED CUSTOM DATE RANGE SEARCH', () => { + beforeEach(() => { + SecureMessagingSite.login(); + PatientInboxPage.loadInboxMessages(); + FolderLoadPage.loadFolders(); + FolderLoadPage.loadDeletedMessages(); + PatientInboxPage.openAdvancedSearch(); + PatientInboxPage.selectDateRange('Custom'); + }); + + it('verify advanced filter form elements', () => { + PatientSearchPage.verifyStartDateFormElements(); + PatientSearchPage.verifyEndDateFormElements(); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify month and day range', () => { + PatientSearchPage.verifyMonthFilterRange(14); + PatientSearchPage.verifyDayFilterRange(2); + + PatientSearchPage.selectStartMonth(`February`); + PatientSearchPage.verifyDayFilterRange(31); + + PatientSearchPage.selectStartMonth(`June`); + PatientSearchPage.verifyDayFilterRange(32); + + PatientSearchPage.selectStartMonth(`October`); + PatientSearchPage.verifyDayFilterRange(33); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it(`verify errors`, () => { + cy.get(Locators.BUTTONS.FILTER).click(); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_START_DATE, + ).should(`have.text`, Alerts.DATE_FILTER.EMPTY_START_DATE); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_END_DATE, + ).should(`have.text`, Alerts.DATE_FILTER.EMPTY_END_DATE); + + PatientSearchPage.selectStartMonth('April'); + PatientSearchPage.selectEndMonth('February'); + cy.get(Locators.BUTTONS.FILTER).click(); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_START_DATE, + ).should(`include.text`, Alerts.DATE_FILTER.INVALID_START_DATE); + + PatientSearchPage.getRequiredFieldError( + Locators.BLOCKS.FILTER_END_DATE, + ).should(`include.text`, Alerts.DATE_FILTER.INVALID_END_DATE); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify clear filters button', () => { + PatientSearchPage.selectStartMonth(`February`); + PatientSearchPage.selectStartDay(`2`); + PatientSearchPage.selectEndMonth('April'); + PatientSearchPage.selectEndDay(`11`); + cy.get(Locators.CLEAR_FILTERS).click(); + cy.get(Locators.FIELDS.DATE_RANGE_OPTION).should( + `have.attr`, + `value`, + `any`, + ); + cy.get(Locators.BLOCKS.FILTER_START_DATE).should(`not.exist`); + cy.get(Locators.BLOCKS.FILTER_END_DATE).should(`not.exist`); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); + + it('verify search results', () => { + const searchResultResponse = PatientSearchPage.createDateSearchMockResponse( + 2, + 1, + ); + const currentYear = format(new Date(), 'yyyy'); + const startMonth = format(subMonths(new Date(), 2), 'MMMM'); + const endMonth = format(new Date(), 'MMMM'); + + PatientSearchPage.selectStartMonth(startMonth); + PatientSearchPage.selectStartDay(`1`); + PatientSearchPage.getStartYear(currentYear); + PatientSearchPage.selectEndMonth(endMonth); + PatientSearchPage.selectEndDay(`11`); + PatientSearchPage.getEndYear(currentYear); + + PatientInboxPage.clickFilterMessagesButton(searchResultResponse); + + PatientSearchPage.verifySearchResponseLength(searchResultResponse); + PatientSearchPage.verifyMessageDate(2); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + `${startMonth} 1st ${currentYear} to ${endMonth} 11th ${currentYear}`, + ); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT); + }); +}); diff --git a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-custom-folder.cypress.spec.js b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-folder.cypress.spec.js similarity index 94% rename from src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-custom-folder.cypress.spec.js rename to src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-folder.cypress.spec.js index 82bffd440c76..8b505ab73117 100644 --- a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-custom-folder.cypress.spec.js +++ b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-custom-folder.cypress.spec.js @@ -82,6 +82,10 @@ describe('SM CUSTOM FOLDER ADVANCED FIXED DATE RANGE SEARCH', () => { PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifyMessageDate(6); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + 'Last 6 months', + ); cy.injectAxe(); cy.axeCheck(AXE_CONTEXT); @@ -99,6 +103,10 @@ describe('SM CUSTOM FOLDER ADVANCED FIXED DATE RANGE SEARCH', () => { PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifyMessageDate(12); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + 'Last 12 months', + ); cy.injectAxe(); cy.axeCheck(AXE_CONTEXT); diff --git a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-drafts.cypress.spec.js b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-drafts.cypress.spec.js similarity index 90% rename from src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-drafts.cypress.spec.js rename to src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-drafts.cypress.spec.js index 760498e9652f..e290ca134327 100644 --- a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-drafts.cypress.spec.js +++ b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-drafts.cypress.spec.js @@ -58,6 +58,10 @@ describe('SM DRAFTS ADVANCED FIXED DATE RANGE SEARCH', () => { PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifyMessageDate(3); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + 'Last 3 months', + ); cy.injectAxe(); cy.axeCheck(AXE_CONTEXT); @@ -75,6 +79,10 @@ describe('SM DRAFTS ADVANCED FIXED DATE RANGE SEARCH', () => { PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifyMessageDate(6); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + 'Last 6 months', + ); cy.injectAxe(); cy.axeCheck(AXE_CONTEXT); @@ -92,6 +100,10 @@ describe('SM DRAFTS ADVANCED FIXED DATE RANGE SEARCH', () => { PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifyMessageDate(12); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + 'Last 12 months', + ); cy.injectAxe(); cy.axeCheck(AXE_CONTEXT); diff --git a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-inbox.cypress.spec.js b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-inbox.cypress.spec.js similarity index 89% rename from src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-inbox.cypress.spec.js rename to src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-inbox.cypress.spec.js index 21348463f3d1..46f5ff371968 100644 --- a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-inbox.cypress.spec.js +++ b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-inbox.cypress.spec.js @@ -48,6 +48,10 @@ describe('SM INBOX ADVANCED FIXED DATE RANGE SEARCH', () => { PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifyMessageDate(3); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + 'Last 3 months', + ); cy.injectAxe(); cy.axeCheck(AXE_CONTEXT); @@ -58,10 +62,13 @@ describe('SM INBOX ADVANCED FIXED DATE RANGE SEARCH', () => { PatientInboxPage.selectDateRange('Last 6 months'); PatientInboxPage.clickFilterMessagesButton(searchResultResponse); - PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifyMessageDate(6); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + 'Last 6 months', + ); cy.injectAxe(); cy.axeCheck(AXE_CONTEXT); @@ -75,10 +82,13 @@ describe('SM INBOX ADVANCED FIXED DATE RANGE SEARCH', () => { PatientInboxPage.selectDateRange('Last 12 months'); PatientInboxPage.clickFilterMessagesButton(searchResultResponse); - PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifyMessageDate(12); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + 'Last 12 months', + ); cy.injectAxe(); cy.axeCheck(AXE_CONTEXT); diff --git a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-sent.cypress.spec.js b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-sent.cypress.spec.js similarity index 93% rename from src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-sent.cypress.spec.js rename to src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-sent.cypress.spec.js index 031e164cc66f..6678baf02178 100644 --- a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-sent.cypress.spec.js +++ b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-sent.cypress.spec.js @@ -82,6 +82,10 @@ describe('SM SENT ADVANCED FIXED DATE RANGE SEARCH', () => { PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifyMessageDate(6); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + 'Last 6 months', + ); cy.injectAxe(); cy.axeCheck(AXE_CONTEXT); @@ -99,6 +103,10 @@ describe('SM SENT ADVANCED FIXED DATE RANGE SEARCH', () => { PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifyMessageDate(12); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + 'Last 12 months', + ); cy.injectAxe(); cy.axeCheck(AXE_CONTEXT); diff --git a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-trash.cypress.spec.js b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-trash.cypress.spec.js similarity index 93% rename from src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-trash.cypress.spec.js rename to src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-trash.cypress.spec.js index 3d069c62c4df..159e2716a6be 100644 --- a/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-search-trash.cypress.spec.js +++ b/src/applications/mhv-secure-messaging/tests/e2e/sort-filter-test/secure-messaging-advanced-filter-trash.cypress.spec.js @@ -81,6 +81,10 @@ describe('SM TRASH ADVANCED FIXED DATE RANGE SEARCH', () => { PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifyMessageDate(6); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + 'Last 6 months', + ); cy.injectAxe(); cy.axeCheck(AXE_CONTEXT); @@ -98,6 +102,10 @@ describe('SM TRASH ADVANCED FIXED DATE RANGE SEARCH', () => { PatientSearchPage.verifySearchResponseLength(searchResultResponse); PatientSearchPage.verifyMessageDate(12); + PatientSearchPage.verifySearchMessageLabel( + searchResultResponse, + 'Last 12 months', + ); cy.injectAxe(); cy.axeCheck(AXE_CONTEXT); diff --git a/src/applications/mhv-secure-messaging/tests/e2e/utils/constants.js b/src/applications/mhv-secure-messaging/tests/e2e/utils/constants.js index 38b300ae1870..3755f9924491 100644 --- a/src/applications/mhv-secure-messaging/tests/e2e/utils/constants.js +++ b/src/applications/mhv-secure-messaging/tests/e2e/utils/constants.js @@ -239,6 +239,8 @@ export const Locators = { }, BLOCKS: { ATTACHMENTS: '.attachments-list', + FILTER_START_DATE: `[data-testid="date-start"]`, + FILTER_END_DATE: `[data-testid="date-end"]`, }, CHECKBOX: { CL_ALL: '[data-testid*="select-all"]', @@ -294,6 +296,12 @@ export const Alerts = { ACTIVE: `Maintenance on My HealtheVet`, UPCOMING: `Upcoming maintenance on My HealtheVet`, }, + DATE_FILTER: { + EMPTY_START_DATE: `Error Please enter a start date.`, + EMPTY_END_DATE: `Error Please enter an end date.`, + INVALID_START_DATE: `Start date must be on or before end date.`, + INVALID_END_DATE: `End date must be on or after start date.`, + }, OUTAGE: 'We’re sorry. We couldn’t load this page. Try again later.', OLD_MSG_HEAD: 'This conversation is too old for new replies', OLD_MSG_SUBHEAD: