This commit is contained in:
48
e2e/node/tests/embed_async_pending.test.ts
generated
Normal file
48
e2e/node/tests/embed_async_pending.test.ts
generated
Normal file
@@ -0,0 +1,48 @@
|
||||
// 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, embedTextsAsync, type EmbeddingConfig, type ExtractionConfig } from '@kreuzberg/node';
|
||||
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('embed_async_pending', () => { it('embed_texts_async_empty_input: embed_texts_async: empty text list', async () => { const result = await embedTextsAsync([], undefined); expect(result.length).toBe(0);
|
||||
|
||||
}, 600000);
|
||||
it('embed_texts_async_happy: embed_texts_async: basic async embedding', async () => { const result = await embedTextsAsync(["First", "Second"], undefined); expect(result.length).toBeGreaterThanOrEqual(2);
|
||||
|
||||
}, 600000);
|
||||
it('embed_texts_async_preset_switch: embed_texts_async: preset override', async () => { await embedTextsAsync(["Text"], { model: { name: "balanced", type: "preset" } } as ExtractionConfig);
|
||||
}, 600000);
|
||||
});
|
||||
Reference in New Issue
Block a user