Skip to content

Commit

Permalink
63818 refactor message detail page (#33178)
Browse files Browse the repository at this point in the history
* refactor message-details spec

* fix failed tests

* rename tests

* refactor details-sent-message spec

* refactor nav-to-message-details spec

* refactor delete-reply-draft spec

* clean-up delete-reply-draft spec

* delete unused imports

* update mocks

* refactor message-details-buttons spec

* refactor move-message-with-attachment spec

* update print and reply specs

* update message-reply spec

* fix failed tests

* delete unused methods

* fix failed test

* fix failed test

* update selectors

* fix flacky test

* fix flaky test
  • Loading branch information
fazilqa authored Nov 26, 2024
1 parent a2b9ba6 commit 6e7ed0c
Show file tree
Hide file tree
Showing 30 changed files with 406 additions and 697 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"messageCount": 2,
"category": "OTHER",
"subject": "Test-First Message",
"triageGroupName": "Dimitar's TG",
"triageGroupName": "TG-7410",
"sentDate": "2023-07-17T19:57:15.000Z",
"draftDate": null,
"senderId": 694294,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"attachment": null,
"sentDate": "2023-07-17T19:57:15.000Z",
"senderId": 694294,
"senderName": "MAMMADOV, FAZIL",
"senderName": "SPARROW, JACK",
"recipientId": 406227,
"recipientName": "MHVTP, SAFARI ",
"readReceipt": "READ",
"triageGroupName": "Dimitar's TG",
"triageGroupName": "TG-7410",
"proxySenderName": null,
"threadId": 2708300,
"folderId": -3,
"folderId": -1,
"messageBody": "Message to patient\r\n\r\nhttps://vajira.max.gov/browse/MHV-19810",
"draftDate": null,
"toDate": null,
Expand All @@ -41,9 +41,9 @@
"senderId": 406227,
"senderName": "MHVTP, SAFARI ",
"recipientId": 2298160,
"recipientName": "Dimitar's TG",
"recipientName": "TAYLOR, ELIZABETH",
"readReceipt": "READ",
"triageGroupName": "Dimitar's TG",
"triageGroupName": "TG-7410",
"proxySenderName": null,
"threadId": 2708300,
"folderId": -1,
Expand All @@ -56,6 +56,62 @@
"self": "https://staging-api.va.gov/my_health/v1/messaging/messages/2708301"
}
}
,{
"id": "7176701",
"type": "message_thread_details",
"attributes": {
"messageId": 7176701,
"category": "50",
"subject": "Covid-Inquiry",
"body": "replying",
"attachment": null,
"sentDate": "2022-09-06T20:06:15.000Z",
"senderId": 6177,
"senderName": "TEACH, EDWARD",
"recipientId": 6820911,
"recipientName": "MORGAN, JAMES",
"readReceipt": "READ",
"triageGroupName": "Jeasmitha-Cardio-Clinic",
"proxySenderName": null,
"threadId": 7176615,
"folderId": -1,
"messageBody": "replying",
"draftDate": null,
"toDate": null,
"hasAttachments": false
},
"links": {
"self": "http://127.0.0.1:3000/my_health/v1/messaging/messages/7176701"
}
},
{
"id": "7176616",
"type": "message_thread_details",
"attributes": {
"messageId": 7176616,
"category": "50",
"subject": "Covid-Inquiry",
"body": "Send message Api testing 39",
"attachment": null,
"sentDate": "2022-09-06T19:31:18.000Z",
"senderId": 6820911,
"senderName": "MORGAN, JAMES",
"recipientId": 6910405,
"recipientName": "Jeasmitha-Cardio-Clinic",
"readReceipt": "READ",
"triageGroupName": "Jeasmitha-Cardio-Clinic",
"proxySenderName": null,
"threadId": 7176615,
"folderId": -1,
"messageBody": "Send message Api testing 39",
"draftDate": null,
"toDate": null,
"hasAttachments": false
},
"links": {
"self": "http://127.0.0.1:3000/my_health/v1/messaging/messages/7176616"
}
}
]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"messageId": 7179613,
"category": "OTHER",
"subject": "Covid-Inquiry",
"body": "REPLY\nFROM ESCALATED FOLDER\n\n\nJack Sparrow\nSenior Software Test Engineer",
"body": "REPLY\nJack Sparrow\nSenior Software Test Engineer",
"attachment": null,
"sentDate": "2022-09-12T14:34:28.000Z",
"senderId": 20029,
Expand All @@ -18,8 +18,8 @@
"triageGroupName": "Jeasmitha-Cardio-Clinic",
"proxySenderName": null,
"threadId": 7176615,
"folderId": -3,
"messageBody": "REPLY\nFROM ESCALATED FOLDER\n\n\njack Sparrow\nSenior Software Test Engineer",
"folderId": -1,
"messageBody": "REPLY\nJack Sparrow\nSenior Software Test Engineer",
"draftDate": null,
"toDate": null,
"hasAttachments": true,
Expand All @@ -41,7 +41,7 @@
"type": "message_thread_details",
"attributes": {
"messageId": 7177164,
"category": "50",
"category": "COVID",
"subject": "Covid-Inquiry",
"body": "Draft2",
"attachment": null,
Expand All @@ -50,7 +50,7 @@
"senderName": "TEACH, EDWARD",
"recipientId": 6820911,
"recipientName": "MORGAN, JAMES",
"readReceipt": null,
"readReceipt": "READ",
"triageGroupName": "Jeasmitha-Cardio-Clinic",
"proxySenderName": null,
"threadId": 7176615,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"attachment": null,
"sentDate": "2023-10-22T14:34:28.000Z",
"senderId": 20029,
"senderName": "ISLAM, MOHAMMAD RAFIQ",
"senderName": "SPARROW, JACK",
"recipientId": 6820911,
"recipientName": "ECSTEN, THOMAS ",
"recipientName": "MORGAN, JAMES",
"readReceipt": null,
"triageGroupName": "Jeasmitha-Cardio-Clinic",
"proxySenderName": null,
"threadId": 7176615,
"folderId": -1,
"messageBody": "REPLY\r\nFROM ESCALATED FOLDER\r\n\r\n\r\n\r\nMohammad R Islam\r\nSenior Software Test Engineer",
"messageBody": "REPLY\nJack Sparrow\nSenior Software Test Engineer",
"draftDate": null,
"toDate": null,
"hasAttachments": false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import PatientInboxPage from '../pages/PatientInboxPage';
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, Locators } from '../utils/constants';
import { AXE_CONTEXT } from '../utils/constants';
import GeneralFunctionsPage from '../pages/GeneralFunctionsPage';
import singleThreadResponse from '../fixtures/thread-response-new-api.json';

describe('Navigate to Message Details ', () => {
beforeEach(() => {
const updatedSingleThreadResponse = GeneralFunctionsPage.updatedThreadDates(
singleThreadResponse,
);
SecureMessagingSite.login();
mockMessageWithAttachment.data.id = '7192838';
mockMessageWithAttachment.data.attributes.attachment = true;
mockMessageWithAttachment.data.attributes.body = 'attachment';
PatientInboxPage.loadInboxMessages(mockMessages, mockMessageWithAttachment);
PatientMessageDetailsPage.loadMessageDetails(mockMessageWithAttachment);
PatientInboxPage.loadInboxMessages();
PatientMessageDetailsPage.loadSingleThread(updatedSingleThreadResponse);
});

it('keyboard navigation to expand messages', () => {
Expand All @@ -25,19 +25,10 @@ describe('Navigate to Message Details ', () => {
it('keyboard navigation to main buttons', () => {
PatientMessageDetailsPage.verifyButtonsKeyboardNavigation();

cy.tabToElement('#print-button')
.should('contain', 'Print')
.and('have.focus');

cy.realPress('Tab');
cy.get(Locators.BUTTONS.MOVE)
.should(`contain`, `Move`)
.and('have.focus');

cy.realPress('Tab');
cy.get(Locators.BUTTONS.TRASH)
.should(`contain`, `Trash`)
.and('have.focus');
PatientMessageDetailsPage.verifyReplyButtonByKeyboard('reply');
PatientMessageDetailsPage.verifySingleButtonByKeyboard('print');
PatientMessageDetailsPage.verifySingleButtonByKeyboard('move');
PatientMessageDetailsPage.verifySingleButtonByKeyboard('trash');

cy.injectAxe();
cy.axeCheck(AXE_CONTEXT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('handle multiple drafts older than 45 days', () => {

cy.get(Locators.ALERTS.EXPIRED_MESSAGE)
.should('be.visible')
.and('have.text', Alerts.OLD_MSG);
.and('have.text', Alerts.OLD_MSG_HEAD);

cy.get(Locators.BUTTONS.EDIT_DRAFTS).should('not.exist');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import SecureMessagingSite from '../sm_site/SecureMessagingSite';
import PatientMessageDetailsPage from '../pages/PatientMessageDetailsPage';
import mockMessages from '../fixtures/messages-response.json';
import singleThreadResponse from '../fixtures/thread-response-new-api.json';
import PatientInboxPage from '../pages/PatientInboxPage';
import PatientInterstitialPage from '../pages/PatientInterstitialPage';
import FolderLoadPage from '../pages/FolderLoadPage';
import { Alerts, AXE_CONTEXT, Data } from '../utils/constants';
import PatientComposePage from '../pages/PatientComposePage';
import GeneralFunctionsPage from '../pages/GeneralFunctionsPage';
import PatientReplyPage from '../pages/PatientReplyPage';
import PatientInterstitialPage from '../pages/PatientInterstitialPage';

describe('SM NAVIGATE AWAY FROM UNSAVED REPLY DRAFT', () => {
const updatedSingleThreadResponse = GeneralFunctionsPage.updatedThreadDates(
singleThreadResponse,
);

beforeEach(() => {
SecureMessagingSite.login();
const testMessage = PatientInboxPage.getNewMessageDetails();
PatientInboxPage.loadInboxMessages(mockMessages, testMessage);
PatientMessageDetailsPage.loadMessageDetails(testMessage);
PatientMessageDetailsPage.loadReplyPageDetails(testMessage);
PatientInterstitialPage.getContinueButton().click({
waitForAnimations: true,
});
PatientInboxPage.loadInboxMessages();
PatientMessageDetailsPage.loadSingleThread(updatedSingleThreadResponse);

PatientReplyPage.clickReplyButton(updatedSingleThreadResponse);
PatientInterstitialPage.getContinueButton().click();
});

it('navigate away with no data', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class FolderLoadPage {
cy.get(Locators.BACK_TO).click({ force: true });
};

backToFolder = name => {
backToInbox = name => {
cy.get(Locators.LINKS.CRUMB)
.contains(name)
.click({ force: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,88 +57,6 @@ class FolderManagementPage {
cy.wait('@customFolderMessages');
};

loadCustomFolderMessageDetails = (
mockParentMessageDetails,
mockThread = defaultMockThread,
previousMessageIndex = 1,
mockPreviousMessageDetails = mockCustomResponse,
) => {
this.currentThread = mockThread;

this.currentThread.data.at(0).id =
mockParentMessageDetails.data.attributes.messageId;
this.currentThread.data.at(0).attributes.messageId =
mockParentMessageDetails.data.attributes.messageId;
this.currentThread.data.at(0).attributes.subject =
mockParentMessageDetails.data.attributes.subject;
this.currentThread.data.at(0).attributes.body =
mockParentMessageDetails.data.attributes.body;
this.currentThread.data.at(0).attributes.category =
mockParentMessageDetails.data.attributes.category;
this.currentThread.data.at(0).attributes.recipientId =
mockParentMessageDetails.data.attributes.recipientId;
this.currentThread.data.at(0).attributes.senderName =
mockParentMessageDetails.data.attributes.senderName;
this.currentThread.data.at(0).attributes.recipientName =
mockParentMessageDetails.data.attributes.recipientName;

cy.log(
`loading parent message details.${
this.currentThread.data.at(0).attributes.messageId
}`,
);
if (this.currentThread.data.lenghth > 1) {
this.currentThread.data.at(previousMessageIndex).attributes.sentDate =
mockPreviousMessageDetails.data.attributes.sentDate;
this.currentThread.data.at(previousMessageIndex).id =
mockPreviousMessageDetails.data.attributes.messageId;
this.currentThread.data.at(previousMessageIndex).attributes.messageId =
mockPreviousMessageDetails.data.attributes.messageId;
this.currentThread.data.at(previousMessageIndex).attributes.subject =
mockPreviousMessageDetails.data.attributes.subject;
this.currentThread.data.at(previousMessageIndex).attributes.body =
mockPreviousMessageDetails.data.attributes.body;
this.currentThread.data.at(previousMessageIndex).attributes.category =
mockPreviousMessageDetails.data.attributes.category;
this.currentThread.data.at(previousMessageIndex).attributes.recipientId =
mockPreviousMessageDetails.data.attributes.recipientId;
this.currentThread.data.at(previousMessageIndex).attributes.senderName =
mockPreviousMessageDetails.data.attributes.senderName;
this.currentThread.data.at(
previousMessageIndex,
).attributes.recipientName =
mockPreviousMessageDetails.data.attributes.recipientName;
this.currentThread.data.at(
previousMessageIndex,
).attributes.triageGroupName =
mockPreviousMessageDetails.data.attributes.triageGroupName;
}
cy.log(
`message thread = ${JSON.stringify(
mockParentMessageDetails.data.attributes.messageId,
)}`,
);
cy.intercept(
'GET',
`${Paths.INTERCEPT.MESSAGES}/${
this.currentThread.data.at(0).attributes.messageId
}`,
mockParentMessageDetails,
).as('message1');

cy.intercept(
'GET',
`${Paths.INTERCEPT.MESSAGES}/${
mockParentMessageDetails.data.attributes.messageId
}/thread`,
this.currentThread,
).as('full-thread');

cy.contains(mockParentMessageDetails.data.attributes.subject).click();
cy.wait('@message1', { timeout: 10000 });
// cy.wait('@full-thread');
};

folderConfirmation = () => {
return cy.get('[data-testid="alert-text"]');
};
Expand Down Expand Up @@ -180,12 +98,14 @@ class FolderManagementPage {
cy.get(`#radiobutton-${folderName}`).click();
};

moveMessageToFolder = (folderId = `-3`) => {
confirmMovingMessageToFolder = (
mockResponse = mockCustomResponse,
folderId = `-3`,
) => {
cy.intercept(
'PATCH',
`${Paths.INTERCEPT.MESSAGE_THREADS +
mockCustomResponse.data.attributes
.threadId}/move?folder_id=${folderId}`,
mockResponse.data.attributes.threadId}/move?folder_id=${folderId}`,
{ statusCode: 204 },
).as('threadNoContent');
cy.get(Locators.ALERTS.MOVE_MODAL)
Expand Down
Loading

0 comments on commit 6e7ed0c

Please sign in to comment.