Cover raw and TIFF import in tests and show decode details
The new tests pin the CR2/NEF/CR3/DNG and TIFF routing, container signatures and TIFF proxy decoding, with an opt-in fixture run for real raw files. The Info panel now reports the decoder and the proxy size, so a file that fell back to a camera preview is visible at a glance.
This commit is contained in:
@@ -30,6 +30,8 @@ export interface UploadResult {
|
||||
size?: number;
|
||||
previewUrl?: string;
|
||||
thumbUrl?: string;
|
||||
/** Size of the JPEG proxy the server wrote, when it decoded this file. */
|
||||
previewBytes?: number;
|
||||
note?: string | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -652,6 +652,10 @@ export function normalizePhoto(input: Partial<PhotoRecord> & { id: string }): Ph
|
||||
typeof input.previewVersion === 'number' && Number.isFinite(input.previewVersion)
|
||||
? input.previewVersion
|
||||
: undefined,
|
||||
proxyBytes:
|
||||
typeof input.proxyBytes === 'number' && Number.isFinite(input.proxyBytes)
|
||||
? input.proxyBytes
|
||||
: undefined,
|
||||
proofAt: typeof input.proofAt === 'number' && Number.isFinite(input.proofAt) ? input.proofAt : undefined,
|
||||
name: input.name ?? 'Untitled',
|
||||
width: input.width ?? 0,
|
||||
|
||||
@@ -162,6 +162,7 @@ async function importRaw(
|
||||
history: [{ label: 'Import', ts: Date.now(), edits }],
|
||||
raw,
|
||||
decode: upload.engine,
|
||||
proxyBytes: upload.previewBytes,
|
||||
previewUrl,
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
RAW_ACCEPT,
|
||||
RAW_EXTENSIONS,
|
||||
SERVER_IMAGE_EXTENSIONS,
|
||||
isRawFile,
|
||||
isTiffFile,
|
||||
} from './raw';
|
||||
import { isSupportedFile } from './import';
|
||||
|
||||
/** isRawFile/isTiffFile only read the name; isSupportedFile also reads type. */
|
||||
function fakeFile(name: string, type = ''): File {
|
||||
return { name, type } as File;
|
||||
}
|
||||
|
||||
describe('import format routing', () => {
|
||||
it.each(['CR2', 'NEF', 'CR3', 'DNG'])('sends .%s to the server raw decoder', (ext) => {
|
||||
const file = fakeFile(`IMG_0001.${ext}`, 'application/octet-stream');
|
||||
expect(RAW_EXTENSIONS.has(ext.toLowerCase())).toBe(true);
|
||||
expect(isRawFile(file)).toBe(true);
|
||||
expect(isTiffFile(file)).toBe(false);
|
||||
expect(isSupportedFile(file)).toBe(true);
|
||||
});
|
||||
|
||||
it.each(['TIF', 'TIFF'])('sends .%s to the server still decoder', (ext) => {
|
||||
const file = fakeFile(`scan.${ext}`, 'image/tiff');
|
||||
expect(SERVER_IMAGE_EXTENSIONS.has(ext.toLowerCase())).toBe(true);
|
||||
expect(isTiffFile(file)).toBe(true);
|
||||
expect(isRawFile(file)).toBe(false);
|
||||
expect(isSupportedFile(file)).toBe(true);
|
||||
});
|
||||
|
||||
it('still accepts the browser-decoded formats', () => {
|
||||
expect(isSupportedFile(fakeFile('photo.jpg', 'image/jpeg'))).toBe(true);
|
||||
expect(isSupportedFile(fakeFile('photo.png', 'image/png'))).toBe(true);
|
||||
expect(isSupportedFile(fakeFile('photo.webp', 'image/webp'))).toBe(true);
|
||||
expect(isSupportedFile(fakeFile('photo.avif', 'image/avif'))).toBe(true);
|
||||
expect(isSupportedFile(fakeFile('notes.txt', 'text/plain'))).toBe(false);
|
||||
});
|
||||
|
||||
it('offers every supported extension in the file picker', () => {
|
||||
for (const ext of ['cr2', 'nef', 'cr3', 'dng', 'tif', 'tiff', 'sraw']) {
|
||||
expect(RAW_ACCEPT.split(',')).toContain(`.${ext}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user