mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 06:43:06 +00:00
Adiciona trailing actions nas linhas de resultado da busca global: - WhatsApp em lideranças e assessores (reusa whatsAppHrefForPhone) - Compartilhar em demandas e atividades (Web Share nativo com fallback wa.me) - trailingAction fora do Link da linha para não roubar navegação Closes #9
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
buildHomeSearchShareText,
|
|
buildHomeSearchWhatsAppShareHref,
|
|
buildWhatsAppTextShareUrl,
|
|
resolveHomeSearchShareStrategy,
|
|
} from '@/lib/homeSearchShare'
|
|
|
|
describe('homeSearchShare', () => {
|
|
it('builds share text from title and absolute URL', () => {
|
|
expect(
|
|
buildHomeSearchShareText('Atividade X', 'https://campanha.test/campanha/atividades/x'),
|
|
).toBe('Atividade X\nhttps://campanha.test/campanha/atividades/x')
|
|
})
|
|
|
|
it('builds wa.me text-only share URL', () => {
|
|
const href = buildWhatsAppTextShareUrl('Olá\nhttps://example.com')
|
|
expect(href).toBe('https://wa.me/?text=Ol%C3%A1%0Ahttps%3A%2F%2Fexample.com')
|
|
})
|
|
|
|
it('falls back to whatsapp strategy when navigator.share is unavailable', () => {
|
|
expect(resolveHomeSearchShareStrategy()).toBe('whatsapp')
|
|
})
|
|
|
|
it('builds WhatsApp share href for desktop fallback', () => {
|
|
const href = buildHomeSearchWhatsAppShareHref(
|
|
'Demanda Y',
|
|
'https://campanha.test/campanha/demandas/y',
|
|
)
|
|
expect(href).toContain('https://wa.me/?text=')
|
|
expect(href).toContain('Demanda+Y')
|
|
expect(href).toContain(encodeURIComponent('https://campanha.test/campanha/demandas/y'))
|
|
})
|
|
})
|