test(angular): strengthen gameplay wiring coverage for host/player flows
CI / test-and-quality (push) Successful in 2m20s
CI / test-and-quality (pull_request) Successful in 2m1s

This commit is contained in:
2026-03-01 14:46:21 +00:00
parent 89870f44ac
commit de4302622b
2 changed files with 99 additions and 0 deletions
@@ -71,4 +71,50 @@ describe('HostShellComponent gameplay wiring', () => {
expect(component.scoreboardError).toContain('Scoreboard failed: Scoreboard unavailable');
expect(component.loading).toBe(false);
});
it('wires showQuestion, mixAnswers and calculateScores with expected request payloads', async () => {
const sessionAfterAction = {
session: { code: 'ABCD12', status: 'guess', current_round: 1 },
round_question: { id: 77, prompt: 'Q?', answers: [] },
players: [],
};
const fetchMock: FetchMock = vi
.fn()
.mockResolvedValueOnce(jsonResponse(200, { ok: true }))
.mockResolvedValueOnce(jsonResponse(200, sessionAfterAction))
.mockResolvedValueOnce(jsonResponse(200, { ok: true }))
.mockResolvedValueOnce(jsonResponse(200, sessionAfterAction))
.mockResolvedValueOnce(jsonResponse(200, { ok: true }))
.mockResolvedValueOnce(jsonResponse(200, sessionAfterAction));
vi.stubGlobal('fetch', fetchMock);
const component = new HostShellComponent();
component.sessionCode = ' abcd12 ';
component.roundQuestionId = ' 77 ';
await component.showQuestion();
await component.mixAnswers();
await component.calculateScores();
expect(fetchMock).toHaveBeenNthCalledWith(
1,
'/lobby/sessions/ABCD12/questions/show',
expect.objectContaining({ method: 'POST', body: JSON.stringify({}) })
);
expect(fetchMock).toHaveBeenNthCalledWith(
3,
'/lobby/sessions/ABCD12/questions/77/answers/mix',
expect.objectContaining({ method: 'POST', body: JSON.stringify({}) })
);
expect(fetchMock).toHaveBeenNthCalledWith(
5,
'/lobby/sessions/ABCD12/questions/77/scores/calculate',
expect.objectContaining({ method: 'POST', body: JSON.stringify({}) })
);
expect(component.error).toBe('');
expect(component.loading).toBe(false);
});
});