mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 15:13:07 +00:00
Modo "Por tema" no acervo de falas: expansão determinística do tema via DeepSeek (generateObject, timeout, fallback null) alimenta o motor lexical existente (searchText/keywords OR), mantendo facetas AND, paginação por fala, o OR de cortes do C174 e o access control intacto. Resultado de tema mostra selo e "Por que apareceu" com trecho real (frase contínua), sem score; degradação honesta para termo exato com aviso e vazio honesto com saídas. - URL: mode=tema (default omitido; canonicaliza sem q), seletor otimista - ai/expandSpeechSearchTheme + lib/speechThemeTerms (sanitiza saída do modelo) - view model com themeMatchTerm + espelho speechMatchesSearchTerm - UI do card de tema (selos, proveniência, ações) e aviso degradado - sem migration/Consent/exposição pública; gate de leitura inalterado - testes unit/int/e2e; design hi-fi estendido e certificado pelo designer
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
// @vitest-environment node
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { MAX_SPEECH_THEME_TERMS, normalizeSpeechThemeTerms } from '@/lib/speechThemeTerms'
|
|
|
|
describe('normalizeSpeechThemeTerms (C192)', () => {
|
|
it('removes LIKE wildcards so the expansion cannot widen the pattern', () => {
|
|
expect(normalizeSpeechThemeTerms(['saúde%', 'a_b', 'c\\d'])).toEqual(['saúde', 'a b', 'c d'])
|
|
})
|
|
|
|
it('drops empty and too-short terms', () => {
|
|
expect(normalizeSpeechThemeTerms(['', ' ', 'ab', 'SUS', 'de'])).toEqual(['SUS'])
|
|
})
|
|
|
|
it('dedupes by normalized form keeping the first spelling', () => {
|
|
expect(normalizeSpeechThemeTerms(['Saúde Pública', 'saude publica', 'SUS'])).toEqual([
|
|
'Saúde Pública',
|
|
'SUS',
|
|
])
|
|
})
|
|
|
|
it('caps the list length', () => {
|
|
const values = Array.from({ length: 20 }, (_, index) => `termo ${index}`)
|
|
expect(normalizeSpeechThemeTerms(values)).toHaveLength(MAX_SPEECH_THEME_TERMS)
|
|
})
|
|
|
|
it('truncates a single term to the max length', () => {
|
|
const term = 'x'.repeat(90)
|
|
expect(normalizeSpeechThemeTerms([term])[0]).toHaveLength(60)
|
|
})
|
|
})
|