mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix(server): cannot render email template (#13957)
This commit is contained in:
parent
8d8becd0f7
commit
ebf06dc12e
3 changed files with 174 additions and 67 deletions
74
server/src/repositories/notification.repository.spec.ts
Normal file
74
server/src/repositories/notification.repository.spec.ts
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
import { EmailRenderRequest, EmailTemplate } from 'src/interfaces/notification.interface';
|
||||
import { NotificationRepository } from 'src/repositories/notification.repository';
|
||||
import { Mocked } from 'vitest';
|
||||
|
||||
describe(NotificationRepository.name, () => {
|
||||
let sut: NotificationRepository;
|
||||
let loggerMock: Mocked<ILoggerRepository>;
|
||||
|
||||
beforeEach(() => {
|
||||
loggerMock = {
|
||||
setContext: vitest.fn(),
|
||||
debug: vitest.fn(),
|
||||
} as unknown as Mocked<ILoggerRepository>;
|
||||
|
||||
sut = new NotificationRepository(loggerMock);
|
||||
});
|
||||
|
||||
describe('renderEmail', () => {
|
||||
it('should render the email correctly for TEST_EMAIL template', async () => {
|
||||
const request: EmailRenderRequest = {
|
||||
template: EmailTemplate.TEST_EMAIL,
|
||||
data: { displayName: 'Alen Turing', baseUrl: 'http://localhost' },
|
||||
};
|
||||
|
||||
const result = await sut.renderEmail(request);
|
||||
|
||||
expect(result.html).toContain('<!DOCTYPE html PUBLIC');
|
||||
expect(result.text).toContain('test email');
|
||||
});
|
||||
|
||||
it('should render the email correctly for WELCOME template', async () => {
|
||||
const request: EmailRenderRequest = {
|
||||
template: EmailTemplate.WELCOME,
|
||||
data: { displayName: 'Alen Turing', username: 'turing', baseUrl: 'http://localhost' },
|
||||
};
|
||||
|
||||
const result = await sut.renderEmail(request);
|
||||
|
||||
expect(result.html).toContain('<!DOCTYPE html PUBLIC');
|
||||
expect(result.text).toContain('A new account has been created for you');
|
||||
});
|
||||
|
||||
it('should render the email correctly for ALBUM_INVITE template', async () => {
|
||||
const request: EmailRenderRequest = {
|
||||
template: EmailTemplate.ALBUM_INVITE,
|
||||
data: {
|
||||
albumName: 'Vacation',
|
||||
albumId: '123',
|
||||
senderName: 'John',
|
||||
recipientName: 'Jane',
|
||||
baseUrl: 'http://localhost',
|
||||
},
|
||||
};
|
||||
|
||||
const result = await sut.renderEmail(request);
|
||||
|
||||
expect(result.html).toContain('<!DOCTYPE html PUBLIC');
|
||||
expect(result.text).toContain('Vacation');
|
||||
});
|
||||
|
||||
it('should render the email correctly for ALBUM_UPDATE template', async () => {
|
||||
const request: EmailRenderRequest = {
|
||||
template: EmailTemplate.ALBUM_UPDATE,
|
||||
data: { albumName: 'Holiday', albumId: '123', recipientName: 'Jane', baseUrl: 'http://localhost' },
|
||||
};
|
||||
|
||||
const result = await sut.renderEmail(request);
|
||||
|
||||
expect(result.html).toContain('<!DOCTYPE html PUBLIC');
|
||||
expect(result.text).toContain('Holiday');
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue