Skip to content

Commit 5509211

Browse files
author
hjen_adobe
committed
update to use correct template
1 parent b8355b2 commit 5509211

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

src/support/opportunity-workspace-notifications.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ export function detectStatusChanges(prevData, nextData, log) {
223223
opportunityName: nextOpp.name || nextOpp.opportunityId,
224224
assigneeBefore: '',
225225
assigneeAfter: nextOpp.assignee,
226+
statusAfter: nextOpp.status,
226227
recipients: filterValidEmails([nextOpp.assignee, nextStrategy.createdBy], log),
227228
createdBy: nextStrategy.createdBy || '',
228229
assignee: nextOpp.assignee,
@@ -259,6 +260,7 @@ export function detectStatusChanges(prevData, nextData, log) {
259260
opportunityName: nextOpp.name || nextOpp.opportunityId,
260261
assigneeBefore: prevOpp.assignee || '',
261262
assigneeAfter: nextOpp.assignee,
263+
statusAfter: nextOpp.status,
262264
recipients: filterValidEmails([nextOpp.assignee, nextStrategy.createdBy], log),
263265
createdBy: nextStrategy.createdBy || '',
264266
assignee: nextOpp.assignee,
@@ -292,7 +294,6 @@ export async function sendStatusChangeNotifications(context, {
292294

293295
const oppTemplateName = 'llmo_opportunity_status_update';
294296
const stratTemplateName = 'llmo_strategy_update';
295-
const assignTemplateName = 'llmo_opportunity_assignment';
296297

297298
const hostname = extractHostnameFromBaseURL(siteBaseUrl || '');
298299
const strategyUrl = hostname
@@ -306,9 +307,7 @@ export async function sendStatusChangeNotifications(context, {
306307
} else {
307308
const isOpportunity = change.type === 'opportunity';
308309
const isAssignment = change.type === 'assignment';
309-
let templateName = stratTemplateName;
310-
if (isAssignment) templateName = assignTemplateName;
311-
else if (isOpportunity) templateName = oppTemplateName;
310+
const templateName = (isOpportunity || isAssignment) ? oppTemplateName : stratTemplateName;
312311

313312
const createdBy = change.createdBy || '';
314313
if (!createdBy) {
@@ -332,19 +331,7 @@ export async function sendStatusChangeNotifications(context, {
332331
const recipientName = await resolveUserName(dataAccess, recipient);
333332

334333
let templateData;
335-
if (isAssignment) {
336-
templateData = {
337-
recipient_name: recipientName,
338-
recipient_email: recipient,
339-
assignee_name: assigneeName,
340-
assignee_email: assigneeEmail,
341-
strategy_owner_name: strategyOwnerName,
342-
strategy_owner_email: strategyOwnerEmail,
343-
opportunity_name: change.opportunityName || '',
344-
strategy_name: change.strategyName,
345-
strategy_url: strategyUrl,
346-
};
347-
} else if (isOpportunity) {
334+
if (isOpportunity || isAssignment) {
348335
templateData = {
349336
recipient_name: recipientName,
350337
recipient_email: recipient,

test/support/opportunity-workspace-notifications.test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ describe('opportunity-workspace-notifications', () => {
419419
expect(changes[0].opportunityName).to.equal('New Opp');
420420
expect(changes[0].assigneeBefore).to.equal('');
421421
expect(changes[0].assigneeAfter).to.equal('user@test.com');
422+
expect(changes[0].statusAfter).to.equal('new');
422423
expect(changes[0].recipients).to.include('user@test.com');
423424
expect(changes[0].recipients).to.include('owner@test.com');
424425
});
@@ -474,6 +475,7 @@ describe('opportunity-workspace-notifications', () => {
474475
expect(changes[0].type).to.equal('assignment');
475476
expect(changes[0].assigneeBefore).to.equal('');
476477
expect(changes[0].assigneeAfter).to.equal('user@test.com');
478+
expect(changes[0].statusAfter).to.equal('new');
477479
});
478480

479481
it('should emit assignment change when assignee changes from one user to another', () => {
@@ -505,6 +507,7 @@ describe('opportunity-workspace-notifications', () => {
505507
expect(changes[0].type).to.equal('assignment');
506508
expect(changes[0].assigneeBefore).to.equal('user1@test.com');
507509
expect(changes[0].assigneeAfter).to.equal('user2@test.com');
510+
expect(changes[0].statusAfter).to.equal('new');
508511
});
509512

510513
it('should not emit assignment change when assignee is removed', () => {
@@ -567,6 +570,7 @@ describe('opportunity-workspace-notifications', () => {
567570
expect(statusChange.statusAfter).to.equal('completed');
568571
expect(assignmentChange.assigneeBefore).to.equal('user1@test.com');
569572
expect(assignmentChange.assigneeAfter).to.equal('user2@test.com');
573+
expect(assignmentChange.statusAfter).to.equal('completed');
570574
});
571575

572576
it('should collect all assignees for strategy status change', () => {
@@ -809,7 +813,7 @@ describe('opportunity-workspace-notifications', () => {
809813
expect(emailOptions.templateData.strategy_url).to.equal('https://llmo.now/www.example.com/insights/opportunity-workspace');
810814
});
811815

812-
it('should send assignment change email with llmo_opportunity_assignment template', async () => {
816+
it('should send assignment change email with llmo_opportunity_status_update template', async () => {
813817
const changes = [{
814818
type: 'assignment',
815819
strategyId: 's1',
@@ -818,6 +822,7 @@ describe('opportunity-workspace-notifications', () => {
818822
opportunityName: 'Opp 1',
819823
assigneeBefore: '',
820824
assigneeAfter: 'user@test.com',
825+
statusAfter: 'new',
821826
recipients: ['user@test.com'],
822827
createdBy: 'owner@test.com',
823828
assignee: 'user@test.com',
@@ -830,7 +835,7 @@ describe('opportunity-workspace-notifications', () => {
830835
expect(summary.sent).to.equal(1);
831836
expect(sendEmailStub).to.have.been.calledOnce;
832837
const [, emailOptions] = sendEmailStub.firstCall.args;
833-
expect(emailOptions.templateName).to.equal('llmo_opportunity_assignment');
838+
expect(emailOptions.templateName).to.equal('llmo_opportunity_status_update');
834839
expect(emailOptions.recipients).to.deep.equal(['user@test.com']);
835840
});
836841

@@ -843,6 +848,7 @@ describe('opportunity-workspace-notifications', () => {
843848
opportunityName: 'Opp 1',
844849
assigneeBefore: 'user1@test.com',
845850
assigneeAfter: 'user2@test.com',
851+
statusAfter: 'in_progress',
846852
recipients: ['user2@test.com'],
847853
createdBy: 'owner@test.com',
848854
assignee: 'user2@test.com',
@@ -860,6 +866,7 @@ describe('opportunity-workspace-notifications', () => {
860866
expect(emailOptions.templateData.strategy_owner_name).to.equal('Owner Smith');
861867
expect(emailOptions.templateData.strategy_owner_email).to.equal('owner@test.com');
862868
expect(emailOptions.templateData.opportunity_name).to.equal('Opp 1');
869+
expect(emailOptions.templateData.opportunity_status).to.equal('in_progress');
863870
expect(emailOptions.templateData.strategy_name).to.equal('Strategy 1');
864871
expect(emailOptions.templateData.strategy_url).to.equal('https://llmo.now/www.example.com/insights/opportunity-workspace');
865872
});
@@ -873,6 +880,7 @@ describe('opportunity-workspace-notifications', () => {
873880
opportunityName: 'Opp 1',
874881
assigneeBefore: '',
875882
assigneeAfter: 'user@test.com',
883+
statusAfter: 'new',
876884
recipients: ['user@test.com'],
877885
createdBy: '',
878886
assignee: 'user@test.com',

0 commit comments

Comments
 (0)