Skip to content

Commit

Permalink
[EASI-4023] New Discussion Reply Notification (#1024)
Browse files Browse the repository at this point in the history
* [EASI-3944] Notifications - On Discussion Replied Notification (#990)

* wip: draft of sending notifications on discussion reply

* wip: implementing PR feedback

* wip: implement various PR feedback

* wip: corrected actor ID to be reply creator ID and added discussion creator ID to meta

* fix: corrected notification recipient from actor to discussion creator

* feat: testing preview for discussion reply notification

* chore: updated postman collection

* fix: corrected activity meta base struct type

* chore: added comment to helper function

* chore: deleted unused generated resolver

* fix: revereted incorrectly changed user ID assignment

* removed irrelevant comment

* chore: added more assertions to unit test

* Add new reply type guard

* add more conditional renders based on type guard

* Add the new discussion reply gql fragment

* implementing new discussion reply into the UI

* Add a few more queries to the getNotification query

* Notification content to show on discussions

* add model name to util

* move notification settings to its own test

* add e2e test

---------

Co-authored-by: Tom Brooks <[email protected]>
  • Loading branch information
garyjzhao and OddTomBrooks authored Mar 29, 2024
1 parent e7f584d commit 1f216b7
Show file tree
Hide file tree
Showing 16 changed files with 1,199 additions and 54 deletions.
11 changes: 6 additions & 5 deletions MINT.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"info": {
"_postman_id": "32329f70-986e-430d-8a0b-4509ca71dab1",
"_postman_id": "e2043604-4cd9-443c-9267-db489feb92d8",
"name": "MINT",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "20320964"
"_exporter_id": "20435042"
},
"item": [
{
Expand Down Expand Up @@ -2089,7 +2089,8 @@
"// pm.collectionVariables.set(\"operationalSolutionSubtaskID\"+i, subtaskID);",
"// }"
],
"type": "text/javascript"
"type": "text/javascript",
"packages": {}
}
}
],
Expand All @@ -2099,7 +2100,7 @@
"body": {
"mode": "graphql",
"graphql": {
"query": "query currentUser {\n currentUser {\n notifications {\n numUnreadNotifications\n notifications {\n __typename\n id\n isRead\n inAppSent\n emailSent\n activity {\n activityType\n entityID\n actorID\n metaData {\n __typename\n ... on TaggedInPlanDiscussionActivityMeta{\n version\n type\n modelPlanID\n modelPlan{\n modelName\n } \n discussionID\n content\n }\n ... on TaggedInDiscussionReplyActivityMeta {\n version\n type\n modelPlanID\n modelPlan{\n modelName\n } \n discussionID\n replyID\n content\n }\n ... on DailyDigestCompleteActivityMeta{\n version\n type\n modelPlanIDs\n date\n analyzedAudits{\n id\n modelPlanID\n modelName\n date\n changes{\n modelPlan{\n oldName\n statusChanges\n }\n documents{\n count\n }\n crTdls{\n activity\n }\n planSections{\n updated\n readyForReview\n readyForClearance\n }\n modelLeads{\n added{\n id\n commonName\n # userAccount{\n # id\n # email\n # }\n }\n }\n planDiscussions{\n activity\n }\n }\n\n }\n\n } \n }\n createdByUserAccount {\n commonName\n }\n }\n createdByUserAccount {\n commonName\n }\n }\n }\n }\n}\n",
"query": "query currentUser {\n currentUser {\n notifications {\n numUnreadNotifications\n notifications {\n __typename\n id\n isRead\n inAppSent\n emailSent\n activity {\n activityType\n entityID\n actorID\n metaData {\n __typename\n ... on TaggedInPlanDiscussionActivityMeta{\n version\n type\n modelPlanID\n modelPlan{\n modelName\n } \n discussionID\n content\n }\n ... on TaggedInDiscussionReplyActivityMeta {\n version\n type\n modelPlanID\n modelPlan{\n modelName\n } \n discussionID\n replyID\n content\n }\n ... on NewDiscussionRepliedActivityMeta {\n version\n type\n discussionID\n replyID\n content\n } \n ... on DailyDigestCompleteActivityMeta{\n version\n type\n modelPlanIDs\n date\n analyzedAudits{\n id\n modelPlanID\n modelName\n date\n changes{\n modelPlan{\n oldName\n statusChanges\n }\n documents{\n count\n }\n crTdls{\n activity\n }\n planSections{\n updated\n readyForReview\n readyForClearance\n }\n modelLeads{\n added{\n id\n commonName\n # userAccount{\n # id\n # email\n # }\n }\n }\n planDiscussions{\n activity\n }\n }\n\n }\n\n } \n }\n createdByUserAccount {\n commonName\n }\n }\n createdByUserAccount {\n commonName\n }\n }\n }\n }\n}\n",
"variables": ""
}
},
Expand Down Expand Up @@ -2424,4 +2425,4 @@
"value": ""
}
]
}
}
99 changes: 85 additions & 14 deletions cypress/e2e/notification.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ describe('Notification Center', () => {

cy.contains('button', 'Save discussion').click();

cy.visit('/notifications');
cy.get('[data-testid="close-discussions"]').click();
cy.get('[data-testid="navmenu__notification"]').first().click();

// Actual Notification Test
cy.get('[data-testid="navmenu__notification"]')
Expand All @@ -67,7 +68,9 @@ describe('Notification Center', () => {
.find('button', 'View Discussion')
.click();

cy.visit('/notifications');
// Navigate to Notification page (faster than cy.visit)
cy.get('[data-testid="close-discussions"]').click();
cy.get('[data-testid="navmenu__notification"]').first().click();

// Check to see first entry should no longer have red dot
cy.get('[data-testid="individual-notification"]')
Expand All @@ -83,6 +86,30 @@ describe('Notification Center', () => {
'exist'
);
cy.get('[data-testid="notification-red-dot"]').should('have.length', 0);
});

it('navigates to see Daily Digest notification', () => {
cy.localLogin({ name: 'MINT', role: 'MINT_ASSESSMENT_NONPROD' });
cy.visit('/notifications');

cy.get('[data-testid="individual-notification"]')
.first()
.find('[data-testid="notification-red-dot"]')
.should('exist');
cy.contains('button', 'View digest').click();

cy.get('[data-testid="notification--daily-digest"').should('exist');

cy.contains('h3', 'Empty Plan').siblings('a').click();

cy.location().should(loc => {
expect(loc.pathname).to.match(/models\/.{36}\/read-only\/model-basics/);
});
});

it('navigates to see Notification Settings', () => {
cy.localLogin({ name: 'MINT', role: 'MINT_ASSESSMENT_NONPROD' });
cy.visit('/notifications');

// Notification Settings Test
cy.contains('a', 'Notification settings').click();
Expand All @@ -107,22 +134,66 @@ describe('Notification Center', () => {
);
});

it('navigates to see Daily Digest notification', () => {
cy.localLogin({ name: 'MINT', role: 'MINT_ASSESSMENT_NONPROD' });
cy.visit('/notifications');
it.only('testing New Discussion Reply Notification', () => {
cy.localLogin({ name: 'JTTC', role: 'MINT_ASSESSMENT_NONPROD' });
cy.clickPlanTableByName('Empty Plan');

// Create a discussion to start things off
cy.contains('button', 'Start a discussion').click();

cy.contains('h1', 'Start a discussion');

cy.contains('button', 'Save discussion').should('be.disabled');

cy.get('#user-role').should('not.be.disabled');

cy.get('#user-role').select('None of the above');

cy.get('#user-role-description')
.type('Designer')
.should('have.value', 'Designer');

cy.get('#mention-editor').type('@ana');
cy.get('#JTTC').contains('Anabelle Jerde (JTTC)').click();
cy.get('#mention-editor').type('First Notification');
cy.get('#mention-editor').should(
'have.text',
'@Anabelle Jerde (JTTC) First Notification'
);

cy.contains('button', 'Save discussion').click();

// New Discussion Reply test
cy.contains('button', 'Reply').click();

cy.contains('label', 'Type your reply');

cy.get('#mention-editor').type(
'Triggering new discussion reply notification'
);

cy.contains('button', 'Save reply').click();

cy.get('[data-testid="close-discussions"]').click();
cy.get('[data-testid="navmenu__notification"]').first().click();

cy.get('[data-testid="navmenu__notifications--yesNotification"').should(
'exist'
);

cy.get('[data-testid="individual-notification"]').should('have.length', 2);

cy.get('[data-testid="individual-notification"]')
.first()
.find('[data-testid="notification-red-dot"]')
.should('exist');
cy.contains('button', 'View digest').click();

cy.get('[data-testid="notification--daily-digest"').should('exist');
.find('button', 'View Discussion')
.click();

cy.contains('h3', 'Empty Plan').siblings('a').click();
cy.get('[data-testid="close-discussions"]').click();
cy.get('[data-testid="navmenu__notification"]').first().click();

cy.location().should(loc => {
expect(loc.pathname).to.match(/models\/.{36}\/read-only\/model-basics/);
});
cy.get('[data-testid="individual-notification"]')
.first()
.find('[data-testid="notification-red-dot"]')
.should('not.exist');
});
});
Loading

0 comments on commit 1f216b7

Please sign in to comment.