feat(finale): deliberation jury identity resolution, rankable projects, score-revision path, session sync

- submitVote resolves the caller's JuryGroupMember participant row server-side
  (was comparing JuryGroupMember id to User id — every juror got FORBIDDEN)
- getSessionWithVotes now includes category projects so the ranking form has
  data before finalize
- liveVoting.vote accepts any finale-ordered project (revision during
  deliberation); timed window still applies to the live project
- live.sendToScreens keeps LiveVotingSession.currentProjectId/status in sync

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt
2026-06-10 18:15:45 +02:00
parent 4e6904fa12
commit c9dc1bfabd
7 changed files with 229 additions and 18 deletions

View File

@@ -88,12 +88,56 @@ describe('vote comments', () => {
})
})
describe('deliberation-time revision', () => {
it('allows voting for an ordered project that is not currently presenting', async () => {
const otherProject = await createTestProject(program.id, {
competitionCategory: 'BUSINESS_CONCEPT',
})
await prisma.round.update({
where: { id: round.id },
data: { configJson: { projectOrder: [project.id, otherProject.id] } },
})
// otherProject is NOT currentProjectId — revision path must accept it
const vote = await jurorCaller.vote({
sessionId: session.id,
projectId: otherProject.id,
score: 6,
comment: 'revised during deliberation',
})
expect(vote.projectId).toBe(otherProject.id)
})
it('still rejects projects outside the finale order', async () => {
const stranger = await createTestProject(program.id)
await expect(
jurorCaller.vote({ sessionId: session.id, projectId: stranger.id, score: 5 })
).rejects.toThrow()
})
it('allows revision while the session is PAUSED', async () => {
await prisma.liveVotingSession.update({
where: { id: session.id },
data: { status: 'PAUSED' },
})
const vote = await jurorCaller.vote({
sessionId: session.id,
projectId: project.id,
score: 10,
})
expect(vote.score).toBe(10)
await prisma.liveVotingSession.update({
where: { id: session.id },
data: { status: 'IN_PROGRESS' },
})
})
})
describe('getSessionForVotingByRound', () => {
it('resolves the session from a roundId', async () => {
const data = await jurorCaller.getSessionForVotingByRound({ roundId: round.id })
expect(data?.session.id).toBe(session.id)
expect(data?.currentProject?.id).toBe(project.id)
expect(data?.userVote?.score).toBe(7)
expect(data?.userVote?.score).toBe(10) // last revision in the PAUSED test
})
it('returns null when the round has no session (creates nothing)', async () => {
@@ -111,9 +155,9 @@ describe('getMyFinaleInputs', () => {
})
const inputs = await jurorCaller.getMyFinaleInputs({ roundId: round.id })
expect(inputs.session?.id).toBe(session.id)
expect(inputs.votes).toHaveLength(1)
expect(inputs.votes[0].projectId).toBe(project.id)
expect(inputs.votes[0].comment).toBe('Revised after Q&A')
expect(inputs.votes).toHaveLength(2) // original + deliberation-time revision
const mainVote = inputs.votes.find((v: any) => v.projectId === project.id)
expect(mainVote?.comment).toBe('Revised after Q&A')
expect(inputs.notes).toHaveLength(1)
expect(inputs.notes[0].content).toBe('ceremony note')
})