diff --git a/src/lib/services/email-service.test.ts b/src/lib/services/email-service.test.ts index 8f97838342..bc80bf148d 100644 --- a/src/lib/services/email-service.test.ts +++ b/src/lib/services/email-service.test.ts @@ -118,7 +118,11 @@ test('Can send order environments email', async () => { } as unknown as IUnleashConfig); const customerId = 'customer133'; - const environments = ['development', 'production']; + const environments = [ + { name: 'test', type: 'development' }, + { name: 'live', type: 'production' }, + ]; + const content = await emailService.sendOrderEnvironmentEmail( 'user@user.com', customerId, @@ -126,8 +130,16 @@ test('Can send order environments email', async () => { ); expect(content.from).toBe('noreply@getunleash.ai'); expect(content.subject).toBe('Unleash - ordered environments successfully'); - expect(content.html.includes(`
  • ${environments[0]}
  • `)).toBe(true); - expect(content.html.includes(`
  • ${environments[1]}
  • `)).toBe(true); + expect( + content.html.includes( + `
  • Name: ${environments[0].name}, Type: ${environments[0].type}
  • `, + ), + ).toBe(true); + expect( + content.html.includes( + `
  • Name: ${environments[1].name}, Type: ${environments[1].type}
  • `, + ), + ).toBe(true); expect(content.html.includes(customerId)).toBe(true); expect(content.bcc).toBe('bcc@bcc.com'); }); diff --git a/src/lib/services/email-service.ts b/src/lib/services/email-service.ts index 3f24abde52..94e60a0c9f 100644 --- a/src/lib/services/email-service.ts +++ b/src/lib/services/email-service.ts @@ -63,6 +63,11 @@ export type ChangeRequestScheduleConflictData = environment: string; }; +export type OrderEnvironmentData = { + name: string; + type: string; +}; + export class EmailService { private logger: Logger; private config: IUnleashConfig; @@ -453,16 +458,18 @@ export class EmailService { async sendOrderEnvironmentEmail( userEmail: string, customerId: string, - environmentNames: string[], + environments: OrderEnvironmentData[], ): Promise { if (this.configured()) { const context = { userEmail, customerId, - environments: environmentNames.map((name) => - this.stripSpecialCharacters(name), - ), + environments: environments.map((data) => ({ + name: this.stripSpecialCharacters(data.name), + type: this.stripSpecialCharacters(data.type), + })), }; + const bodyHtml = await this.compileTemplate( 'order-environments', TemplateFormat.HTML, diff --git a/src/mailtemplates/order-environments/order-environments.html.mustache b/src/mailtemplates/order-environments/order-environments.html.mustache index e2971d2ce9..9e87f8b6d1 100644 --- a/src/mailtemplates/order-environments/order-environments.html.mustache +++ b/src/mailtemplates/order-environments/order-environments.html.mustache @@ -341,7 +341,7 @@

    An order for additional environments has been successfully submitted by {{{ userEmail }}} for customer ID {{{ customerId }}}. Below are the details of the environments requested:

    Please note that it may take up to 24 hours for these changes to come into effect.

    diff --git a/src/mailtemplates/order-environments/order-environments.plain.mustache b/src/mailtemplates/order-environments/order-environments.plain.mustache index e12da06c27..db3615ad1b 100644 --- a/src/mailtemplates/order-environments/order-environments.plain.mustache +++ b/src/mailtemplates/order-environments/order-environments.plain.mustache @@ -5,7 +5,7 @@ Hello, An order for additional environments has been successfully submitted by {{ userEmail }} for customer ID {{ customerId }}. Below are the details of the environments requested: {{#environments}} - - {{.}} + - Name: {{name}}, Type: {{type}} {{/environments}} Please note that it may take up to 24 hours for these changes to come into effect.