mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-18 00:19:49 +01:00
feat: now you can add env type to env order (#8442)
This commit is contained in:
parent
a3dd51734e
commit
735e6f0b23
@ -118,7 +118,11 @@ test('Can send order environments email', async () => {
|
|||||||
} as unknown as IUnleashConfig);
|
} as unknown as IUnleashConfig);
|
||||||
|
|
||||||
const customerId = 'customer133';
|
const customerId = 'customer133';
|
||||||
const environments = ['development', 'production'];
|
const environments = [
|
||||||
|
{ name: 'test', type: 'development' },
|
||||||
|
{ name: 'live', type: 'production' },
|
||||||
|
];
|
||||||
|
|
||||||
const content = await emailService.sendOrderEnvironmentEmail(
|
const content = await emailService.sendOrderEnvironmentEmail(
|
||||||
'user@user.com',
|
'user@user.com',
|
||||||
customerId,
|
customerId,
|
||||||
@ -126,8 +130,16 @@ test('Can send order environments email', async () => {
|
|||||||
);
|
);
|
||||||
expect(content.from).toBe('noreply@getunleash.ai');
|
expect(content.from).toBe('noreply@getunleash.ai');
|
||||||
expect(content.subject).toBe('Unleash - ordered environments successfully');
|
expect(content.subject).toBe('Unleash - ordered environments successfully');
|
||||||
expect(content.html.includes(`<li>${environments[0]}</li>`)).toBe(true);
|
expect(
|
||||||
expect(content.html.includes(`<li>${environments[1]}</li>`)).toBe(true);
|
content.html.includes(
|
||||||
|
`<li>Name: ${environments[0].name}, Type: ${environments[0].type}</li>`,
|
||||||
|
),
|
||||||
|
).toBe(true);
|
||||||
|
expect(
|
||||||
|
content.html.includes(
|
||||||
|
`<li>Name: ${environments[1].name}, Type: ${environments[1].type}</li>`,
|
||||||
|
),
|
||||||
|
).toBe(true);
|
||||||
expect(content.html.includes(customerId)).toBe(true);
|
expect(content.html.includes(customerId)).toBe(true);
|
||||||
expect(content.bcc).toBe('bcc@bcc.com');
|
expect(content.bcc).toBe('bcc@bcc.com');
|
||||||
});
|
});
|
||||||
|
@ -63,6 +63,11 @@ export type ChangeRequestScheduleConflictData =
|
|||||||
environment: string;
|
environment: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type OrderEnvironmentData = {
|
||||||
|
name: string;
|
||||||
|
type: string;
|
||||||
|
};
|
||||||
|
|
||||||
export class EmailService {
|
export class EmailService {
|
||||||
private logger: Logger;
|
private logger: Logger;
|
||||||
private config: IUnleashConfig;
|
private config: IUnleashConfig;
|
||||||
@ -453,16 +458,18 @@ export class EmailService {
|
|||||||
async sendOrderEnvironmentEmail(
|
async sendOrderEnvironmentEmail(
|
||||||
userEmail: string,
|
userEmail: string,
|
||||||
customerId: string,
|
customerId: string,
|
||||||
environmentNames: string[],
|
environments: OrderEnvironmentData[],
|
||||||
): Promise<IEmailEnvelope> {
|
): Promise<IEmailEnvelope> {
|
||||||
if (this.configured()) {
|
if (this.configured()) {
|
||||||
const context = {
|
const context = {
|
||||||
userEmail,
|
userEmail,
|
||||||
customerId,
|
customerId,
|
||||||
environments: environmentNames.map((name) =>
|
environments: environments.map((data) => ({
|
||||||
this.stripSpecialCharacters(name),
|
name: this.stripSpecialCharacters(data.name),
|
||||||
),
|
type: this.stripSpecialCharacters(data.type),
|
||||||
|
})),
|
||||||
};
|
};
|
||||||
|
|
||||||
const bodyHtml = await this.compileTemplate(
|
const bodyHtml = await this.compileTemplate(
|
||||||
'order-environments',
|
'order-environments',
|
||||||
TemplateFormat.HTML,
|
TemplateFormat.HTML,
|
||||||
|
@ -341,7 +341,7 @@
|
|||||||
<p>An order for additional environments has been successfully submitted by <strong>{{{ userEmail }}}</strong> for customer ID <strong>{{{ customerId }}}</strong>. Below are the details of the environments requested:</p>
|
<p>An order for additional environments has been successfully submitted by <strong>{{{ userEmail }}}</strong> for customer ID <strong>{{{ customerId }}}</strong>. Below are the details of the environments requested:</p>
|
||||||
<ul>
|
<ul>
|
||||||
{{#environments}}
|
{{#environments}}
|
||||||
<li>{{.}}</li>
|
<li>Name: {{name}}, Type: {{type}}</li>
|
||||||
{{/environments}}
|
{{/environments}}
|
||||||
</ul>
|
</ul>
|
||||||
<p>Please note that it may take up to 24 hours for these changes to come into effect.</p>
|
<p>Please note that it may take up to 24 hours for these changes to come into effect.</p>
|
||||||
|
@ -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:
|
An order for additional environments has been successfully submitted by {{ userEmail }} for customer ID {{ customerId }}. Below are the details of the environments requested:
|
||||||
|
|
||||||
{{#environments}}
|
{{#environments}}
|
||||||
- {{.}}
|
- Name: {{name}}, Type: {{type}}
|
||||||
{{/environments}}
|
{{/environments}}
|
||||||
|
|
||||||
Please note that it may take up to 24 hours for these changes to come into effect.
|
Please note that it may take up to 24 hours for these changes to come into effect.
|
||||||
|
Loading…
Reference in New Issue
Block a user