Files
chat_web_app/llm-fe/src/llm-fe/utils/promptFeedback.test.ts
T
westfarn 4a172fce56
Unit Tests / test (pull_request) Failing after 4s
Add message actions and grounded citation Sources (#97, #98)
Wire copy/thumbs/export on chat bubbles and render live + hydrated Sources from citations frames so users can rate, export, and inspect grounded answers.
2026-08-03 14:25:10 -05:00

46 lines
1.2 KiB
TypeScript

import { upsertPromptFeedback, clearPromptFeedback } from './promptFeedback';
import { axiosInstance } from '../../axiosApi';
jest.mock('../../axiosApi', () => ({
axiosInstance: {
post: jest.fn(),
delete: jest.fn(),
},
}));
describe('promptFeedback optimistic helpers', () => {
const post = axiosInstance.post as jest.Mock;
const del = axiosInstance.delete as jest.Mock;
beforeEach(() => {
post.mockReset();
del.mockReset();
});
it('posts upsert payload', async () => {
post.mockResolvedValue({ data: { rating: 'up' } });
await upsertPromptFeedback(42, { rating: 'up' });
expect(post).toHaveBeenCalledWith('prompt_feedback', {
prompt_id: 42,
rating: 'up',
reason: undefined,
comment: undefined,
});
});
it('deletes vote by prompt_id', async () => {
del.mockResolvedValue({});
await clearPromptFeedback(42);
expect(del).toHaveBeenCalledWith('prompt_feedback', {
params: { prompt_id: 42 },
});
});
it('surfaces request failures for rollback callers', async () => {
post.mockRejectedValue(new Error('network'));
await expect(upsertPromptFeedback(1, { rating: 'down' })).rejects.toThrow(
'network',
);
});
});