From 3d10f562e74bd065a093a9be40817bbd34e674b0 Mon Sep 17 00:00:00 2001 From: Alexey Grigorev Date: Sat, 21 Nov 2026 20:29:39 +0100 Subject: [PATCH] fix(podcast-docs): share interview questions with guests while keeping internal prep staff-only --- backend/e2e/podcast-guest-form.spec.js | 26 ++++++--- backend/src/sponsorDocs/templates.ts | 34 +++++++---- backend/tests/podcast-guest-form.test.ts | 31 ++++++---- backend/tests/sponsor-docs.test.ts | 28 ++++++++- .../operations/sponsor-doc-podcast.js | 9 ++- .../src/surfaces/operations/sponsor-docs.js | 5 ++ frontend/test/podcast-doc-tabs.test.mjs | 57 +++++++++++++------ 7 files changed, 136 insertions(+), 54 deletions(-) diff --git a/backend/e2e/podcast-guest-form.spec.js b/backend/e2e/podcast-guest-form.spec.js index fd4867f7..d468247a 100644 --- a/backend/e2e/podcast-guest-form.spec.js +++ b/backend/e2e/podcast-guest-form.spec.js @@ -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", @@ -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(); @@ -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 }, @@ -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", @@ -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(); @@ -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 ({ diff --git a/backend/src/sponsorDocs/templates.ts b/backend/src/sponsorDocs/templates.ts index 74860712..da0ad7eb 100644 --- a/backend/src/sponsorDocs/templates.ts +++ b/backend/src/sponsorDocs/templates.ts @@ -759,10 +759,25 @@ export const SPONSOR_DOC_TEMPLATES: Record 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')); @@ -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')); @@ -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', @@ -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', @@ -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')); diff --git a/backend/tests/sponsor-docs.test.ts b/backend/tests/sponsor-docs.test.ts index dd424b5b..d82fda05 100644 --- a/backend/tests/sponsor-docs.test.ts +++ b/backend/tests/sponsor-docs.test.ts @@ -1064,7 +1064,6 @@ describe('Sponsor Content Docs API (/api/sponsor-docs)', () => { const internalFields: Record = { coldOpen: 'PRIVATE-COLD-OPEN', introScript: 'PRIVATE-INTRO-SCRIPT', - interviewQuestions: 'PRIVATE-INTERVIEW-QUESTIONS', closingScript: 'PRIVATE-CLOSING-SCRIPT', goal: 'PRIVATE-EPISODE-GOAL', audience: 'PRIVATE-TARGET-AUDIENCE', @@ -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, }, }); @@ -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); @@ -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-/); } @@ -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}`); } @@ -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}`); } @@ -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', }, @@ -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)) { @@ -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}`); diff --git a/frontend/src/surfaces/operations/sponsor-doc-podcast.js b/frontend/src/surfaces/operations/sponsor-doc-podcast.js index e3f035e3..b18c324a 100644 --- a/frontend/src/surfaces/operations/sponsor-doc-podcast.js +++ b/frontend/src/surfaces/operations/sponsor-doc-podcast.js @@ -266,7 +266,7 @@ function buildGuestSnapshot({ el, doc, draftContent, guestZone }) { return snapshot; } -function buildRunSheetSection({ el, actionBtn, draftContent, onEditPrep }) { +function buildRunSheetSection({ el, actionBtn, draftContent, onEditPrep, onEditQuestions }) { const section = el("section", "podcast-host-runsheet"); const head = el("div", "podcast-host-runsheet__head"); const meta = el("div", "podcast-host-runsheet__meta"); @@ -278,7 +278,7 @@ function buildRunSheetSection({ el, actionBtn, draftContent, onEditPrep }) { "dk-button dk-button--secondary dk-button--sm", "Edit questions", "", - () => onEditPrep?.(), + () => (onEditQuestions ? onEditQuestions() : onEditPrep?.()), ); editBtn.dataset.podcastAction = "edit-questions"; head.append(meta, editBtn); @@ -423,12 +423,13 @@ export function renderPodcastHostView({ qnaState, onLoadQna, onEditPrep, + onEditQuestions, }) { const container = el("div", "sponsor-doc-card podcast-host-view"); container.dataset.podcastQuestionsView = "readonly"; container.append( buildGuestSnapshot({ el, doc, draftContent, guestZone }), - buildRunSheetSection({ el, actionBtn, draftContent, onEditPrep }), + buildRunSheetSection({ el, actionBtn, draftContent, onEditPrep, onEditQuestions }), buildHostQnaSection({ el, actionBtn, doc, qnaState, onLoadQna }), ); return container; @@ -557,6 +558,7 @@ export function renderPodcastTwoTabWorkspace({ onSelectMode, onLoadQna, onEditPrep, + onEditQuestions, onCopyExport, }) { const { guestSections, internalSections } = splitPodcastSections(sections); @@ -613,6 +615,7 @@ export function renderPodcastTwoTabWorkspace({ qnaState, onLoadQna, onEditPrep, + onEditQuestions, })); } else { internalPanel.append(buildFormElement({ diff --git a/frontend/src/surfaces/operations/sponsor-docs.js b/frontend/src/surfaces/operations/sponsor-docs.js index 5337c6de..259b2559 100644 --- a/frontend/src/surfaces/operations/sponsor-docs.js +++ b/frontend/src/surfaces/operations/sponsor-docs.js @@ -867,6 +867,11 @@ export function createSponsorDocPage({ syncPodcastUrl(); render(); }, + onEditQuestions: () => { + activePodcastTab = "guest"; + syncPodcastUrl(); + render(); + }, onCopyExport: () => copyText(doc.markdownExport, "Copied Markdown export to clipboard."), }); return; diff --git a/frontend/test/podcast-doc-tabs.test.mjs b/frontend/test/podcast-doc-tabs.test.mjs index b5ec0021..2d4c91cc 100644 --- a/frontend/test/podcast-doc-tabs.test.mjs +++ b/frontend/test/podcast-doc-tabs.test.mjs @@ -80,15 +80,22 @@ function fullPodcastDefinition() { { key: "websiteUrl", label: "Website", type: "text" }, ], }, + { + id: "interview-questions", + tab: "guest", + title: "7) Interview Questions", + fields: [ + { key: "interviewQuestions", label: "Interview Questions", type: "textarea", rows: 6 }, + ], + }, { id: "run-sheet", tab: "internal", internal: true, - title: "Run Sheet & Interview Questions", + title: "1) Run Sheet", fields: [ { key: "coldOpen", label: "Cold Open", type: "textarea", rows: 2 }, { key: "introScript", label: "Intro Script", type: "textarea", rows: 3 }, - { key: "interviewQuestions", label: "Interview Questions", type: "textarea", rows: 6 }, { key: "closingScript", label: "Closing Script", type: "textarea", rows: 3 }, ], }, @@ -243,7 +250,7 @@ test("podcast helpers classify docs, split sections, check host content, and syn assert.deepEqual(synced, ["Podcast document tabs", "Internal view mode"]); }); -test("guest view blocks tab bar, internal sections, view-questions, markdown export, and ?tab=internal params", async () => { +test("guest view shows interviewQuestions and blocks tab bar, internal sections, view-questions, markdown export, and ?tab=internal params", async () => { const h = createHarness({ href: "https://ops.example.test/podcast-docs/sdoc-pod-1?code=bcdfghjklmnpqrst&tab=internal&view=questions", docOverrides: { @@ -255,7 +262,9 @@ test("guest view blocks tab bar, internal sections, view-questions, markdown exp content: { guestName: "Julien Khaleghy", topicsToCover: "Distributed crawling", - interviewQuestions: "Should never render for guest", + interviewQuestions: "Q1: How does your browser fleet scale?", + coldOpen: "Should never render for guest", + hostNotes: "Private host note", }, }, }); @@ -269,8 +278,11 @@ test("guest view blocks tab bar, internal sections, view-questions, markdown exp assert.equal(h.root.querySelector("[data-sponsor-staff-bar]"), null); assert.equal(h.root.querySelector("[data-sponsor-export]"), null); assert.equal(h.root.querySelector("[data-podcast-sponsored-badge]"), null); - assert.equal(h.root.querySelector("#sponsor-field-interviewQuestions"), null); + assert.equal(h.root.querySelector("#sponsor-field-interviewQuestions").value, "Q1: How does your browser fleet scale?"); + assert.equal(h.root.querySelector("#sponsor-field-coldOpen"), null); + assert.equal(h.root.querySelector("#sponsor-field-hostNotes"), null); assert.doesNotMatch(h.root.textContent, /Should never render for guest/); + assert.doesNotMatch(h.root.textContent, /Private host note/); assert.doesNotMatch(h.root.textContent, /sponsor/i); assert.doesNotMatch(h.identity.textContent, /sponsor/i); @@ -300,35 +312,43 @@ test("staff two-tab navigation smart-defaults Host/Edit modes, preserves unsaved assert.ok(emptyH.root.querySelector('[data-podcast-panel="guest"] .dk-callout')); assert.ok(emptyH.root.querySelector('[data-podcast-panel="guest"] [data-guest-timezone]')); - // Edit a guest field without saving, then switch to Internal tab + // Edit guest fields (including shared interviewQuestions) without saving, then switch to Internal tab const guestNameInput = emptyH.root.querySelector("#sponsor-field-guestName"); guestNameInput.value = "Ada Lovelace (Edited)"; await guestNameInput.dispatch("input"); + const questionsInput = emptyH.root.querySelector("#sponsor-field-interviewQuestions"); + assert.ok(questionsInput, "interviewQuestions is editable on Guest tab"); + questionsInput.value = "1. What inspired the Analytical Engine?"; + await questionsInput.dispatch("input"); await emptyH.root.querySelector("#podcast-tab-internal").click(); assert.equal(emptyH.root.querySelector("#podcast-tab-internal").getAttribute("aria-selected"), "true"); - assert.equal(emptyH.history.at(-1)[2], "/podcast-docs/sdoc-pod-1?tab=internal"); - assert.match(emptyH.root.querySelector('[data-podcast-tab-notice="internal"]').textContent, /Staff only/); - - // Smart-defaulted to Edit mode because no host content existed; internal sections are expanded (no
) + // Smart-defaults to Host view now that interviewQuestions has content; switch to Edit mode assert.equal( - emptyH.root.querySelector('[data-podcast-internal-mode="edit"]').getAttribute("aria-selected"), + emptyH.root.querySelector('[data-podcast-internal-mode="host"]').getAttribute("aria-selected"), "true", ); - const questionsInput = emptyH.root.querySelector("#sponsor-field-interviewQuestions"); - assert.ok(questionsInput); + await emptyH.root.querySelector('[data-podcast-internal-mode="edit"]').click(); + assert.equal(emptyH.history.at(-1)[2], "/podcast-docs/sdoc-pod-1?tab=internal"); + assert.match(emptyH.root.querySelector('[data-podcast-tab-notice="internal"]').textContent, /Staff only/); + + // Internal sections are expanded (no
) and exclude interviewQuestions + assert.equal(emptyH.root.querySelector("#sponsor-field-interviewQuestions"), null); + const coldOpenInput = emptyH.root.querySelector("#sponsor-field-coldOpen"); + assert.ok(coldOpenInput); assert.ok(emptyH.root.querySelector("#sponsor-field-hostNotes"), "internal-research expanded without details"); - questionsInput.value = "1. What inspired the Analytical Engine?"; - await questionsInput.dispatch("input"); + coldOpenInput.value = "Hook: the first computer program."; + await coldOpenInput.dispatch("input"); - // Switch back to Guest intake -> unsaved guest edit is still there + // Switch back to Guest intake -> unsaved guest edits are still there await emptyH.root.querySelector("#podcast-tab-guest").click(); assert.equal(emptyH.history.at(-1)[2], "/podcast-docs/sdoc-pod-1"); assert.equal(emptyH.root.querySelector("#sponsor-field-guestName").value, "Ada Lovelace (Edited)"); + assert.equal(emptyH.root.querySelector("#sponsor-field-interviewQuestions").value, "1. What inspired the Analytical Engine?"); - // Switch back to Internal -> still in Edit mode and unsaved questions edit is preserved + // Switch back to Internal -> still in Edit mode and unsaved coldOpen edit is preserved await emptyH.root.querySelector("#podcast-tab-internal").click(); - assert.equal(emptyH.root.querySelector("#sponsor-field-interviewQuestions").value, "1. What inspired the Analytical Engine?"); + assert.equal(emptyH.root.querySelector("#sponsor-field-coldOpen").value, "Hook: the first computer program."); // Save internal changes via PUT await findByText(emptyH.root, "Save internal changes", "button").click(); @@ -338,6 +358,7 @@ test("staff two-tab navigation smart-defaults Host/Edit modes, preserves unsaved const sent = JSON.parse(putCall[1].body); assert.equal(sent.content.guestName, "Ada Lovelace (Edited)"); assert.equal(sent.content.interviewQuestions, "1. What inspired the Analytical Engine?"); + assert.equal(sent.content.coldOpen, "Hook: the first computer program."); assert.match(emptyH.root.querySelector("[data-sponsor-feedback]").textContent, /Saved draft/); emptyH.controller.destroy();