Skip to content

Commit

Permalink
Add e2e tests for pno form sent message list
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Sep 30, 2024
1 parent 0ee18d1 commit e787242
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
INSERT INTO public.prior_notification_sent_messages (
prior_notification_report_id, prior_notification_source, date_time_utc, communication_means, recipient_address_or_number, success, error_message, recipient_name, recipient_organization
prior_notification_report_id, prior_notification_source, date_time_utc, communication_means, recipient_address_or_number, success, error_message, recipient_name, recipient_organization
) VALUES
( 'FAKE_OPERATION_103', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 1', 'Douane'),
( 'FAKE_OPERATION_106', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 1', 'Douane'),
( 'FAKE_OPERATION_106', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 3', 'Gendarmerie'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 4', 'Gendarmerie'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 3', 'Gendarmerie'),
( 'FAKE_OPERATION_110', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 6', 'DDTM'),
( 'FAKE_OPERATION_110', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 7', 'Office Français de la Biodiversité'),
( 'FAKE_OPERATION_110', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'SMS', '+33123456789', FALSE, NULL, 'Unité 7', 'Office Français de la Biodiversité'),
('00000000-0000-4000-0000-000000000003', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 9', 'DDTM'),
('00000000-0000-4000-0000-000000000003', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 10', 'DIRM / DM'),
('00000000-0000-4000-0000-000000000004', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 11', 'DDTM'),
('00000000-0000-4000-0000-000000000006', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 11', 'DDTM'),
('00000000-0000-4000-0000-000000000008', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 12', 'DIRM / DM'),
('00000000-0000-4000-0000-000000000010', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 12', 'DIRM / DM');

( 'FAKE_OPERATION_103', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 1', 'Douane'),

( 'FAKE_OPERATION_106', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 1', 'Douane'),
( 'FAKE_OPERATION_106', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 3', 'Gendarmerie'),

( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.3 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 3', 'Gendarmerie'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 4', 'Gendarmerie'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.1 minutes', 'SMS', '+33123456789', FALSE, NULL, 'Unité 3', 'Gendarmerie'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.2 minutes', 'SMS', '+33987654321', FALSE, NULL, 'Unité 4', 'Gendarmerie'),

( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '4.0 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 3', 'Gendarmerie'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '4.1 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 4', 'Gendarmerie'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '4.2 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 5', 'DDTM 40'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '4.3 minutes', 'SMS', '+33123456789', TRUE, NULL, 'Unité 3', 'Gendarmerie'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '4.4 minutes', 'SMS', '+33987654321', FALSE, NULL, 'Unité 4', 'Gendarmerie'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '4.5 minutes', 'SMS', '+33000000000', FALSE, NULL, 'Unité 5', 'DDTM 40'),

( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '9.3 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 3', 'Gendarmerie'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '9.2 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 4', 'Gendarmerie'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '9.1 minutes', 'SMS', '+33123456789', TRUE, NULL, 'Unité 3', 'Gendarmerie'),
( 'FAKE_OPERATION_108', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '9.0 minutes', 'SMS', '+33987654321', TRUE, NULL, 'Unité 4', 'Gendarmerie'),

( 'FAKE_OPERATION_110', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 6', 'DDTM'),
( 'FAKE_OPERATION_110', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 7', 'Office Français de la Biodiversité'),
( 'FAKE_OPERATION_110', 'LOGBOOK', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'SMS', '+33111111111', FALSE, NULL, 'Unité 7', 'Office Français de la Biodiversité'),

('00000000-0000-4000-0000-000000000003', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 9', 'DDTM'),
('00000000-0000-4000-0000-000000000003', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 10', 'DIRM / DM'),

('00000000-0000-4000-0000-000000000004', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 11', 'DDTM'),

('00000000-0000-4000-0000-000000000006', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 11', 'DDTM'),

('00000000-0000-4000-0000-000000000008', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', FALSE, NULL, 'Unité 12', 'DIRM / DM'),

('00000000-0000-4000-0000-000000000010', 'MANUAL', NOW() AT TIME ZONE 'UTC' - INTERVAL '2.0 minutes', 'EMAIL', '[email protected]', TRUE, NULL, 'Unité 12', 'DIRM / DM');
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { editSideWindowPriorNotification } from './utils'

context('Side Window > Logbook Prior Notification Form > Error Handling', () => {
const failedQueryCount = RTK_MAX_RETRIES + 1
const url = '/bff/v1/prior_notifications/FAKE_OPERATION_109_COR?isManuallyCreated=false&operationDate=*'

it('Should handle fetching error as expected', () => {
const url = '/bff/v1/prior_notifications/FAKE_OPERATION_109_COR?isManuallyCreated=false&operationDate=*'

cy.intercept(
{
method: 'GET',
Expand All @@ -32,4 +33,30 @@ context('Side Window > Logbook Prior Notification Form > Error Handling', () =>

cy.contains(`L'ANCRE SÈCHE (CFR106)`).should('be.visible')
})

it('Should handle sent message list fetching error as expected', () => {
const url = '/bff/v1/prior_notifications/FAKE_OPERATION_108/sent_messages'

cy.intercept(
{
method: 'GET',
times: failedQueryCount,
url
},
{
statusCode: 400
}
).as('getPriorNotificationSentMessagesWithError')

editSideWindowPriorNotification(`CALAMARO`, 'FAKE_OPERATION_108')

cy.clickButton('Voir les détails de la diffusion du préavis')

for (let i = 1; i <= failedQueryCount; i += 1) {
cy.wait('@getPriorNotificationSentMessagesWithError')
}

cy.contains(`Impossible de récupérer la liste.`).should('be.visible')
cy.contains(`Impossible de récupérer l’historique.`).should('be.visible')
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { editSideWindowPriorNotification } from './utils'

context('Side Window > Logbook Prior Notification Form > Sent Message List', () => {
it('Should display the expected list of subscribers and sent messages history', () => {
editSideWindowPriorNotification(`CALAMARO`, 'FAKE_OPERATION_108')

cy.intercept('GET', `/bff/v1/prior_notifications/FAKE_OPERATION_108/sent_messages`).as(
'getPriorNotificationSentMessages'
)

cy.clickButton('Voir les détails de la diffusion du préavis')

cy.wait('@getPriorNotificationSentMessages')

cy.get('address').eq(0).contains('Unité 3 (Gendarmerie)')
cy.get('address').eq(0).contains('[email protected]')
cy.get('address').eq(0).contains('+33123456789')

cy.get('address').eq(1).contains('Unité 4 (Gendarmerie)')
cy.get('address').eq(1).contains('[email protected]')
cy.get('address').eq(1).contains('+33987654321')

cy.get('address').eq(2).contains('Unité 5 (DDTM 40)')
cy.get('address').eq(2).contains('[email protected]')
cy.get('address').eq(2).contains('+33000000000')

cy.getDataCy('SentMessageList-historyItem')
.eq(0)
.contains(
'Échec de la diffusion pour tous les contacts: [email protected], +33987654321, +33123456789, [email protected].'
)

cy.getDataCy('SentMessageList-historyItem')
.eq(1)
.contains(
'Échec de la diffusion pour le(s) contact(s): +33000000000, +33987654321, [email protected], [email protected].'
)

cy.getDataCy('SentMessageList-historyItem').eq(2).contains('Préavis diffusé avec succès à tous les contacts.')
})
})

0 comments on commit e787242

Please sign in to comment.