learning_ai_common_plat/packages/feedback-client/src/index.test.ts
saravanakumardb1 5195f9c052 fix(platform): production readiness — admin-web client bundling, config sub-path exports, stale tests
- dashboards/admin-web: split product-constants.ts for client-safe imports
- dashboards/admin-web: serverExternalPackages + webpack fallbacks for @bytelyst/config
- dashboards/admin-web: instrumentation.ts uses @bytelyst/config/keyvault sub-path
- packages/config: add ./keyvault and ./product-identity sub-path exports
- packages/feedback-client: fix stale test expectation (TODO-1 → actual error message)
- packages/sync: fix reprocessFailed test (flush already pushes items)
2026-03-12 16:49:15 -07:00

49 lines
1.3 KiB
TypeScript

import { describe, it, expect, vi } from 'vitest';
import { FeedbackClient } from './index.js';
import type { ApiClient } from '@bytelyst/api-client';
describe('FeedbackClient', () => {
const mockApi: Partial<ApiClient> = {
fetch: vi.fn(),
};
const createClient = () => new FeedbackClient(mockApi as ApiClient);
it('should submit feedback without screenshot', async () => {
const client = createClient();
const mockResponse = {
id: 'fb_123',
productId: 'test',
userId: 'user_123',
type: 'bug',
title: 'Test bug',
status: 'new',
createdAt: new Date().toISOString(),
};
mockApi.fetch = vi.fn().mockResolvedValue(mockResponse);
const result = await client.submitWithScreenshot({
type: 'bug',
title: 'Test bug',
body: 'Description',
});
expect(result).toEqual(mockResponse);
expect(mockApi.fetch).toHaveBeenCalledWith(
'/api/feedback',
expect.objectContaining({
method: 'POST',
})
);
});
it('should throw if captureAndSubmit called without screenshot', async () => {
const client = createClient();
await expect(client.captureAndSubmit({ type: 'bug', title: 'Test' })).rejects.toThrow(
'Screenshot capture only available in browser environment'
);
});
});