mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-12 22:13:05 +00:00
Troca o motor do modo tema (Câmara + internet) de expansão lexical para embeddings (Deep Infra, BAAI/bge-m3), com índice próprio (speechEmbedding), ranking por proximidade em memória, evidência real do trecho mais próximo, vazio honesto por limiar e degradação para a busca literal. Inclui a collection oculta + migration, o CLI pnpm acervo:index (--dry-run/--limit/ --source/--force/--probe), o port do design aprovado e a suíte de testes. Pós-rebase: o snapshot da migration seguinte (20260926_062039_add_archive_photo, do C231 já na main) foi regenerado para incluir speech_embedding — sem ele o próximo migrate:create recriaria a tabela. Closes #1360
69 lines
2.6 KiB
TypeScript
69 lines
2.6 KiB
TypeScript
// @vitest-environment node
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
ACERVO_SORT_OPTIONS,
|
|
ACERVO_THEME_SORT_OPTIONS,
|
|
acervoSortIsDuration,
|
|
parseAcervoSort,
|
|
parseAcervoThemeSort,
|
|
} from '@/lib/acervoListSort'
|
|
|
|
// C216 — the shared ordering vocabulary of the acervo (recordings C219 + web
|
|
// speeches): `recentes` is the default and never serialized, and only the two
|
|
// duration orders count as duration sorts (the `where` gate follows them).
|
|
|
|
describe('parseAcervoSort', () => {
|
|
it('accepts only the non-default known orders', () => {
|
|
expect(parseAcervoSort('duracao_maior')).toBe('duracao_maior')
|
|
expect(parseAcervoSort('duracao_menor')).toBe('duracao_menor')
|
|
expect(parseAcervoSort('recentes')).toBeUndefined()
|
|
expect(parseAcervoSort('maratona')).toBeUndefined()
|
|
expect(parseAcervoSort(undefined)).toBeUndefined()
|
|
expect(parseAcervoSort(['duracao_maior', 'duracao_menor'])).toBe('duracao_maior')
|
|
})
|
|
})
|
|
|
|
describe('acervoSortIsDuration', () => {
|
|
it('flags only the duration orders', () => {
|
|
expect(acervoSortIsDuration('duracao_maior')).toBe(true)
|
|
expect(acervoSortIsDuration('duracao_menor')).toBe(true)
|
|
expect(acervoSortIsDuration('recentes')).toBe(false)
|
|
expect(acervoSortIsDuration(undefined)).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('ACERVO_SORT_OPTIONS', () => {
|
|
it('keeps the pt-BR labels of the approved control', () => {
|
|
expect(ACERVO_SORT_OPTIONS).toEqual([
|
|
{ value: 'recentes', label: 'Mais recentes' },
|
|
{ value: 'duracao_maior', label: 'Duração (maior)' },
|
|
{ value: 'duracao_menor', label: 'Duração (menor)' },
|
|
])
|
|
})
|
|
})
|
|
|
|
// C229 — the theme vocabulary of the speech acervo: relevance is the default
|
|
// and `recentes` must remain askable; recordings/Central keep the list above.
|
|
describe('theme sort vocabulary', () => {
|
|
it('opens with relevance and keeps the shared options', () => {
|
|
expect(ACERVO_THEME_SORT_OPTIONS).toEqual([
|
|
{ value: 'relevancia', label: 'Mais relevantes' },
|
|
...ACERVO_SORT_OPTIONS,
|
|
])
|
|
})
|
|
|
|
it('parses relevance and unknown values as the default', () => {
|
|
expect(parseAcervoThemeSort('relevancia')).toBeUndefined()
|
|
expect(parseAcervoThemeSort('maratona')).toBeUndefined()
|
|
expect(parseAcervoThemeSort(undefined)).toBeUndefined()
|
|
})
|
|
|
|
it('keeps recentes and the duration orders meaningful', () => {
|
|
expect(parseAcervoThemeSort('recentes')).toBe('recentes')
|
|
expect(parseAcervoThemeSort('duracao_maior')).toBe('duracao_maior')
|
|
expect(parseAcervoThemeSort('duracao_menor')).toBe('duracao_menor')
|
|
expect(parseAcervoThemeSort(['recentes', 'duracao_maior'])).toBe('recentes')
|
|
})
|
|
})
|