test(feedback): Phase 1.5 - add screenshot and deviceContext schema tests
This commit is contained in:
parent
ecb9f67c99
commit
e712968d3d
@ -103,3 +103,70 @@ describe('QueryFeedbackSchema', () => {
|
|||||||
expect(() => QueryFeedbackSchema.parse({ limit: '101' })).toThrow();
|
expect(() => QueryFeedbackSchema.parse({ limit: '101' })).toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// Screenshot Support Tests (Phase 1.5)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
describe('CreateFeedbackSchema with screenshot', () => {
|
||||||
|
it('accepts feedback with screenshot metadata', () => {
|
||||||
|
const result = CreateFeedbackSchema.parse({
|
||||||
|
type: 'bug',
|
||||||
|
title: 'Crash with screenshot',
|
||||||
|
body: 'App crashes when I tap this button',
|
||||||
|
screenshotBlobPath: 'feedback/test_product/fb_123/screenshot_abc.png',
|
||||||
|
screenshotContentType: 'image/png',
|
||||||
|
screenshotSizeBytes: 1024000,
|
||||||
|
deviceContext: {
|
||||||
|
osVersion: 'iOS 17.4',
|
||||||
|
appVersion: '2.3.1',
|
||||||
|
deviceModel: 'iPhone15,2',
|
||||||
|
screenResolution: '393x852',
|
||||||
|
locale: 'en-US',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(result.screenshotBlobPath).toBe('feedback/test_product/fb_123/screenshot_abc.png');
|
||||||
|
expect(result.screenshotContentType).toBe('image/png');
|
||||||
|
expect(result.screenshotSizeBytes).toBe(1024000);
|
||||||
|
expect(result.deviceContext?.osVersion).toBe('iOS 17.4');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('accepts feedback without screenshot (backward compatible)', () => {
|
||||||
|
const result = CreateFeedbackSchema.parse({
|
||||||
|
type: 'feature',
|
||||||
|
title: 'Add dark mode',
|
||||||
|
});
|
||||||
|
expect(result.screenshotBlobPath).toBeUndefined();
|
||||||
|
expect(result.deviceContext).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects invalid screenshot content type', () => {
|
||||||
|
expect(() =>
|
||||||
|
CreateFeedbackSchema.parse({
|
||||||
|
type: 'bug',
|
||||||
|
title: 'test',
|
||||||
|
screenshotContentType: 'image/gif', // not allowed
|
||||||
|
})
|
||||||
|
).toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rejects screenshot over 10MB', () => {
|
||||||
|
expect(() =>
|
||||||
|
CreateFeedbackSchema.parse({
|
||||||
|
type: 'bug',
|
||||||
|
title: 'test',
|
||||||
|
screenshotSizeBytes: 11 * 1024 * 1024, // 11MB
|
||||||
|
})
|
||||||
|
).toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('accepts webp screenshots', () => {
|
||||||
|
const result = CreateFeedbackSchema.parse({
|
||||||
|
type: 'bug',
|
||||||
|
title: 'test',
|
||||||
|
screenshotContentType: 'image/webp',
|
||||||
|
screenshotSizeBytes: 500000,
|
||||||
|
});
|
||||||
|
expect(result.screenshotContentType).toBe('image/webp');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user