1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00

feat: now you can add env type to env order (#8442)

This commit is contained in:
Jaanus Sellin 2024-10-14 13:26:38 +03:00 committed by GitHub
parent a3dd51734e
commit 735e6f0b23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 28 additions and 9 deletions

View File

@ -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(`<li>${environments[0]}</li>`)).toBe(true);
expect(content.html.includes(`<li>${environments[1]}</li>`)).toBe(true);
expect(
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.bcc).toBe('bcc@bcc.com');
});

View File

@ -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<IEmailEnvelope> {
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,

View File

@ -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>
<ul>
{{#environments}}
<li>{{.}}</li>
<li>Name: {{name}}, Type: {{type}}</li>
{{/environments}}
</ul>
<p>Please note that it may take up to 24 hours for these changes to come into effect.</p>

View File

@ -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.