Skip to content

Commit

Permalink
MHV-43924 SM - [Added test case for expand all messages and focus the…
Browse files Browse the repository at this point in the history
…m 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
  • Loading branch information
haniasma committed Apr 18, 2024
1 parent 12ef189 commit 1eb3102
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]',
Expand All @@ -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"]',
Expand Down

0 comments on commit 1eb3102

Please sign in to comment.