test(frontend): harden reveal fooled-player normalization
All checks were successful
CI / test-and-quality (push) Successful in 2m52s
CI / test-and-quality (pull_request) Successful in 2m53s

This commit is contained in:
2026-03-15 22:14:54 +00:00
parent 0b0e3c325c
commit e566e0967d
2 changed files with 34 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
import { describe, expect, it, vi } from 'vitest';
import { createAngularApiClient, type AngularHttpClientLike } from '../src/api/angular-client';
import { mapSubmitGuessResponse } from '../src/api/mappers';
describe('createAngularApiClient', () => {
it('reads health and session detail using Django-compatible endpoints', async () => {
@@ -384,6 +385,22 @@ describe('createAngularApiClient', () => {
}
});
it('maps omitted fooled_player_id to null in submit guess mapper payloads', () => {
const mapped = mapSubmitGuessResponse({
guess: {
id: 200,
player_id: 9,
round_question_id: 77,
selected_text: 'A',
is_correct: false,
created_at: '2026-03-01T16:01:00Z'
},
window: { guess_deadline_at: '2026-03-01T16:01:30Z' }
});
expect(mapped.guess.fooled_player_id).toBeNull();
});
it('maps host/player gameplay endpoints through typed response mappers', async () => {
const get = vi.fn<AngularHttpClientLike['get']>(async <T>(url: string) => {
if (url === '/lobby/sessions/ABCD12/scoreboard') {