fix(B55): defer share strategy to click + stabilize unit tests

This commit is contained in:
Cursor Agent 2026-07-30 22:36:58 +00:00
parent b96bf190e8
commit 8ff9e20a88
4 changed files with 11 additions and 5 deletions

View file

@ -71,6 +71,7 @@ export const E2E_AFFECTED_MANIFEST = [
'src/utilities/homeSearch',
'src/utilities/campaignDashboardData',
'src/lib/campaignHomeSearchHits',
'src/lib/homeSearchShare',
],
specs: ['campaignHomeActions'],
},

View file

@ -21,11 +21,10 @@ export const HomeSearchShareAction = ({
title: string
detailPath: string
}) => {
const strategy = resolveHomeSearchShareStrategy()
const handleShare = async () => {
const absoluteUrl = buildHomeSearchDetailUrl(detailPath)
const shareText = buildHomeSearchShareText(title, absoluteUrl)
const strategy = resolveHomeSearchShareStrategy()
if (strategy === 'native') {
try {

View file

@ -10,7 +10,9 @@ export const buildWhatsAppTextShareUrl = (message: string): string => {
}
const canUseNativeWebShare = (): boolean =>
typeof navigator !== 'undefined' && typeof navigator.share === 'function'
typeof window !== 'undefined' &&
typeof navigator !== 'undefined' &&
typeof navigator.share === 'function'
export type HomeSearchShareStrategy = 'native' | 'whatsapp'

View file

@ -1,10 +1,14 @@
import { fireEvent, render, screen } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { HomeSearchHitRow } from '@/components/campaign/dashboard/HomeSearchHitRow'
import { HomeSearchShareAction } from '@/components/campaign/dashboard/HomeSearchShareAction'
import { HomeSearchWhatsAppAction } from '@/components/campaign/dashboard/HomeSearchWhatsAppAction'
afterEach(() => {
cleanup()
})
describe('HomeSearchWhatsAppAction', () => {
it('renders WhatsApp link when phone normalizes', () => {
render(<HomeSearchWhatsAppAction phone="71999998888" contactName="Maria Silva" />)