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
26 changes: 18 additions & 8 deletions backend/e2e/podcast-guest-form.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ test.describe("podcast guest materials form", () => {
linkedinUrl: "https://example.test/linkedin",
coldOpen: "SECRET_COLD_OPEN_HOOK",
introScript: "SECRET_INTRO_SCRIPT",
interviewQuestions: "SECRET_Q1_ARCHITECTURE\nSECRET_Q2_TRADEOFFS",
interviewQuestions: "SHARED_Q1_ARCHITECTURE\nSHARED_Q2_TRADEOFFS",
closingScript: "SECRET_CLOSING_SCRIPT",
goal: "SECRET_EPISODE_GOAL",
audience: "SECRET_TARGET_AUDIENCE",
Expand All @@ -178,25 +178,29 @@ test.describe("podcast guest materials form", () => {
},
});

// 1. Staff desktop view: sees two tabs, Host view + Edit prep & research, and saves internal changes
// 1. Staff desktop view: sees two tabs, shared interviewQuestions on Guest tab, Host view + Edit prep & research
await page.setViewportSize({ width: 1280, height: 900 });
await page.goto(`${server.baseURL}/podcast-docs/${doc.id}`);
await expect(page.locator('[data-podcast-tab="guest"]')).toBeVisible();
await expect(page.locator('[data-podcast-tab="internal"]')).toBeVisible();
await expect(page.locator('[data-podcast-panel="guest"]')).toBeVisible();
await expect(page.locator("#sponsor-field-interviewQuestions")).toHaveCount(0);
await expect(page.locator("#sponsor-field-interviewQuestions")).toHaveValue(
"SHARED_Q1_ARCHITECTURE\nSHARED_Q2_TRADEOFFS",
);
await expect(page.locator("#sponsor-field-coldOpen")).toHaveCount(0);

await page.locator('[data-podcast-tab="internal"]').click();
await expect(page.locator('[data-podcast-panel="internal"]')).toBeVisible();
await expect(page.locator('[data-podcast-questions-view="readonly"]')).toBeVisible();
await expect(page.locator('[data-podcast-host-block="coldOpen"]')).toContainText("SECRET_COLD_OPEN_HOOK");
await expect(page.locator('[data-podcast-host-block="interviewQuestions"]')).toContainText("SECRET_Q1_ARCHITECTURE");
await expect(page.locator('[data-podcast-host-block="interviewQuestions"]')).toContainText("SHARED_Q1_ARCHITECTURE");
await expect(page.locator('[data-podcast-host-block="topicsToAvoid"]')).toContainText("Confidential client contracts");
await expect(page.locator('[data-podcast-host-block="hostNotes"]')).toContainText("SECRET_HOST_TIMING_NOTE");
await expect(page.locator("[data-podcast-host-qna]")).toBeVisible();

await page.locator('[data-podcast-internal-mode="edit"]').click();
await expect(page.locator("#sponsor-field-interviewQuestions")).toBeVisible();
await expect(page.locator("#sponsor-field-interviewQuestions")).toHaveCount(0);
await expect(page.locator("#sponsor-field-coldOpen")).toBeVisible();
await expect(page.locator("#sponsor-field-sourceLinks")).toBeVisible();
await page.locator("#sponsor-field-hostNotes").fill("SECRET_HOST_TIMING_NOTE_UPDATED");
await page.locator('[data-sponsor-action="save-draft"]').click();
Expand All @@ -218,7 +222,7 @@ test.describe("podcast guest materials form", () => {
expect(hostOverflow.scrollWidth).toBeLessThanOrEqual(hostOverflow.clientWidth);

// 3. Anonymous guest browser context with valid ?code= (even requesting ?tab=internal&view=questions):
// never sees tabs, never sees View questions, never receives any internal content.
// sees interviewQuestions, never sees tabs, never sees View questions, never receives any internal content.
const guestContext = await browser.newContext({
extraHTTPHeaders: { "x-sponsor-doc-anonymous": "true" },
viewport: { width: 390, height: 844 },
Expand All @@ -233,11 +237,13 @@ test.describe("podcast guest materials form", () => {
await expect(guestPage.locator('[data-sponsor-action="toggle-questions-view"]')).toHaveCount(0);
await expect(guestPage.locator("[data-sponsor-export]")).toHaveCount(0);
await expect(guestPage.locator("#sponsor-field-guestName")).toHaveValue("Two-Tab Guest, Staff Engineer");
await expect(guestPage.locator("#sponsor-field-interviewQuestions")).toHaveValue(
"SHARED_Q1_ARCHITECTURE\nSHARED_Q2_TRADEOFFS",
);
const guestDomText = await guestPage.locator("body").innerText();
for (const secretMarker of [
"SECRET_COLD_OPEN_HOOK",
"SECRET_INTRO_SCRIPT",
"SECRET_Q1_ARCHITECTURE",
"SECRET_CLOSING_SCRIPT",
"SECRET_EPISODE_GOAL",
"SECRET_CLAIM_LEDGER_INSIGHT",
Expand All @@ -261,9 +267,11 @@ test.describe("podcast guest materials form", () => {
);
expect(anonDocRes.status).toBe(200);
const anonDocBody = await anonDocRes.text();
expect(anonDocBody).toContain("SHARED_Q1_ARCHITECTURE");
expect(anonDocBody).not.toMatch(/SECRET_/);
const anonDocJson = JSON.parse(anonDocBody).doc;
expect(anonDocJson.viewerRole).toBe("sponsor");
expect(anonDocJson.content.interviewQuestions).toBe("SHARED_Q1_ARCHITECTURE\nSHARED_Q2_TRADEOFFS");
expect(anonDocJson.hostContext).toBeUndefined();
expect(anonDocJson.emailDelivery).toBeUndefined();

Expand All @@ -272,7 +280,9 @@ test.describe("podcast guest materials form", () => {
{ headers: { "x-sponsor-doc-anonymous": "true" } },
);
expect(anonExportRes.status).toBe(200);
expect(await anonExportRes.text()).not.toMatch(/SECRET_/);
const anonExportText = await anonExportRes.text();
expect(anonExportText).toContain("SHARED_Q1_ARCHITECTURE");
expect(anonExportText).not.toMatch(/SECRET_/);
});

test("confirmed podcast recording time collapses into one compact line with Change toggle", async ({
Expand Down
34 changes: 22 additions & 12 deletions backend/src/sponsorDocs/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,10 +759,25 @@ export const SPONSOR_DOC_TEMPLATES: Record<SponsorDocTemplateKey, SponsorDocTemp
},
],
},
{
id: 'interview-questions',
title: '7) Interview Questions',
description: 'Draft questions for our conversation — shared between you and the DataTalks.Club team. Feel free to review or suggest edits.',
tab: 'guest',
fields: [
{
key: 'interviewQuestions',
label: 'Interview Questions',
type: 'textarea',
rows: 8,
placeholder: 'Questions for the episode, in order. We will draft these with you before the recording.',
},
],
},
{
id: 'run-sheet',
title: '1) Run Sheet & Interview Questions',
description: 'Prepared flow and questions for the live recording. Staff-only: never shown to or exported for the guest.',
title: '1) Run Sheet',
description: 'Prepared flow and host scripts for the live recording. Staff-only: never shown to or exported for the guest.',
tab: 'internal',
internal: true,
fields: [
Expand All @@ -780,13 +795,6 @@ export const SPONSOR_DOC_TEMPLATES: Record<SponsorDocTemplateKey, SponsorDocTemp
rows: 3,
placeholder: 'How to introduce the guest on air.',
},
{
key: 'interviewQuestions',
label: 'Interview Questions',
type: 'textarea',
rows: 8,
placeholder: 'Questions for the episode, in order.',
},
{
key: 'closingScript',
label: 'Closing Script',
Expand Down Expand Up @@ -1629,11 +1637,13 @@ export function renderSponsorDocMarkdownExport(doc: SponsorDocExportInput): stri
if (c.sponsorNotes?.trim()) {
lines.push('', '---', '', '## Notes from the Guest', '', c.sponsorNotes.trim());
}
if (c.coldOpen?.trim() || c.introScript?.trim() || c.interviewQuestions?.trim() || c.closingScript?.trim()) {
lines.push('', '## Run Sheet & Interview Questions');
if (c.interviewQuestions?.trim()) {
lines.push('', '## Interview Questions', '', c.interviewQuestions.trim());
}
if (c.coldOpen?.trim() || c.introScript?.trim() || c.closingScript?.trim()) {
lines.push('', '## Run Sheet');
if (c.coldOpen?.trim()) lines.push('', '### Cold Open', c.coldOpen.trim());
if (c.introScript?.trim()) lines.push('', '### Intro Script', c.introScript.trim());
if (c.interviewQuestions?.trim()) lines.push('', '### Interview Questions', c.interviewQuestions.trim());
if (c.closingScript?.trim()) lines.push('', '### Closing Script', c.closingScript.trim());
}
if (c.goal?.trim() || c.audience?.trim() || c.keyMessages?.trim()) {
Expand Down
31 changes: 21 additions & 10 deletions backend/tests/podcast-guest-form.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,28 @@ describe('podcast guest form (radio slot picker + topics; email stays one slot)'
'social-links',
'detailed-questions',
'notes',
'interview-questions',
'run-sheet',
'episode-brief',
'internal-research',
]);
const guestSections = template.sections.slice(0, 6);
const internalSections = template.sections.slice(6);
const guestSections = template.sections.slice(0, 7);
const internalSections = template.sections.slice(7);
assert.ok(guestSections.every((section) => section.tab === 'guest' && !section.internal));
assert.ok(internalSections.every((section) => section.tab === 'internal' && section.internal === true && !section.collapsible));
assert.deepEqual(
internalSections.map((section) => section.fields.map((field) => field.key)),
[
['coldOpen', 'introScript', 'interviewQuestions', 'closingScript'],
['coldOpen', 'introScript', 'closingScript'],
['goal', 'audience', 'keyMessages'],
['sourceLinks', 'keyInsights', 'openQuestions', 'hostNotes'],
],
);
const questionsSection = template.sections.find((section) => section.id === 'interview-questions');
assert.equal(questionsSection?.tab, 'guest');
assert.equal(questionsSection?.internal, undefined);
assert.equal(questionsSection?.collapsible, undefined);
assert.deepEqual(questionsSection?.fields.map((field) => field.key), ['interviewQuestions']);
const fields = template.sections.flatMap((section) => section.fields);
const keys = fields.map((field) => field.key);
assert.ok(keys.includes('slotChoice'));
Expand Down Expand Up @@ -210,12 +216,12 @@ describe('podcast guest form (radio slot picker + topics; email stays one slot)'
assert.ok(exported.includes('## Notes from Sponsor'));
});

it('speakerTemplateView and speakerContentView strictly isolate podcast guest views and exports', () => {
it('speakerTemplateView and speakerContentView share interviewQuestions with guests and isolate internal sections', () => {
const template = getSponsorDocTemplate('podcast');
const speakerTemplate = speakerTemplateView(template);
assert.deepEqual(
speakerTemplate.sections.map((section) => section.id),
['scheduling', 'who-you-are', 'topics', 'social-links', 'detailed-questions', 'notes'],
['scheduling', 'who-you-are', 'topics', 'social-links', 'detailed-questions', 'notes', 'interview-questions'],
);
assert.ok(speakerTemplate.sections.every((section) => !section.internal && section.tab === 'guest'));

Expand All @@ -238,9 +244,9 @@ describe('podcast guest form (radio slot picker + topics; email stays one slot)'
keyInsightsAndMilestones: 'Moved to streaming in 2025',
actionableTakeaway: 'Start with idempotency',
sponsorNotes: 'Happy to answer live questions',
interviewQuestions: 'SHARED-INTERVIEW-QUESTIONS',
coldOpen: 'SECRET-COLD-OPEN',
introScript: 'SECRET-INTRO-SCRIPT',
interviewQuestions: 'SECRET-INTERVIEW-QUESTIONS',
closingScript: 'SECRET-CLOSING-SCRIPT',
goal: 'SECRET-GOAL',
audience: 'SECRET-AUDIENCE',
Expand All @@ -256,10 +262,10 @@ describe('podcast guest form (radio slot picker + topics; email stays one slot)'
assert.equal(guestContent.guestName, 'Jane Doe');
assert.equal(guestContent.topicsToCover, 'Flink, Kafka');
assert.equal(guestContent.sponsorNotes, 'Happy to answer live questions');
assert.equal(guestContent.interviewQuestions, 'SHARED-INTERVIEW-QUESTIONS');
for (const secretKey of [
'coldOpen',
'introScript',
'interviewQuestions',
'closingScript',
'goal',
'audience',
Expand All @@ -285,20 +291,25 @@ describe('podcast guest form (radio slot picker + topics; email stays one slot)'

const guestExport = renderSponsorDocMarkdownExport({ ...baseDoc, content: guestContent });
assert.ok(guestExport.includes('## Notes from the Guest'));
assert.ok(!guestExport.includes('## Run Sheet & Interview Questions'));
assert.ok(guestExport.includes('## Interview Questions'));
assert.ok(guestExport.includes('SHARED-INTERVIEW-QUESTIONS'));
assert.ok(!guestExport.includes('## Run Sheet'));
assert.ok(!guestExport.includes('## Event Description & Episode Plan'));
assert.ok(!guestExport.includes('## Internal Research & Host Notes (Staff Only)'));
assert.ok(!guestExport.includes('SECRET-'));

const staffExport = renderSponsorDocMarkdownExport({ ...baseDoc, content: fullContent });
const notesIdx = staffExport.indexOf('## Notes from the Guest');
const runSheetIdx = staffExport.indexOf('## Run Sheet & Interview Questions');
const questionsIdx = staffExport.indexOf('## Interview Questions');
const runSheetIdx = staffExport.indexOf('## Run Sheet');
const briefIdx = staffExport.indexOf('## Event Description & Episode Plan');
const researchIdx = staffExport.indexOf('## Internal Research & Host Notes (Staff Only)');
assert.ok(notesIdx > 0);
assert.ok(runSheetIdx > notesIdx);
assert.ok(questionsIdx > notesIdx);
assert.ok(runSheetIdx > questionsIdx);
assert.ok(briefIdx > runSheetIdx);
assert.ok(researchIdx > briefIdx);
assert.ok(staffExport.includes('SHARED-INTERVIEW-QUESTIONS'));
assert.ok(staffExport.includes('SECRET-COLD-OPEN'));
assert.ok(staffExport.includes('SECRET-GOAL'));
assert.ok(staffExport.includes('SECRET-HOST-NOTES'));
Expand Down
28 changes: 25 additions & 3 deletions backend/tests/sponsor-docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,6 @@ describe('Sponsor Content Docs API (/api/sponsor-docs)', () => {
const internalFields: Record<string, string> = {
coldOpen: 'PRIVATE-COLD-OPEN',
introScript: 'PRIVATE-INTRO-SCRIPT',
interviewQuestions: 'PRIVATE-INTERVIEW-QUESTIONS',
closingScript: 'PRIVATE-CLOSING-SCRIPT',
goal: 'PRIVATE-EPISODE-GOAL',
audience: 'PRIVATE-TARGET-AUDIENCE',
Expand All @@ -1082,6 +1081,7 @@ describe('Sponsor Content Docs API (/api/sponsor-docs)', () => {
introduction: 'Staff data engineer building ML platforms',
topicsToCover: 'Feature stores, latency budgets',
topicsToAvoid: 'Unannounced roadmap',
interviewQuestions: 'SHARED-Q1: How do you design feature stores?',
...internalFields,
},
});
Expand All @@ -1104,7 +1104,9 @@ describe('Sponsor Content Docs API (/api/sponsor-docs)', () => {
assert.equal(guestDoc.viewerRole, 'sponsor');
assert.equal(guestDoc.content.guestName, 'Jane Doe');
assert.equal(guestDoc.content.topicsToCover, 'Feature stores, latency budgets');
assert.equal(guestDoc.content.interviewQuestions, 'SHARED-Q1: How do you design feature stores?');
assert.equal(guestDoc.templateDefinition.sections.filter((s: { internal?: boolean }) => s.internal).length, 0);
assert.ok(guestDoc.templateDefinition.sections.some((s: { id: string }) => s.id === 'interview-questions'));
for (const key of Object.keys(internalFields)) {
assert.equal(guestDoc.content[key], undefined, `guest must not receive ${key}`);
assert.equal(Object.hasOwn(guestDoc.content, key), false);
Expand All @@ -1114,6 +1116,7 @@ describe('Sponsor Content Docs API (/api/sponsor-docs)', () => {
assert.equal(guestDoc.accessCode, undefined);
assert.equal(guestDoc.shareUrl, undefined);
assert.equal(guestDoc.emailDraft, undefined);
assert.ok(guestDoc.markdownExport.includes('SHARED-Q1: How do you design feature stores?'));
assert.doesNotMatch(guestDoc.markdownExport, /PRIVATE-/);
}

Expand All @@ -1125,6 +1128,7 @@ describe('Sponsor Content Docs API (/api/sponsor-docs)', () => {
assert.equal(guestExport.statusCode, 200, guestExport.body);
const exportedText = format === 'json' ? JSON.parse(guestExport.body).markdown : guestExport.body;
assert.ok(exportedText.includes('Feature stores, latency budgets'));
assert.ok(exportedText.includes('SHARED-Q1: How do you design feature stores?'));
for (const value of Object.values(internalFields)) {
assert.ok(!exportedText.includes(value), `${format} export leaked ${value}`);
}
Expand Down Expand Up @@ -1157,6 +1161,7 @@ describe('Sponsor Content Docs API (/api/sponsor-docs)', () => {
}),
);
assert.ok(docxXml.includes('Feature stores, latency budgets'));
assert.ok(docxXml.includes('SHARED-Q1: How do you design feature stores?'));
for (const value of Object.values(internalFields)) {
assert.ok(!docxXml.includes(value), `docx export leaked ${value}`);
}
Expand All @@ -1166,8 +1171,9 @@ describe('Sponsor Content Docs API (/api/sponsor-docs)', () => {
body: {
content: {
currentFocus: 'GUEST-UPDATE',
interviewQuestions: 'HIJACK',
coldOpen: 'HIJACK',
introScript: 'HIJACK',
closingScript: 'HIJACK',
hostNotes: 'HIJACK',
sourceLinks: 'HIJACK',
},
Expand All @@ -1176,6 +1182,7 @@ describe('Sponsor Content Docs API (/api/sponsor-docs)', () => {
assert.equal(guestPut.statusCode, 200, guestPut.body);
const guestPutDoc = JSON.parse(guestPut.body).doc;
assert.equal(guestPutDoc.content.currentFocus, 'GUEST-UPDATE');
assert.equal(guestPutDoc.content.interviewQuestions, 'SHARED-Q1: How do you design feature stores?');
assert.equal(guestPutDoc.emailDelivery, undefined);
assert.equal(guestPutDoc.hostContext, undefined);
for (const key of Object.keys(internalFields)) {
Expand All @@ -1187,16 +1194,31 @@ describe('Sponsor Content Docs API (/api/sponsor-docs)', () => {
assert.equal(storedAfterGuestPut?.content[key], value, `guest PUT overwrote ${key}`);
}

// Staff edits to interviewQuestions show up in the guest API response
const staffEditRes = await staffReq('PUT', `/api/sponsor-docs/${doc.id}`, {
content: { interviewQuestions: 'SHARED-Q1-UPDATED\nSHARED-Q2-ADDED' },
});
assert.equal(staffEditRes.statusCode, 200, staffEditRes.body);
const guestAfterStaffEdit = await anonReq('GET', `/api/sponsor-docs/${doc.id}`, {
codeHeader: doc.accessCode,
});
assert.equal(guestAfterStaffEdit.statusCode, 200, guestAfterStaffEdit.body);
assert.equal(
JSON.parse(guestAfterStaffEdit.body).doc.content.interviewQuestions,
'SHARED-Q1-UPDATED\nSHARED-Q2-ADDED',
);

const staffRes = await staffReq('GET', `/api/sponsor-docs/${doc.id}`);
assert.equal(staffRes.statusCode, 200, staffRes.body);
const staffDoc = JSON.parse(staffRes.body).doc;
assert.equal(staffDoc.viewerRole, 'staff');
assert.equal(staffDoc.templateDefinition.sections.length, 9);
assert.equal(staffDoc.templateDefinition.sections.length, 10);
const staffInternalSections = staffDoc.templateDefinition.sections.filter(
(s: { tab?: string; internal?: boolean }) => s.tab === 'internal' && s.internal === true,
);
assert.equal(staffInternalSections.length, 3);
assert.equal(staffDoc.content.currentFocus, 'GUEST-UPDATE');
assert.equal(staffDoc.content.interviewQuestions, 'SHARED-Q1-UPDATED\nSHARED-Q2-ADDED');
for (const [key, value] of Object.entries(internalFields)) {
assert.equal(staffDoc.content[key], value);
assert.ok(staffDoc.markdownExport.includes(value), `staff markdownExport missing ${key}`);
Expand Down
Loading