From 1eb310286fe3f9f908465fcc7de0dcaeb5970c22 Mon Sep 17 00:00:00 2001 From: Hanna Asmare <121971510+haniasma@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:05:44 -0400 Subject: [PATCH] MHV-43924 SM - [Added test case for expand all messages and focus them by pressing nav] (#29196) * Added test case for expend all messages and focus them by pressing nav * Fix according to the review comments. * Update PatientMessageDetailsPage.js * Update secure-messaging-keyboard-nav-to-message-details.cypress.spec.js --- ...ard-nav-to-message-details.cypress.spec.js | 28 +++++++++++++++ .../e2e/pages/PatientMessageDetailsPage.js | 35 +++++++++++++++++++ .../main/tests/e2e/utils/constants.js | 5 +++ 3 files changed, 68 insertions(+) diff --git a/src/applications/mhv-secure-messaging/main/tests/e2e/keyboard-nav-test/secure-messaging-keyboard-nav-to-message-details.cypress.spec.js b/src/applications/mhv-secure-messaging/main/tests/e2e/keyboard-nav-test/secure-messaging-keyboard-nav-to-message-details.cypress.spec.js index d540925f951d..297d96748b5c 100644 --- a/src/applications/mhv-secure-messaging/main/tests/e2e/keyboard-nav-test/secure-messaging-keyboard-nav-to-message-details.cypress.spec.js +++ b/src/applications/mhv-secure-messaging/main/tests/e2e/keyboard-nav-test/secure-messaging-keyboard-nav-to-message-details.cypress.spec.js @@ -6,6 +6,34 @@ import mockMessages from '../fixtures/messages-response.json'; import { AXE_CONTEXT, Locators } from '../utils/constants'; describe('Navigate to Message Details ', () => { + it('Keyboard Nav Access to Expended Messages', () => { + const landingPage = new PatientInboxPage(); + const messageDetailsPage = new PatientMessageDetailsPage(); + const site = new SecureMessagingSite(); + site.login(); + mockMessagewithAttachment.data.id = '7192838'; + mockMessagewithAttachment.data.attributes.attachment = true; + mockMessagewithAttachment.data.attributes.body = 'attachment'; + landingPage.loadInboxMessages(mockMessages, mockMessagewithAttachment); + messageDetailsPage.loadMessageDetails(mockMessagewithAttachment); + cy.contains('Print').should('be.visible'); + cy.tabToElement('button') + .eq(0) + .should('contain', 'Print'); + cy.realPress('Tab'); + cy.get(Locators.BUTTONS.BUTTON_MOVE).should('have.focus'); + cy.realPress('Tab'); + cy.get(Locators.BUTTONS.BUTTON_TRASH) + .should('be.visible') + .then(() => { + cy.get(Locators.BUTTONS.BUTTON_TRASH).should('have.focus'); + }); + messageDetailsPage.realPressForExpandAllButton(); + messageDetailsPage.verifyClickAndExpandAllMessagesHasFocus(); + + cy.injectAxe(); + cy.axeCheck(AXE_CONTEXT, {}); + }); it('Keyboard Navigation to Print Button', () => { const landingPage = new PatientInboxPage(); const messageDetailsPage = new PatientMessageDetailsPage(); diff --git a/src/applications/mhv-secure-messaging/main/tests/e2e/pages/PatientMessageDetailsPage.js b/src/applications/mhv-secure-messaging/main/tests/e2e/pages/PatientMessageDetailsPage.js index efd8c9f44977..0b9c8a1e6a02 100644 --- a/src/applications/mhv-secure-messaging/main/tests/e2e/pages/PatientMessageDetailsPage.js +++ b/src/applications/mhv-secure-messaging/main/tests/e2e/pages/PatientMessageDetailsPage.js @@ -501,6 +501,41 @@ class PatientMessageDetailsPage { ); }; + realPressForExpandAllButton = () => { + cy.get(Locators.BUTTONS.SECURE_MESSAGING) + .find('button') + .each(button => { + cy.realPress('Tab'); + cy.wrap(button).focus(); + if (button.attr('aria-label') === 'Expand all accordions') { + return false; + } + return 0; + }); + }; + + verifyClickAndExpandAllMessagesHasFocus = () => { + cy.tabToElement(Locators.BUTTONS.THREAD_EXPAND_MESSAGES); + cy.realPress('Enter'); + cy.get(Locators.BUTTONS.THREAD_EXPAND_MESSAGES).each(el => { + cy.realPress('Enter'); + cy.wrap(el) + .should('be.visible') + .and('have.focus'); + cy.wrap(el) + .find(Locators.MESSAGE_THREAD_META) + .should('be.visible'); + cy.realPress('Enter'); + cy.wrap(el) + .should('be.visible') + .and('have.focus'); + cy.wrap(el) + .find(Locators.MESSAGE_THREAD_META) + .should('not.be.visible'); + cy.realPress('Tab'); + }); + }; + // temporary changed to 'contain', 'REPLY' replyToMessageBody = testMessageBody => { cy.get('[data-testid="message-body"]').should('contain', testMessageBody); diff --git a/src/applications/mhv-secure-messaging/main/tests/e2e/utils/constants.js b/src/applications/mhv-secure-messaging/main/tests/e2e/utils/constants.js index ee9c919cb27f..3d56f6dfa658 100644 --- a/src/applications/mhv-secure-messaging/main/tests/e2e/utils/constants.js +++ b/src/applications/mhv-secure-messaging/main/tests/e2e/utils/constants.js @@ -78,6 +78,7 @@ export const Locators = { FILTER_INPUT: '#filter-input', ADDITIONAL_FILTER: '#additional-filter-accordion', ACCORDIONS: '[data-testid="faq-accordion-item"]', + MESSAGE_THREAD_META: '.message-thread-meta', FOLDERS: { FOLDER_NAME: '[label="Folder name"]', FOLDER_REMOVE: '[text="Yes, remove this folder"]', @@ -94,6 +95,10 @@ export const Locators = { FOLDER_NOT_EMPTY: 'va-modal[data-testid="error-folder-not-empty"]', }, BUTTONS: { + SECURE_MESSAGING: '[data-testid="secure-messaging"]', + THREAD_EXPAND: '[data-testid="thread-expand-all"]', + THREAD_EXPAND_MESSAGES: + '[data-testid="thread-expand-all"] va-accordion-item', ADDITIONAL_FILTER: '#additional-filter-accordion', TRASH_TEXT: '[data-testid=trash-button-text]', TEXT_CONFIRM: 'va-button[text="Confirm"]',