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:
@@ -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