Skip to content

Commit

Permalink
Mhv 53979 refactore selectore locators (#28436)
Browse files Browse the repository at this point in the history
* Refactor all the selector to constant

* Refactor

* refactor

* Refactor

* Refactor

* refactor done

* Refactor fix

* Update constants.js

* fix conflict

* Revert "fix conflict"

This reverts commit 21dffd4.

* fix

* fixed failing test

* fixes the failure

* refactor selector to common fail

* Update PatientComposePage.js

updated the locators

* refactor selector to common file

* Added missed PO

* Fixes for the test failures

* Added radio button key

* linting fixes

* updates

* upd: mockFeatureToggles response to fix failing test

---------

Co-authored-by: Aaron Read <10744676+Asterix22@users.noreply.github.com>
Co-authored-by: Aaron Read <Aaron.Read@va.gov>
Co-authored-by: fazilqa <127263470+fazilqa@users.noreply.github.com>
Co-authored-by: fazilqa <fazil.mammadov@bylight.com>
  • Loading branch information
5 people committed Mar 11, 2024
1 parent fcabaff commit 2b1d9f9
Show file tree
Hide file tree
Showing 57 changed files with 477 additions and 375 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SecureMessagingSite from '../sm_site/SecureMessagingSite';
import PatientInboxPage from '../pages/PatientInboxPage';
import { AXE_CONTEXT } from '../utils/constants';
import { AXE_CONTEXT, Locators } from '../utils/constants';
import PatientMessageDraftsPage from '../pages/PatientMessageDraftsPage';
import mockMultiDraftsResponse from '../fixtures/draftsResponse/multi-draft-response.json';

Expand Down Expand Up @@ -58,18 +58,18 @@ describe('handle multiple drafts in one thread', () => {
},
});

cy.get('[data-testid="reply-form"]')
cy.get(Locators.REPLY_FORM)
.find('h2')
.should('be.visible')
.and('contain.text', `${draftsCount} drafts`);

cy.get('[data-testid="reply-form"]')
cy.get(Locators.REPLY_FORM)
.find('h3')
.each(el => {
cy.wrap(el).should('include.text', 'Draft');
});

cy.get('[data-testid="last-edit-date"]').each(el => {
cy.get(Locators.ALERTS.LAST_EDIT_DATE).each(el => {
cy.wrap(el).should('include.text', 'edited');
});
});
Expand All @@ -84,12 +84,12 @@ describe('handle multiple drafts in one thread', () => {
},
});

cy.get('[data-testid="message-body-field"]')
cy.get(Locators.MESSAGES_BODY)
.should('have.attr', 'value')
.and('eq', updatedMultiDraftResponse.data[0].attributes.body);

cy.get('[text="Edit draft 1"]').click();
cy.get('[data-testid="message-body-field"]')
cy.get(Locators.ALERTS.EDIT_DRAFT).click();
cy.get(Locators.MESSAGES_BODY)
.should('have.attr', 'value')
.and('eq', updatedMultiDraftResponse.data[1].attributes.body);

Expand All @@ -99,7 +99,7 @@ describe('handle multiple drafts in one thread', () => {
);

cy.get('[text="Edit draft 2"]').click();
cy.get('[data-testid="message-body-field"]')
cy.get(Locators.MESSAGES_BODY)
.should('have.attr', 'value')
.and('eq', updatedMultiDraftResponse.data[0].attributes.body);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import mockMixedCernerFacilitiesUser from '../fixtures/userResponse/user-cerner-
import mockFacilities from '../fixtures/facilityResponse/cerner-facility-mock-data.json';
import mockEhrData from '../fixtures/userResponse/vamc-ehr-cerner-mixed.json';

import { AXE_CONTEXT } from '../utils/constants';
import { AXE_CONTEXT, Locators } from '../utils/constants';

describe('Secure Messaging Inbox Cerner', () => {
it('verify cerner facilities displays in alert banner', () => {
Expand All @@ -22,7 +22,7 @@ describe('Secure Messaging Inbox Cerner', () => {
facility => facility.isCerner,
);

cy.get('[data-testid="cerner-facilities-alert"]').should('be.visible');
cy.get(Locators.ALERTS.CERNER_ALERT).should('be.visible');

cy.contains('h2', 'Make sure you’re in the right health portal').should(
'be.visible',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import SecureMessagingSite from '../sm_site/SecureMessagingSite';
import PatientInboxPage from '../pages/PatientInboxPage';
import PatientInterstitialPage from '../pages/PatientInterstitialPage';
import { AXE_CONTEXT } from '../utils/constants';
import { AXE_CONTEXT, Locators } from '../utils/constants';
import categories from '../fixtures/categories-response.json';

describe('Validate the category', () => {
Expand All @@ -12,7 +12,7 @@ describe('Validate the category', () => {

site.login();
landingPage.loadInboxMessages();
cy.get('[data-testid="compose-message-link"]').click();
cy.get(Locators.LINKS.CREATE_NEW_MESSAGE).click();
PatientInterstitialPage.getContinueButton().click();
cy.tabToElement('[data-testid="edit-preferences-button"]').should(
'have.focus',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SecureMessagingSite from '../sm_site/SecureMessagingSite';
import PatientInboxPage from '../pages/PatientInboxPage';
import PatientComposePage from '../pages/PatientComposePage';
import requestBody from '../fixtures/message-compose-request-body.json';
import { AXE_CONTEXT } from '../utils/constants';
import { AXE_CONTEXT, Locators } from '../utils/constants';

describe('Check confirmation message after save draft', () => {
const site = new SecureMessagingSite();
Expand Down Expand Up @@ -36,7 +36,7 @@ describe('Check confirmation message after save draft', () => {
},
});
// next line is for checking if assertion works properly
cy.get('#save-draft-button')
cy.get(Locators.BUTTONS.SAVE_DRAFT)
.should('exist')
.and('be.focused');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SecureMessagingSite from '../sm_site/SecureMessagingSite';
import PatientInboxPage from '../pages/PatientInboxPage';
import { AXE_CONTEXT } from '../utils/constants';
import { AXE_CONTEXT, Locators } from '../utils/constants';

describe('Secure Messaging Keyboard Nav To Compose', () => {
const site = new SecureMessagingSite();
Expand All @@ -22,7 +22,7 @@ describe('Secure Messaging Keyboard Nav To Compose', () => {
});
cy.tabToElement('[data-testid="continue-button"] ');
cy.realPress(['Enter']);
cy.get('.page-title')
cy.get(Locators.ALERTS.PAGE_TITLE)
.should('be.focused')
.and('have.text', 'Start a new message');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import PatientInboxPage from '../pages/PatientInboxPage';
import SecureMessagingSite from '../sm_site/SecureMessagingSite';
import { AXE_CONTEXT } from '../utils/constants';
import { AXE_CONTEXT, Locators } from '../utils/constants';

describe('Secure Messaging Verify Links and Buttons Keyboard Nav', () => {
it('Tab to Links and Buttons on the Landing Page', () => {
const site = new SecureMessagingSite();
const landingPage = new PatientInboxPage();
site.login();
landingPage.loadInboxMessages();
cy.get('[class="sidebar-navigation-messages-list-header"]').click();
cy.get('[text="Go to your inbox"]').should('be.visible');
cy.get(Locators.ALERTS.SIDEBAR_NAV).click();
cy.get(Locators.ALERTS.INBOX_TEXT).should('be.visible');
cy.tabToElement('[text="Go to your inbox"]').should(
'have.text',
'Go to your inbox',
Expand All @@ -20,17 +20,17 @@ describe('Secure Messaging Verify Links and Buttons Keyboard Nav', () => {
);

cy.realPress('Tab');
cy.get('.welcome-message')
cy.get(Locators.ALERTS.WELCOME_MESSAGE)
.find('a')
.should('have.focus');

cy.realPress('Tab');
cy.get('[data-testid="faq-accordion-item"]').each(el => {
cy.get(Locators.ALERTS.ACC_ITEM).each(el => {
cy.get(el).should('have.focus');
cy.realPress('Tab');
});

cy.get('va-back-to-top')
cy.get(Locators.ALERTS.BACK_TOP)
.scrollIntoView()
.should('have.focus');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PatientMessageDetailsPage from '../pages/PatientMessageDetailsPage';
import SecureMessagingSite from '../sm_site/SecureMessagingSite';
import mockMessagewithAttachment from '../fixtures/message-response-withattachments.json';
import mockMessages from '../fixtures/messages-response.json';
import { AXE_CONTEXT } from '../utils/constants';
import { AXE_CONTEXT, Locators } from '../utils/constants';

describe('Navigate to Message Details ', () => {
it('Keyboard Navigation to Print Button', () => {
Expand All @@ -22,11 +22,10 @@ describe('Navigate to Message Details ', () => {
.should('contain', 'Print');

cy.realPress('Tab');
cy.get('button:contains("Move")').should('have.focus');
cy.get(Locators.BUTTONS.BUTTON_MOVE).should('have.focus');

cy.realPress('Tab');
cy.get('button:contains("Trash")').should('be.visible');
cy.get('button:contains("Trash")').should('have.focus');
cy.get(Locators.BUTTONS.BUTTON_TRASH).should('be.visible');

cy.injectAxe();
cy.axeCheck(AXE_CONTEXT, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import mockCategories from '../fixtures/categories-response.json';
import mockFolders from '../fixtures/folder-response.json';
import mockToggles from '../fixtures/toggles-response.json';
import mockRecipients from '../fixtures/recipients-response.json';
import { Locators } from '../utils/constants';

class FolderLoadPage {
foldersSetup = () => {
Expand Down Expand Up @@ -64,7 +65,7 @@ class FolderLoadPage {
};

getFolderHeader = text => {
cy.get('[data-testid="folder-header"]').should('have.text', `${text}`);
cy.get(Locators.FOLDERS.FOLDER_HEADER).should('have.text', `${text}`);
};

verifyBackToMessagesButton = () => {
Expand All @@ -78,17 +79,17 @@ class FolderLoadPage {
cy.contains('Back to messages')
.should('be.visible')
.click({ force: true });
cy.get('h1').should('contain', 'Messages');
cy.get(Locators.HEADER).should('contain', 'Messages');
};

navigateToLastPage = index => {
cy.get('.usa-pagination__list li')
cy.get(Locators.ALERTS.PAGIN_LIST)
.eq(index)
.click();
};

verifyPaginationElements = () => {
cy.get('.usa-pagination__list li').each(el => {
cy.get(Locators.ALERTS.PAGIN_LIST).each(el => {
cy.wrap(el).should('be.visible');
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@ import mockCustomResponse from '../fixtures/custom-response.json';
import defaultMockThread from '../fixtures/thread-response.json';
import mockMessageResponse from '../fixtures/message-custom-response.json';
import mockFolders from '../fixtures/generalResponses/folders.json';
import { Locators } from '../utils/constants';

class FolderManagementPage {
currentThread = defaultMockThread;

createANewFolderButton = () => {
return cy
.get('[text="Create new folder"]')
.get(Locators.ALERTS.CREAT_NEW_TEXT_FOLD)
.shadow()
.find('[type="button"]');
};

deleteFolderButton = () => {
return cy.get('[data-testid="remove-folder-button"]');
return cy.get(Locators.BUTTONS.REMOVE_FOLDER_BUTTON);
};

editFolderNameButton = () => {
return cy.get('[data-testid="edit-folder-button"]');
return cy.get(Locators.BUTTONS.EDIT_FOLDER);
};

createFolderTextBox = () => {
Expand Down Expand Up @@ -187,8 +188,8 @@ class FolderManagementPage {
}`,
mockMessageResponse,
);
cy.get('[data-testid="move-button-text"]').click();
cy.get('[data-testid = "move-to-modal"')
cy.get(Locators.BUTTONS.MOVE_BUTTON_TEXT).click();
cy.get(Locators.ALERTS.MOVE_MODAL)

.find('[class = "form-radio-buttons hydrated"]', {
includeShadowDom: true,
Expand All @@ -205,8 +206,8 @@ class FolderManagementPage {
}/move?folder_id=-3`,
mockCustomResponse,
).as('moveMockCustomResponse');
cy.get('[data-testid="move-to-modal"]')
.find('va-button[text="Confirm"]')
cy.get(Locators.ALERTS.MOVE_MODAL)
.find(Locators.BUTTONS.TEXT_CONFIRM)
.click();
// cy.wait('@mockCustomResponse');
};
Expand All @@ -228,21 +229,21 @@ class FolderManagementPage {
}/move?folder_id=${folderId}`,
{},
);
cy.get('[data-testid="move-button-text"]').click({ force: true });
cy.get(Locators.BUTTONS.MOVE_BUTTON_TEXT).click({ force: true });
cy.get(`[data-testid="radiobutton-${folderName}"]`)
.should('exist')
.click();
cy.get('va-button[text="Confirm"]').click();
cy.get(Locators.BUTTONS.TEXT_CONFIRM).click();
};

verifyMoveMessageSuccessConfirmationMessage = () => {
cy.get('[close-btn-aria-label="Close notification"]')
cy.get(Locators.ALERTS.CLOSE_NOTIFICATION)
.should('exist')
.and('have.text', 'Message conversation was successfully moved.');
};

verifyMoveMessageSuccessConfirmationHasFocus = () => {
cy.get('[close-btn-aria-label="Close notification"]').should('have.focus');
cy.get(Locators.ALERTS.CLOSE_NOTIFICATION).should('have.focus');
};

confirmDeleteFolder = folderId => {
Expand All @@ -256,7 +257,7 @@ class FolderManagementPage {
mockFolders,
).as('updatedFoldersList');

cy.get('[text="Yes, remove this folder"]')
cy.get(Locators.FOLDERS.FOLDER_REMOVE)
.shadow()
.find('[type="button"]')
.click();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import mockMessageResponse from '../fixtures/drafts-search-results.json';
import folderResponse from '../fixtures/folder-response.json';
import { Locators } from '../utils/constants';

class PatientBasicSearchPage {
// This method clicks the Search messages on the side navigation bar.
clickSearchMessage = () => {
cy.get('[data-testid="filter-messages-button"]').click();
cy.get(Locators.BUTTONS.FILTER).click();
};

// This method will access the input field and enters the text that will be used for search.

typeSearchInputFieldText = text => {
cy.get('[data-testid="keyword-search-input"]')
cy.get(Locators.KEYWORD_SEARCH)
.shadow()
.find('[id="inputField"]')
.type(text, { force: true });
Expand Down Expand Up @@ -53,7 +54,7 @@ class PatientBasicSearchPage {
// This method verifies the highlighted text in the messages returned after clicking the search button.

verifyHighlightedText = text => {
cy.get('[data-testid="highlighted-text"]').should('contain', text);
cy.get(Locators.ALERTS.HIGHLIGHTED).should('contain', text);
};

loadInboxSearchResults = () => {
Expand All @@ -66,7 +67,7 @@ class PatientBasicSearchPage {
// This method selects the folder from the drop down menu.

selectMessagesFolder = name => {
cy.get('[data-testid="folder-dropdown"]')
cy.get(Locators.FOLDERS.FOLDER_DROPDOWN)
.shadow()
.find('select')
.select(`${name}`, { force: true });
Expand Down

0 comments on commit 2b1d9f9

Please sign in to comment.