Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

1.0 KB
Raw Blame
import { describe, expect, it } from 'vitest';

import { FTS_SEARCH_DOCUMENT_FIXTURES } from './__tests__/fixtures';
import { FTS_SEARCH_DOCUMENT_ENTITIES, parseFtsSearchDocumentSource } from './zodSchema';

describe('search document schemas', () => {
  it.each(FTS_SEARCH_DOCUMENT_ENTITIES)('parses the fixed %s fixture', (entity) => {
    expect(parseFtsSearchDocumentSource(entity, FTS_SEARCH_DOCUMENT_FIXTURES[entity])).toEqual(
      FTS_SEARCH_DOCUMENT_FIXTURES[entity],
    );
  });

  it('rejects fields not declared by the canonical document schema', () => {
    expect(() =>
      parseFtsSearchDocumentSource('agents', {
        ...FTS_SEARCH_DOCUMENT_FIXTURES.agents,
        undeclared_field: 'must not reach Elasticsearch',
      }),
    ).toThrow();
  });

  it('accepts the shared soft-delete projection marker', () => {
    expect(
      parseFtsSearchDocumentSource('agents', {
        ...FTS_SEARCH_DOCUMENT_FIXTURES.agents,
        fts_search_sync_deleted: true,
      }),
    ).toMatchObject({ fts_search_sync_deleted: true });
  });
});