Files
fil/e2e/wasm/tests/smoke.test.ts

46 lines
2.9 KiB
TypeScript
Raw Permalink Normal View History

2026-06-01 23:40:55 +02:00
// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef
import { describe, expect, it } from 'vitest';import { extractFile, extractBytes, WasmExtractionConfig, WasmAccelerationConfig, WasmChunkingConfig, WasmContentFilterConfig, WasmEmailConfig, WasmEmbeddingConfig, WasmHierarchyConfig, WasmHtmlOutputConfig, WasmImageExtractionConfig, WasmImagePreprocessingConfig, WasmKeywordConfig, WasmLanguageDetectionConfig, WasmLayoutDetectionConfig, WasmLlmConfig, WasmOcrConfig, WasmOcrElementConfig, WasmOcrPipelineConfig, WasmOcrPipelineStage, WasmOcrQualityThresholds, WasmPageConfig, WasmPdfConfig, WasmPostProcessorConfig, WasmRakeParams, WasmSecurityLimits, WasmStructuredExtractionConfig, WasmTesseractConfig, WasmTokenReductionOptions, WasmTreeSitterConfig, WasmTreeSitterProcessConfig, WasmYakeParams } from '@kreuzberg/wasm';
function _alefE2eText(value: unknown): string {
return value == null ? "" : String(value);
}
function _alefE2eItemTexts(item: unknown): string[] {
if (item == null || typeof item !== "object") {
return [_alefE2eText(item)];
}
const record = item as Record<string, unknown>;
const itemsText = Array.isArray(record.items) ? record.items.map(_alefE2eText).join(" ") : "";
return [_alefE2eText(item), _alefE2eText(record.kind), _alefE2eText(record.name), _alefE2eText(record.source), _alefE2eText(record.alias), _alefE2eText(record.text), _alefE2eText(record.signature), itemsText];
}
function _alefE2eFormatMetadataDisplay(fm: unknown): string {
if (fm == null) return "";
if (typeof fm !== "object") return String(fm);
const record = fm as Record<string, unknown>;
const formatType = record.format_type;
// FormatMetadata is a tagged union: { format_type: 'image', image: { format: 'PNG', ... }, ... }
// Extract the display string based on the variant type
if (formatType === "image" && typeof record.image === "object") {
const imageData = record.image as Record<string, unknown>;
if (typeof imageData.format === "string") return imageData.format;
}
// Fallback: return format_type variant name
if (typeof record.format_type === "string") return record.format_type;
return "";
}
describe('smoke', () => { it('ocr_image_png: OCR: PNG image extraction with OCR enabled. In WASM this exercises the Uint8Array bridge parameter and Promise await in the generated OcrBackend bridge.', async () => { const _content_content = await (await import('node:fs/promises')).readFile('images/test_hello_world.png'); const result = await extractBytes(_content_content, "image/png", undefined); expect(result.mimeType.trim()).toBe("image/png");
expect(result.content.length).toBeGreaterThanOrEqual(1);
expect(["Hello", "World", "hello", "world"].some((v) => result.content.includes(v))).toBe(true);
}, 30000);
});