From c5c3b7964c2049f9d086355ac7fb83041ebf3b5d Mon Sep 17 00:00:00 2001 From: Alexey Grigorev Date: Mon, 9 Nov 2026 10:56:17 +0100 Subject: [PATCH] Render a guest email for podcast-episode-brief docs Staff wording stays for guest-research and host-run-sheet kinds. --- backend/src/sponsorDocs/templates.ts | 18 +++++++++++++++++- backend/tests/podcast-doc-email.test.ts | 25 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 backend/tests/podcast-doc-email.test.ts diff --git a/backend/src/sponsorDocs/templates.ts b/backend/src/sponsorDocs/templates.ts index 1f29498b..a1cf3b36 100644 --- a/backend/src/sponsorDocs/templates.ts +++ b/backend/src/sponsorDocs/templates.ts @@ -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 ,', + '', + `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,', diff --git a/backend/tests/podcast-doc-email.test.ts b/backend/tests/podcast-doc-email.test.ts new file mode 100644 index 00000000..f4a1ac12 --- /dev/null +++ b/backend/tests/podcast-doc-email.test.ts @@ -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/); + }); + } +});