From 0d91531b909f07577921c80da0e7c26d9538ed04 Mon Sep 17 00:00:00 2001 From: DEV-bot Date: Sun, 15 Mar 2026 22:56:34 +0000 Subject: [PATCH] test(frontend): lock omitted reveal nickname contract --- frontend/tests/angular-api-client.test.ts | 64 ++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/frontend/tests/angular-api-client.test.ts b/frontend/tests/angular-api-client.test.ts index 584b289..5d58920 100644 --- a/frontend/tests/angular-api-client.test.ts +++ b/frontend/tests/angular-api-client.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from 'vitest'; import { createAngularApiClient, type AngularHttpClientLike } from '../src/api/angular-client'; -import { mapSubmitGuessResponse } from '../src/api/mappers'; +import { mapSessionDetailResponse, mapSubmitGuessResponse } from '../src/api/mappers'; describe('createAngularApiClient', () => { it('reads health and session detail using Django-compatible endpoints', async () => { @@ -401,6 +401,68 @@ describe('createAngularApiClient', () => { expect(mapped.guess.fooled_player_id).toBeNull(); }); + it('keeps fooled_player_nickname omitted when canonical reveal payload omits fooled player refs', () => { + const mapped = mapSessionDetailResponse({ + session: { code: 'ABCD12', status: 'reveal', host_id: 1, current_round: 1, players_count: 2 }, + players: [ + { id: 2, nickname: 'Maja', score: 10, is_connected: true }, + { id: 3, nickname: 'Bo', score: 7, is_connected: true } + ], + round_question: { + id: 77, + round_number: 1, + prompt: 'Q?', + shown_at: '2026-03-01T18:00:00Z', + answers: [{ text: 'A' }, { text: 'B' }] + }, + reveal: { + round_question_id: 77, + round_number: 1, + prompt: 'Q?', + correct_answer: 'A', + lies: [], + guesses: [ + { + player_id: 3, + nickname: 'Bo', + selected_text: 'A', + is_correct: true, + created_at: '2026-03-01T18:00:15Z' + } + ] + }, + phase_view_model: { + status: 'reveal', + round_number: 1, + players_count: 2, + constraints: { + min_players_to_start: 2, + max_players_mvp: 8, + min_players_reached: true, + max_players_allowed: true + }, + host: { + can_start_round: false, + can_show_question: false, + can_mix_answers: false, + can_calculate_scores: false, + can_reveal_scoreboard: true, + can_start_next_round: false, + can_finish_game: false + }, + player: { + can_join: true, + can_submit_lie: false, + can_submit_guess: false, + can_view_final_result: false + } + } + }); + + expect(mapped.reveal?.guesses[0].fooled_player_id).toBeNull(); + expect(mapped.reveal?.guesses[0]).not.toHaveProperty('fooled_player_nickname'); + }); + it('maps host/player gameplay endpoints through typed response mappers', async () => { const get = vi.fn(async (url: string) => { if (url === '/lobby/sessions/ABCD12/scoreboard') {