Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
import { afterEach, describe, expect, it, vi } from 'vitest';
import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { useState } from 'react';
import ProductionReviewPanel from './ProductionReviewPanel.jsx';
afterEach(() => { vi.unstubAllGlobals(); window.location.hash = ''; });
const approvalAction = 'Approve proof — watched with sound';
const proofAction = /Approve.*proof/;
const project = {
id: 'example-project', scenes: [], lyricCues: [], composition: { mode: 'document' },
productionReview: { proof: { excerptId: 'proof-a', basis: 'same-creative-basis' }, draft: {
cast: 'Example figure', environments: 'Example stage', visualLanguage: 'Copper and indigo',
motionLanguage: 'Energy target: driving chorus. 0:04 — figure turns and opens the prop on the downbeat.',
lyricsMode: 'instrumental', timingStatus: 'verified', timingNotes: 'Synthetic master', storyboard: [],
} },
excerpts: [{ id: 'proof-a', filename: 'proof-a.mp4', status: 'complete' }],
};
const reviewFixture = () => ({ readiness: {
basis: { art: 'art', storyboard: 'board', proof: 'same-creative-basis' },
art: { approved: true, problems: [] }, storyboard: { approved: true, problems: [] }, proof: { approved: false, problems: [] },
}, busy: false, proof: { active: false }, approve: vi.fn(), save: vi.fn(async () => null) });
const NOTE = '0:04 — figure turns on the downbeat; prop follows at 4.5s.';
function recordPlayback() {
fireEvent.loadedData(screen.getByLabelText('Animated proof with master audio'));
fireEvent.change(screen.getByLabelText('Notes (optional)'), { target: { value: NOTE } });
}
describe('Production proof render controls', () => {
it('leads with the first render and submits the edited chorus interval', () => {
const review = { ...reviewFixture(), renderProof: vi.fn() };
const missing = { ...project, productionReview: { ...project.productionReview, proof: null } };
render(<ProductionReviewPanel project={missing} review={review} stage="proof" />);
const start = screen.getByLabelText('Chorus start (s)');
const end = screen.getByLabelText('End (s)');
expect(start.id).toBe('mv-review-example-project-proof-proof-start');
expect(end.id).toBe('mv-review-example-project-proof-proof-end');
expect(start.value).toBe('0');
expect(end.value).toBe('20');
const button = screen.getByRole('button', { name: 'Render animated proof' });
expect(button.disabled).toBe(false);
expect(button.compareDocumentPosition(screen.getByRole('button', { name: 'Request changes' })) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
fireEvent.change(start, { target: { value: '12.25' } });
fireEvent.change(end, { target: { value: '32.75' } });
fireEvent.click(button);
expect(review.renderProof).toHaveBeenCalledExactlyOnceWith({ startSec: 12.25, endSec: 32.75 });
});
it('offers a replacement below saved choreography using the persisted interval', () => {
const review = { ...reviewFixture(), renderProof: vi.fn() };
const ranged = { ...project, productionReview: { ...project.productionReview,
proof: { ...project.productionReview.proof, startSec: 8.5, endSec: 24.5 } } };
render(<ProductionReviewPanel project={ranged} review={review} stage="proof" />);
const button = screen.getByRole('button', { name: 'Render a new proof' });
expect(button.disabled).toBe(false);
expect(screen.getByLabelText('Saved choreography for proof comparison').compareDocumentPosition(button) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
expect(button.compareDocumentPosition(screen.getByLabelText('Animated proof with master audio')) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
fireEvent.click(button);
expect(review.renderProof).toHaveBeenCalledExactlyOnceWith({ startSec: 8.5, endSec: 24.5 });
});
it('blocks rendering until stills are locked and while another project occupies the renderer', () => {
const review = { ...reviewFixture(), renderProof: vi.fn() };
review.readiness.storyboard.approved = false;
const view = render(<ProductionReviewPanel project={project} review={review} stage="proof" />);
const button = screen.getByRole('button', { name: 'Render a new proof' });
expect(button.disabled).toBe(true);
fireEvent.click(button);
expect(review.renderProof).not.toHaveBeenCalled();
review.readiness.storyboard.approved = true;
view.rerender(<ProductionReviewPanel project={project} review={{ ...review, proof: { occupied: true, active: false } }} stage="proof" />);
expect(button.disabled).toBe(true);
expect(screen.getByText('Review evidence is rendering in another project. Wait for it to finish before starting another.').getAttribute('role')).toBe('status');
fireEvent.click(button);
expect(review.renderProof).not.toHaveBeenCalled();
});
it('blocks duplicate rendering and reports connection and percent progress', () => {
const review = { ...reviewFixture(), renderProof: vi.fn(), proof: { active: true, connected: false } };
const view = render(<ProductionReviewPanel project={project} review={review} stage="proof" />);
const button = screen.getByRole('button', { name: 'Render a new proof' });
expect(button.disabled).toBe(true);
expect(screen.getByText('Connecting to review render… Production approvals are separate.').getAttribute('role')).toBe('status');
fireEvent.click(button);
expect(review.renderProof).not.toHaveBeenCalled();
view.rerender(<ProductionReviewPanel project={project} review={{ ...review, proof: { active: true, connected: true, percent: 37 } }} stage="proof" />);
expect(button.disabled).toBe(true);
expect(screen.getByText('Rendering review evidence — 37%. Production approvals are separate.').getAttribute('role')).toBe('status');
});
});
describe('Production proof playback evidence', () => {
it('approves a played proof straight away; notes are optional and no checkbox attests', () => {
const review = reviewFixture();
render(<ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="proof" />);
const approve = screen.getByRole('button', { name: approvalAction });
expect(approve.disabled).toBe(true);
fireEvent.loadedData(screen.getByLabelText('Animated proof with master audio'));
expect(screen.queryByRole('checkbox')).toBeNull();
expect(approve.disabled).toBe(false);
// Optional: labelled so, and not highlighted like a required approval.
expect(screen.getByRole('heading', { name: /^Animated proof\s*Optional$/ })).toBeTruthy();
expect(screen.getByRole('region', { name: 'Approve: Animated proof' }).className).not.toContain('border-port-accent');
expect(review.approve).not.toHaveBeenCalled();
// The button itself says what approving attests; no attestation paragraph, and no line once nothing is missing.
expect(approve.textContent).toBe('Approve proof — watched with sound');
expect(screen.queryByText(/By approving, I confirm/)).toBeNull();
expect(approve.getAttribute('aria-describedby')).toBeNull();
fireEvent.click(approve);
expect(review.approve).toHaveBeenCalledWith('proof', { watchedWithAudio: true, excerptId: 'proof-a', filename: 'proof-a.mp4' });
// A note, when given, goes with the approval.
fireEvent.change(screen.getByLabelText('Notes (optional)'), { target: { value: NOTE } });
fireEvent.click(approve);
expect(review.approve).toHaveBeenLastCalledWith('proof', { watchedWithAudio: true, excerptId: 'proof-a', filename: 'proof-a.mp4', timecodedNotes: NOTE });
});
it('opens the missing prerequisites and offers no prototype render', () => {
const review = reviewFixture();
review.readiness.art.approved = false;
review.readiness.storyboard = { approved: false, problems: ['Verify alignment against the current master.', 'Import a matching document shot manifest.'] };
review.readiness.proof.problems = ['Approve the current lyric-timed storyboard before the animated proof.'];
const prototype = { ...project, productionReview: { ...project.productionReview, proof: null, prototype: { excerptId: 'proof-a' } } };
const onNavigate = vi.fn();
render(<ProductionReviewPanel project={prototype} review={review} onOpenArtifact={vi.fn()} stage="proof" onNavigate={onNavigate} />);
expect(screen.getByRole('region', { name: 'Approve: Animated proof' })).toBeTruthy();
const prerequisites = screen.getByLabelText('Proof approval prerequisites');
// The proof step names the one earlier approval to give, not that step's problems.
expect(prerequisites.textContent).toContain('Approve the art direction first.');
expect(prerequisites.textContent).not.toContain('Verify alignment against the current master.');
// With no proof yet, the box leads with rendering one; there is nothing to approve.
expect(screen.queryByRole('button', { name: approvalAction })).toBeNull();
expect(screen.getByRole('button', { name: 'Render animated proof' }).disabled).toBe(true);
expect(screen.queryByRole('button', { name: 'Render preview only' })).toBeNull();
expect(screen.queryByLabelText('Unapproved feasibility prototype')).toBeNull();
// The link crosses to the step that owns that approval.
fireEvent.click(within(prerequisites).getByRole('link', { name: 'Approve the art direction' }));
expect(onNavigate).toHaveBeenLastCalledWith('cast-sets', 'mv-review-art');
expect(review.approve).not.toHaveBeenCalled();
});
it('clears evidence when the creative revision changes even if the excerpt and filename are unchanged', () => {
const review = reviewFixture();
const view = render(<ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="proof" />);
recordPlayback();
const changedReview = { ...review, readiness: { ...review.readiness,
basis: { ...review.readiness.basis, proof: 'new-creative-basis' },
proof: { approved: false, problems: ['Render and watch a current animated chorus proof with the master song.'] },
} };
view.rerender(<ProductionReviewPanel project={project} review={changedReview} onOpenArtifact={vi.fn()} stage="proof" />);
// The notes belonged to the old proof: they go, with the fields, until a new proof is rendered.
expect(screen.queryByLabelText('Notes (optional)')).toBeNull();
view.rerender(<ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="proof" />);
expect(screen.getByLabelText('Notes (optional)').value).toBe('');
view.rerender(<ProductionReviewPanel project={project} review={changedReview} onOpenArtifact={vi.fn()} stage="proof" />);
// A proof of an older revision can't be approved; rendering a new one leads instead.
expect(screen.queryByRole('button', { name: approvalAction })).toBeNull();
expect(screen.getByRole('button', { name: 'Render animated proof' })).toBeTruthy();
expect(screen.getByText(/Source changed — render a new proof/)).toBeTruthy();
expect(review.approve).not.toHaveBeenCalled();
});
it('shows a persisted capture failure after reconnect and keeps proof approval blocked', () => {
render(<ProductionReviewPanel project={{ ...project, excerpts: [{ id: 'proof-a', status: 'error',
error: 'Composition capture failed at frame 0 (song 12s): Browser command timed out: Page.captureScreenshot' }] }}
review={reviewFixture()} onOpenArtifact={vi.fn()} stage="proof" />);
expect(screen.getByRole('alert').textContent).toContain('capture failed at frame 0');
expect(screen.queryByRole('button', { name: proofAction })).toBeNull();
expect(screen.getByRole('button', { name: 'Render animated proof' })).toBeTruthy();
expect(screen.queryByLabelText('Animated proof with master audio')).toBeNull();
});
it('submits substantive machine evidence for the exact proof without claiming playback', () => {
const review = reviewFixture();
const view = render(<ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="proof" />);
recordPlayback();
fireEvent.change(screen.getByLabelText('Review method'), { target: { value: 'machine' } });
expect(screen.queryByRole('checkbox')).toBeNull();
const approve = screen.getByRole('button', { name: proofAction });
const evidence = {
visualReview: 'Continuous frame sequence shows the figure turning and opening the prop on the beat.',
audioReview: 'Decoded master audio matches the proof interval; transient timing aligns with the turn.',
limitations: 'Machine inspection only; no human listening or playback is claimed.',
};
fireEvent.change(screen.getByLabelText('Visual and motion observations'), { target: { value: evidence.visualReview } });
fireEvent.change(screen.getByLabelText('Audio and alignment observations'), { target: { value: 'short' } });
fireEvent.change(screen.getByLabelText('Review limitations'), { target: { value: evidence.limitations } });
expect(approve.disabled).toBe(true);
fireEvent.change(screen.getByLabelText('Audio and alignment observations'), { target: { value: evidence.audioReview } });
expect(approve.disabled).toBe(false);
fireEvent.click(approve);
expect(review.approve).toHaveBeenCalledWith('proof', {
method: 'machine', watchedWithAudio: false, machineEvidence: evidence,
excerptId: 'proof-a', filename: 'proof-a.mp4', timecodedNotes: NOTE,
});
fireEvent.change(screen.getByLabelText('Review method'), { target: { value: 'playback' } });
expect(screen.getByRole('button', { name: approvalAction }).disabled).toBe(false);
fireEvent.change(screen.getByLabelText('Review method'), { target: { value: 'machine' } });
view.rerender(<ProductionReviewPanel project={{ ...project, excerpts: [{ ...project.excerpts[0], filename: 'replacement.mp4' }] }} review={review} onOpenArtifact={vi.fn()} stage="proof" />);
expect(screen.getByLabelText('Review method').value).toBe('playback');
fireEvent.loadedData(screen.getByLabelText('Animated proof with master audio'));
fireEvent.change(screen.getByLabelText('Review method'), { target: { value: 'machine' } });
expect(screen.getByLabelText('Visual and motion observations').value).toBe('');
expect(screen.getByLabelText('Audio and alignment observations').value).toBe('');
expect(screen.getByLabelText('Review limitations').value).toBe('');
expect(approve.disabled).toBe(true);
});
it('reports server errors and blocks machine approval for missing media', () => {
const review = reviewFixture();
render(<ProductionReviewPanel project={project} review={{ ...review, error: 'The proof revision changed; review the current proof.' }} onOpenArtifact={vi.fn()} stage="proof" />);
expect(screen.getByRole('alert').textContent).toContain('proof revision changed');
expect(screen.getByLabelText('Review method').disabled).toBe(true);
fireEvent.loadedData(screen.getByLabelText('Animated proof with master audio'));
fireEvent.change(screen.getByLabelText('Review method'), { target: { value: 'machine' } });
for (const label of ['Visual and motion observations', 'Audio and alignment observations', 'Review limitations']) {
fireEvent.change(screen.getByLabelText(label), { target: { value: 'Specific evidence from the exact proof and the current master audio.' } });
}
const approve = screen.getByRole('button', { name: proofAction });
expect(approve.disabled).toBe(false);
fireEvent.error(screen.getByLabelText('Animated proof with master audio'));
expect(approve.disabled).toBe(true);
expect(screen.getByLabelText('Visual and motion observations').disabled).toBe(true);
expect(review.approve).not.toHaveBeenCalled();
});
it('shows the selected version before permitting art approval without password re-entry', async () => {
vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true })));
const review = reviewFixture(); review.readiness.art.approved = false;
const art = { ...project, devArtifacts: [{ id: 'guide', title: 'Synthetic visual guide', version: 2, mimeType: 'image/png' }],
productionReview: { ...project.productionReview, draft: { ...project.productionReview.draft, guideArtifactId: 'guide' } } };
render(<ProductionReviewPanel project={art} review={review} onOpenArtifact={vi.fn()} stage="art" />);
const approve = screen.getByRole('button', { name: 'Approve art direction' });
expect(approve.disabled).toBe(true);
const image = await screen.findByAltText('Synthetic visual guide v2');
expect(image.getAttribute('src')).toContain('?version=2');
fireEvent.load(image);
expect(screen.queryByLabelText('Instance password for this approval')).toBeNull();
fireEvent.click(approve);
expect(review.approve).toHaveBeenCalledWith('art', undefined);
fireEvent.error(image);
expect(approve.disabled).toBe(true);
expect(screen.getByRole('alert').textContent).toContain('could not be loaded');
});
it('shows the document shots beside storyboard approval and targets change requests to that stage', async () => {
const review = { ...reviewFixture(), feedback: vi.fn(async () => true) }; review.readiness.storyboard.approved = false;
const doc = { ...project, composition: { mode: 'document', document: { directory: 'synthetic/doc-2' } },
productionReview: { ...project.productionReview, draft: { ...project.productionReview.draft, storyboardSource: 'document',
storyboard: [{ id: 'shot-a', label: 'Doorway', startSec: 0, endSec: 10, action: 'Open the doorway on the downbeat', camera: 'Push in', staging: 'Figure left', transition: 'Match cut', lyricCueIds: [] }] } } };
render(<ProductionReviewPanel project={doc} review={review} onOpenArtifact={vi.fn()} stage="storyboard" />);
const content = screen.getByLabelText('Storyboard review content');
expect(content.textContent).toContain('1 document shots');
expect(content.textContent).toContain('doc-2');
expect(content.textContent).toContain('Open the doorway on the downbeat');
const box = screen.getByRole('region', { name: 'Approve: Lyric-timed storyboard' });
expect(box.contains(content)).toBe(true);
fireEvent.click(within(box).getByRole('button', { name: 'Request changes' }));
expect(screen.queryByLabelText('Feedback stage')).toBeNull();
expect(document.activeElement).toBe(screen.getByLabelText('Requested change'));
expect(screen.getByLabelText('Requested change').closest('details').open).toBe(true);
fireEvent.change(screen.getByLabelText('Feedback target'), { target: { value: 'shot: Doorway' } });
fireEvent.change(screen.getByLabelText('Requested change'), { target: { value: 'Hold the doorway one beat longer.' } });
fireEvent.click(screen.getByRole('button', { name: 'Save revision feedback' }));
expect(review.feedback).toHaveBeenCalledWith({ stage: 'storyboard', target: 'shot: Doorway', text: 'Hold the doorway one beat longer.', decision: 'request-changes' });
await waitFor(() => expect(screen.getByLabelText('Requested change').value).toBe(''));
});
it('names the open change request that blocks approval in one line, leaving its controls to the step checklist', () => {
const review = reviewFixture();
review.readiness.storyboard = { approved: false, problems: ['Resolve storyboard feedback for shot: Chorus: Land the leap on the downbeat'] };
const withRequests = { ...project, scenes: [{ sceneId: 'scene-a', label: 'Chorus', startSec: 0, endSec: 10 }],
productionReview: { ...project.productionReview, feedback: [
{ id: 'fb-open', stage: 'storyboard', target: 'shot: Chorus', text: 'Land the leap on the downbeat', decision: 'request-changes', basis: 'board' },
{ id: 'fb-done', stage: 'storyboard', target: 'shot: Intro', text: 'Already handled', decision: 'request-changes', basis: 'board', resolvedAt: '2026-01-01T00:00:00.000Z' },
] } };
render(<ProductionReviewPanel project={withRequests} review={review} onOpenArtifact={vi.fn()} stage="storyboard" />);
const box = screen.getByRole('region', { name: 'Approve: Lyric-timed storyboard' });
expect(within(box).getByRole('status').textContent).toBe('Resolve the change request on shot: Chorus first.');
expect(within(box).queryByRole('button', { name: 'Revise from feedback' })).toBeNull();
});
it('keeps the art approval to one quiet line while there is no direction or guide to review', () => {
const review = reviewFixture(); review.readiness.art = { approved: false, problems: ['Attach a visual cast/environment sheet from Development artifacts.'] };
render(<ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="art" />);
const box = screen.getByRole('region', { name: 'Approve: Art direction' });
expect(box.textContent).toContain('Opens once the art direction is written and a visual guide is chosen.');
expect(within(box).queryByRole('button', { name: 'Approve art direction' })).toBeNull();
expect(box.textContent).not.toContain('Attach a visual cast');
expect(box.className).not.toContain('border-port-accent');
});
it('keeps the hash-selected art approval open and highlighted when readiness arrives, until approved', async () => {
vi.stubGlobal('fetch', vi.fn(async () => ({ ok: true })));
window.location.hash = '#mv-review-art';
const guided = { ...project, devArtifacts: [{ id: 'guide', title: 'Synthetic visual guide', version: 1, mimeType: 'image/png' }],
productionReview: { ...project.productionReview, draft: { ...project.productionReview.draft, guideArtifactId: 'guide' } } };
const review = reviewFixture(); review.readiness.art.approved = false;
const view = render(<ProductionReviewPanel project={guided} review={{ ...review, readiness: null }} onOpenArtifact={vi.fn()} stage="art" />);
view.rerender(<ProductionReviewPanel project={guided} review={review} onOpenArtifact={vi.fn()} stage="art" />);
const box = document.getElementById('mv-review-art');
expect(box).toBe(screen.getByRole('region', { name: 'Approve: Art direction' }));
expect(box.tagName).toBe('SECTION');
expect(within(box).getByRole('heading', { name: 'Approve the art direction' })).toBeTruthy();
expect(box.className).toContain('border-port-accent');
const approved = reviewFixture();
view.rerender(<ProductionReviewPanel project={guided} review={approved} onOpenArtifact={vi.fn()} stage="art" />);
await act(async () => {});
expect(within(box).getByRole('heading', { name: 'Art direction approved' })).toBeTruthy();
expect(box.className).not.toContain('border-port-accent');
});
it('shows the recorded review for an approved artifact without treating it as fresh playback evidence', () => {
const review = reviewFixture();
review.readiness.proof.approved = true;
const approved = { ...project, productionReview: { ...project.productionReview, approvals: { proof: { proofReview: {
excerptId: 'proof-a', filename: 'proof-a.mp4', watchedWithAudio: true,
energyComparison: 'The driving turn matches the saved energy target.', timecodedNotes: '0:04 — the figure turns on the downbeat.',
} } } } };
const view = render(<ProductionReviewPanel project={approved} review={review} onOpenArtifact={vi.fn()} stage="proof" />);
expect(screen.getByLabelText('Recorded proof review').textContent).toContain('0:04 — the figure turns on the downbeat.');
expect(screen.queryByRole('checkbox')).toBeNull();
expect(screen.getByLabelText('Notes (optional)').value).toBe('');
view.rerender(<ProductionReviewPanel project={{ ...approved, excerpts: [{ id: 'proof-a', filename: 'replacement.mp4', status: 'complete' }] }} review={review} onOpenArtifact={vi.fn()} stage="proof" />);
expect(screen.queryByLabelText('Recorded proof review')).toBeNull();
});
it.each([
{ id: 'proof-b', filename: 'proof-b.mp4' },
{ id: 'proof-a', filename: 'replacement.mp4' },
])('requires playing the new proof again when it changes to $filename without a creative-basis change', ({ id, filename }) => {
const review = reviewFixture();
const view = render(<ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="proof" />);
recordPlayback();
expect(screen.getByRole('button', { name: proofAction }).disabled).toBe(false);
const replacement = { ...project, productionReview: { ...project.productionReview, proof: { ...project.productionReview.proof, excerptId: id } },
excerpts: [{ id, filename, status: 'complete' }] };
view.rerender(<ProductionReviewPanel project={replacement} review={review} onOpenArtifact={vi.fn()} stage="proof" />);
expect(screen.queryByRole('checkbox')).toBeNull();
expect(screen.getByLabelText('Notes (optional)').value).toBe('');
expect(screen.getByRole('button', { name: proofAction }).disabled).toBe(true);
recordPlayback();
fireEvent.click(screen.getByRole('button', { name: proofAction }));
expect(review.approve).toHaveBeenCalledWith('proof', expect.objectContaining({
excerptId: id, filename, watchedWithAudio: true, timecodedNotes: NOTE,
}));
});
it('blocks approval and explains a failed proof player', () => {
const review = reviewFixture();
render(<ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="proof" />);
recordPlayback();
fireEvent.error(screen.getByLabelText('Animated proof with master audio'));
expect(screen.getByRole('alert').textContent).toContain('could not be played');
expect(screen.getByRole('button', { name: proofAction }).disabled).toBe(true);
});
it('keeps failed choreography saves dirty and blocks approval', async () => {
const review = reviewFixture();
// The page owns the planning draft so unsaved edits on the art step still block the proof step.
function Steps({ stage }) {
const planning = useState(null);
return <ProductionReviewPanel key={stage} project={project} review={review} onOpenArtifact={vi.fn()} stage={stage} planning={planning} />;
}
const view = render(<Steps stage="art" />);
fireEvent.change(screen.getByLabelText('Timed choreography and energy plan'), { target: { value: 'Energy target: explosive. 0:04 — replace the turn with a leap.' } });
fireEvent.click(screen.getByRole('button', { name: 'Save planning edits', hidden: true }));
await waitFor(() => expect(review.save).toHaveBeenCalled());
expect(screen.getByText('Save edits before preparing, approving or rendering.')).toBeTruthy();
// Art is already approved in this fixture, so it offers no Approve button, only Request changes.
expect(screen.queryByRole('button', { name: 'Approve art direction' })).toBeNull();
expect(screen.getByRole('button', { name: 'Request changes' })).toBeTruthy();
view.rerender(<Steps stage="proof" />);
fireEvent.loadedData(screen.getByLabelText('Animated proof with master audio'));
expect(screen.getByText('Save your planning edits first.', { selector: '#mv-review-example-project-proof-proof-approval-help' })).toBeTruthy();
expect(screen.getByLabelText('Notes (optional)').disabled).toBe(true);
expect(screen.getByRole('button', { name: proofAction }).disabled).toBe(true);
expect(review.approve).not.toHaveBeenCalled();
});
});
describe('Approval problems with unsaved edits', () => {
it.each([
[['Render and watch a current animated chorus proof with the master song.']],
[['Render and watch a current animated chorus proof with the master song.', 'Second problem.']],
])('lists every proof problem while planning edits are unsaved (%j)', (problems) => {
const review = reviewFixture();
review.readiness.proof = { ...review.readiness.proof, approved: false, problems };
function Board() {
const planning = useState({ ...project.productionReview.draft, cast: 'Edited cast' });
return <ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="proof" planning={planning} />;
}
render(<Board />);
expect(screen.getByText('Save your planning edits first.')).toBeTruthy();
for (const problem of problems) expect(screen.getByText(problem)).toBeTruthy();
});
it('shows the first proof problem once, on the help line, and names an open change request ahead of it', () => {
const review = reviewFixture();
review.readiness.proof = { ...review.readiness.proof, approved: false, problems: ['First problem.', 'Second problem.', 'Resolve proof feedback for chorus: hold longer'] };
const { unmount } = render(<ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="proof" />);
expect(screen.getAllByText(/First problem\./)).toHaveLength(1);
expect(screen.getByText('Second problem.')).toBeTruthy();
expect(screen.queryByText(/hold longer/)).toBeNull();
unmount();
const withRequest = { ...project, productionReview: { ...project.productionReview, feedback: [
{ id: 'fb-proof', stage: 'proof', target: 'chorus', text: 'hold longer', decision: 'request-changes', basis: 'same-creative-basis' }] } };
render(<ProductionReviewPanel project={withRequest} review={review} onOpenArtifact={vi.fn()} stage="proof" />);
expect(screen.getByText('Resolve the change request on chorus first.')).toBeTruthy();
expect(screen.getByText('First problem.')).toBeTruthy();
expect(screen.getByText('Second problem.')).toBeTruthy();
});
// Uniquely catches the lock card pointing at "items above" that live on another step.
it('names the open Plan items and their shots on the storyboard card, with a link to the Plan step', () => {
const review = reviewFixture();
const board = { ...project, composition: { mode: 'concat' }, scenes: [{ sceneId: 's-a', label: 'Verse', startSec: 0, endSec: 4 }, { sceneId: 's-b', label: 'Chorus', startSec: 3.5, endSec: 8 }] };
review.readiness.storyboard = { approved: false,
problems: ['Storyboard shots must cover the master without unintended gaps or overlaps.', 'Complete timing, action, staging, camera and transition for Chorus.'],
coverage: [{ sceneId: 's-b', issue: 'overlap', startSec: 3.5, endSec: 4 }], incompleteShots: [{ sceneId: 's-b', missing: ['staging'] }] };
const onNavigate = vi.fn();
render(<ProductionReviewPanel project={board} review={review} onOpenArtifact={vi.fn()} stage="storyboard" onNavigate={onNavigate} />);
expect(screen.getByText('Finish these 2 items on the Plan step first:')).toBeTruthy();
expect(screen.getByRole('list', { name: 'Open Plan items' }).textContent).toBe('Shot coverage (shot 2)Shot details (shot 2)');
expect(screen.queryByText(/without unintended gaps/)).toBeNull();
fireEvent.click(screen.getByRole('button', { name: 'Open the Plan step' }));
expect(onNavigate).toHaveBeenCalledWith('board');
});
});
describe('Lyric timing lives on the Song step', () => {
it('leaves song content and timing verification out of the storyboard planning editor', () => {
const review = reviewFixture();
review.readiness.alignment = { status: 'stale', basis: 'current-word-times' };
render(<ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="storyboard" />);
fireEvent.click(screen.getByText('Edit storyboard shots'));
expect(screen.queryByLabelText('Song content')).toBeNull();
expect(screen.queryByLabelText('Alignment status')).toBeNull();
expect(screen.queryByRole('button', { name: 'Reverify current timings' })).toBeNull();
// The storyboard source stays here: it is the storyboard's own input.
expect(screen.getByLabelText('Storyboard source')).toBeTruthy();
});
});
describe('Per-stage approval sections (#10151)', () => {
it('renders only its own stage and sends a missing prerequisite to the tab that owns it', () => {
const review = reviewFixture();
review.readiness.art.approved = false;
const prototype = { ...project, productionReview: { ...project.productionReview, proof: null, prototype: { excerptId: 'proof-a' } } };
const onNavigate = vi.fn();
render(<ProductionReviewPanel project={prototype} review={review} onOpenArtifact={vi.fn()} stage="proof" onNavigate={onNavigate} />);
expect(screen.queryByText('Art direction', { selector: 'summary' })).toBeNull();
expect(screen.queryByText('Edit art direction and visual guide')).toBeNull();
fireEvent.click(screen.getByText('Approve the art direction'));
expect(onNavigate).toHaveBeenCalledWith('cast-sets', 'mv-review-art');
});
it('keeps the art fields on the art section and the shot editor on the board section', () => {
const art = render(<ProductionReviewPanel project={project} review={reviewFixture()} onOpenArtifact={vi.fn()} stage="art" />);
expect(screen.getByLabelText('Cast guide')).toBeTruthy();
expect(screen.queryByLabelText('Storyboard source')).toBeNull();
art.unmount();
render(<ProductionReviewPanel project={project} review={reviewFixture()} onOpenArtifact={vi.fn()} stage="storyboard" />);
expect(screen.getByLabelText('Storyboard source')).toBeTruthy();
expect(screen.queryByLabelText('Cast guide')).toBeNull();
});
it('shows the approval on its step as an open box that closes the step, not a fold', () => {
const review = reviewFixture();
review.readiness.storyboard.approved = false;
const { container } = render(<ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="storyboard" />);
const box = screen.getByRole('region', { name: 'Approve: Lyric-timed storyboard' });
expect(box.id).toBe('mv-review-storyboard');
expect(box.tagName).toBe('SECTION');
expect(within(box).getByRole('heading', { name: 'Lock all stills' })).toBeTruthy();
expect(within(box).getByRole('button', { name: 'Lock all stills' })).toBeTruthy();
expect(within(box).getByRole('button', { name: 'Request changes' })).toBeTruthy();
expect(container.querySelector('details#mv-review-storyboard')).toBeNull();
// The decision sits at the top of the box, before the shots it is about.
const approveButton = within(box).getByRole('button', { name: 'Lock all stills' });
expect(approveButton.compareDocumentPosition(within(box).getByRole('region', { name: 'Storyboard review content' })) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
expect(screen.queryByText('About production approvals')).toBeNull();
});
});
describe('storyboard camera notes (#10589)', () => {
it('lists camera-variety notes under the storyboard without blocking approval', () => {
const review = reviewFixture();
const note = 'Chorus at 0:45 has no snap move: land a whip-pan, crash-zoom, dutch-roll, crash-zoom-out on its first downbeat.';
review.readiness.storyboard = { approved: false, problems: [], camera: { staticRuns: [], snaplessChoruses: [{ label: 'Chorus', startSec: 45 }], notes: [note] } };
render(<ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="storyboard" />);
const notes = screen.getByRole('note', { name: 'Camera variety notes' });
expect(within(notes).getByText(note)).toBeTruthy();
expect(screen.getByRole('button', { name: 'Lock all stills' }).disabled).toBe(false);
});
it('shows nothing when the camera plan is varied', () => {
const review = reviewFixture();
review.readiness.storyboard = { approved: false, problems: [], camera: { staticRuns: [], snaplessChoruses: [], notes: [] } };
render(<ProductionReviewPanel project={project} review={review} onOpenArtifact={vi.fn()} stage="storyboard" />);
expect(screen.queryByRole('note', { name: 'Camera variety notes' })).toBeNull();
});
});
describe('Board scenes planned without draft shots', () => {
it('counts and lists them in the storyboard approval card with the rows the server derived', () => {
const planned = { ...project, scenes: [
{ sceneId: 's1', label: 'Opening', startSec: 0, endSec: 4 },
{ sceneId: 's2', label: 'Chorus', startSec: 4, endSec: 8 },
] };
const review = reviewFixture();
review.readiness.storyboard = { approved: false, problems: [], shots: [
{ sceneId: 's1', lyricCueIds: [], action: 'She looks up from the monitor', staging: 'Medium shot', camera: 'Handheld drift', transition: 'Cut' },
{ sceneId: 's2', lyricCueIds: [], action: 'Film spills onto the floor', staging: 'Wide shot', camera: 'Handheld drift', transition: 'Cut' },
] };
render(<ProductionReviewPanel project={planned} review={review} onOpenArtifact={vi.fn()} stage="storyboard" />);
expect(screen.getByText(/Watch the storyboard in the player, then approve\. 2 storyboard shots/)).toBeTruthy();
expect(screen.queryByText(/No storyboard shots to review/)).toBeNull();
// The card's shot list and the shot editor both start from the derived row.
expect(screen.getAllByText('She looks up from the monitor')).toHaveLength(2);
});
});