Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api_productions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ const apiProductions: FastifyPluginCallback<ApiProductionsOptions> = (
'Provide client local SDP description as request body to finalize connection protocol.',
params: SessionIdParams,
response: {
200: Type.String(),
204: Type.Null(),
400: Type.String(),
500: Type.String()
}
Expand Down
24 changes: 24 additions & 0 deletions src/api_validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ const mockProductionManager = {
.mockImplementation((lines: any[], id: string) =>
lines.find((l: any) => l.id === id)
),
requireLine: jest.fn().mockImplementation((lines: any[], id: string) => {
const found = lines.find((l: any) => l.id === id);
if (!found) throw new Error(`Line ${id} not found`);
return found;
}),
updateUserLastSeen: jest.fn().mockReturnValue(true),
deleteProductionLine: jest.fn().mockResolvedValue(undefined),
deleteProduction: jest.fn().mockResolvedValue(true),
Expand Down Expand Up @@ -234,6 +239,25 @@ describe('Input Validation', () => {
expect(response.statusCode).not.toBe(400);
});

test('PATCH /session/:sessionId returns 204 with empty body on success', async () => {
mockDbManager.getSession.mockResolvedValueOnce({
productionId: '1',
lineId: 'lid-1',
endpointId: 'endpoint-1',
sessionDescription: { audio: {} }
});
mockCoreFunctions.handleAnswerRequest = jest
.fn()
.mockResolvedValue(undefined);
const response = await server.inject({
method: 'PATCH',
url: '/api/v1/session/valid-session-id',
body: { sdpAnswer: 'v=0\r\n' }
});
expect(response.statusCode).toBe(204);
expect(response.body).toBe('');
});

test('DELETE /session/:sessionId accepts non-empty sessionId', async () => {
const response = await server.inject({
method: 'DELETE',
Expand Down
Loading