mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 23:45:18 +00:00
- src/lib/sollinhaOpeningQuestions.ts: catálogo puro de chips de abertura (staff: 4 perguntas ancoradas nas tools atuais; leader: conjunto seguro sem tool eleitoral — fail-closed B180) - ChatChipGroup: primitivo presentacional reutilizável (slot compartilhado com o B192) - role do usuário flui do layout server pelo shell até o context do chat - slot acima do input renderiza só com conversa vazia (messages 0 + ready); tocar envia via sendMessage e os chips somem no primeiro envio - unit tests do catálogo + e2e (staff desktop 4 / mobile 3 / leader seguro)
56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
// @vitest-environment node
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { getSollinhaOpeningQuestions } from '@/lib/sollinhaOpeningQuestions'
|
|
|
|
const STAFF_TEXT = [
|
|
'Quem foi o deputado mais votado em Feira de Santana?',
|
|
'Quantos votos tivemos em Ilhéus em 2022?',
|
|
'Quais dobradinhas temos em Salvador?',
|
|
'Como está o município de Vitória da Conquista?',
|
|
]
|
|
|
|
const LEADER_TEXT = [
|
|
'O que você sabe fazer?',
|
|
'Me manda o link dos meus contatos',
|
|
'Me manda o link do meu perfil',
|
|
]
|
|
|
|
describe('getSollinhaOpeningQuestions', () => {
|
|
it('offers the full curated catalog to staff on desktop', () => {
|
|
for (const role of ['coordinator', 'advisor', 'candidate'] as const) {
|
|
const questions = getSollinhaOpeningQuestions(role, false)
|
|
expect(questions.map((q) => q.text)).toEqual(STAFF_TEXT)
|
|
}
|
|
})
|
|
|
|
it('caps staff catalog to 3 chips on mobile', () => {
|
|
for (const role of ['coordinator', 'advisor', 'candidate'] as const) {
|
|
const questions = getSollinhaOpeningQuestions(role, true)
|
|
expect(questions.map((q) => q.text)).toEqual(STAFF_TEXT.slice(0, 3))
|
|
}
|
|
})
|
|
|
|
it('gives leaders the safe set — never an election question', () => {
|
|
const questions = getSollinhaOpeningQuestions('leader', false)
|
|
expect(questions.map((q) => q.text)).toEqual(LEADER_TEXT)
|
|
for (const question of questions) {
|
|
expect(question.text).not.toMatch(
|
|
/deputado mais votado|votos tivemos|dobradinhas temos|como está o município/i,
|
|
)
|
|
}
|
|
})
|
|
|
|
it('keeps the leader safe set on mobile (3 chips)', () => {
|
|
expect(getSollinhaOpeningQuestions('leader', true).map((q) => q.text)).toEqual(LEADER_TEXT)
|
|
})
|
|
|
|
it('every text is non-empty and trimmed', () => {
|
|
for (const role of ['coordinator', 'leader'] as const) {
|
|
for (const question of getSollinhaOpeningQuestions(role, false)) {
|
|
expect(question.text.trim().length).toBeGreaterThan(0)
|
|
}
|
|
}
|
|
})
|
|
})
|