Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion backend/src/sponsorDocs/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1675,10 +1675,26 @@ export function renderSponsorEmailDraft(options: {
return { subject, body };
}

if (options.template === 'podcast-episode-brief') {
const firstName = options.recipientName?.trim().split(/\s+/)[0];
const body = [
firstName ? `Hi ${firstName},` : 'Hi <NAME>,',
'',
`Here is the episode brief with the structure and questions for ${pubDate}:`,
'',
options.shareUrl,
`(Access code if prompted: ${options.accessCode})`,
'',
'Please have a look and let us know if you would like any changes to the structure or the questions.',
'',
'Thank you!',
].join('\n');
return { subject, body };
}

if (
options.template === 'podcast-guest-research'
|| options.template === 'podcast-run-sheet'
|| options.template === 'podcast-episode-brief'
) {
const body = [
'Hi team,',
Expand Down
25 changes: 25 additions & 0 deletions backend/tests/podcast-doc-email.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { renderSponsorEmailDraft } from '../src/sponsorDocs/templates';

const base = { sponsorName: 'Sofiia Hordiienko', publicationDate: '2026-11-20 15:00', shareUrl: 'https://example.test/doc', accessCode: 'code-1' };

describe('podcast doc emails', () => {
it('renders a guest email for the episode brief', () => {
const { body } = renderSponsorEmailDraft({ ...base, template: 'podcast-episode-brief', recipientName: 'Sofiia Hordiienko' });
assert.match(body, /Hi Sofiia,/);
assert.match(body, /episode brief with the structure and questions for 2026-11-20 15:00/);
assert.match(body, /https:\/\/example\.test\/doc/);
assert.match(body, /code-1/);
assert.match(body, /any changes/);
assert.doesNotMatch(body, /Hi team|staff-only|Internal/);
});

for (const template of ['podcast-guest-research', 'podcast-run-sheet'] as const) {
it(`keeps staff wording for ${template}`, () => {
const { body } = renderSponsorEmailDraft({ ...base, template });
assert.match(body, /Hi team,/);
assert.match(body, /staff-only working document/);
});
}
});