-
Notifications
You must be signed in to change notification settings - Fork 126
/
secure-messaging-multiple-drafts-resave.cypress.spec.js
91 lines (81 loc) · 2.6 KB
/
secure-messaging-multiple-drafts-resave.cypress.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import SecureMessagingSite from '../sm_site/SecureMessagingSite';
import PatientInboxPage from '../pages/PatientInboxPage';
import { AXE_CONTEXT, Locators } from '../utils/constants';
import PatientMessageDraftsPage from '../pages/PatientMessageDraftsPage';
import mockMultiDraftsResponse from '../fixtures/draftsResponse/multi-draft-response.json';
describe('re-save multiple drafts in one thread', () => {
const site = new SecureMessagingSite();
const landingPage = new PatientInboxPage();
const draftPage = new PatientMessageDraftsPage();
const updateDates = data => {
const currentDate = new Date();
return {
...data,
data: data.data.map((item, i) => {
const newSentDate = new Date(currentDate);
const newDraftDate = new Date(currentDate);
newSentDate.setDate(currentDate.getDate() - i);
newDraftDate.setDate(currentDate.getDate() - i);
return {
...item,
attributes: {
...item.attributes,
sentDate:
item.attributes.sentDate != null
? newSentDate.toISOString()
: null,
draftDate:
item.attributes.draftDate != null
? newDraftDate.toISOString()
: null,
},
};
}),
};
};
const updatedMultiDraftResponse = updateDates(mockMultiDraftsResponse);
beforeEach(() => {
site.login();
landingPage.loadInboxMessages();
draftPage.loadMultiDraftThread(updatedMultiDraftResponse);
});
it('verify first draft could be re-saved', () => {
cy.injectAxe();
cy.axeCheck(AXE_CONTEXT, {
rules: {
'aria-required-children': {
enabled: false,
},
},
});
cy.get('textarea').type('newText', { force: true });
draftPage.saveMultiDraftMessage(
updatedMultiDraftResponse.data[0],
updatedMultiDraftResponse.data[0].attributes.messageId,
);
cy.get(Locators.ALERTS.SAVE_DRAFT).should(
'include.text',
'message was saved',
);
});
it('verify second draft could be re-saved', () => {
cy.injectAxe();
cy.axeCheck(AXE_CONTEXT, {
rules: {
'aria-required-children': {
enabled: false,
},
},
});
cy.get('#edit-draft-button').click({ waitForAnimations: true });
cy.get('textarea').type('newText', { force: true });
draftPage.saveMultiDraftMessage(
updatedMultiDraftResponse.data[1],
updatedMultiDraftResponse.data[1].attributes.messageId,
);
cy.get(Locators.ALERTS.SAVE_DRAFT).should(
'include.text',
'message was saved',
);
});
});