- Removed deprecated functions related to document parsing and blob storage in blobstore.ts. - Introduced new PDF rendering logic in pdf-preview-renderer.ts and pdf-preview-pdfjs-runtime.ts. - Updated previews-render.ts to utilize the new PDF rendering functions. - Refactored user-whisper-align-job.ts to use the compute-worker client for alignment requests. - Enhanced artifact.ts and operation.ts to validate parsed PDF artifacts and resolve current PDF parses. - Updated snapshot.ts to align with new worker operation types. - Adjusted runtime-config.ts to check for compute-worker availability. - Modified types in parsed-pdf.ts and tts.ts to reflect changes in the compute-worker protocol. - Added unit tests for PDF artifact validation and compute-worker client contract. - Removed obsolete pdf-op-key.vitest.spec.ts test file.
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { describe, expect, test, vi } from 'vitest';
|
|
import { persistParsedPdfWhileSourceExists } from '../../src/pdf-artifact-persistence';
|
|
|
|
describe('PDF artifact persistence', () => {
|
|
test('does not write parsed output after the source was deleted', async () => {
|
|
const putParsedObject = vi.fn(async () => 'parsed.json');
|
|
|
|
await expect(persistParsedPdfWhileSourceExists({
|
|
sourceObjectKey: 'document.pdf',
|
|
sourceExists: async () => false,
|
|
putParsedObject,
|
|
deleteParsedObject: async () => undefined,
|
|
})).rejects.toThrow('before parsed output');
|
|
|
|
expect(putParsedObject).not.toHaveBeenCalled();
|
|
});
|
|
|
|
test('removes parsed output when the source disappears during the write', async () => {
|
|
const sourceExists = vi.fn()
|
|
.mockResolvedValueOnce(true)
|
|
.mockResolvedValueOnce(false);
|
|
const deleteParsedObject = vi.fn(async () => undefined);
|
|
|
|
await expect(persistParsedPdfWhileSourceExists({
|
|
sourceObjectKey: 'document.pdf',
|
|
sourceExists,
|
|
putParsedObject: async () => 'parsed.json',
|
|
deleteParsedObject,
|
|
})).rejects.toThrow('while parsed output');
|
|
|
|
expect(deleteParsedObject).toHaveBeenCalledWith('parsed.json');
|
|
});
|
|
});
|