mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-22 04:53:09 +00:00
fix(B55): defer share strategy to click + stabilize unit tests
This commit is contained in:
parent
b96bf190e8
commit
8ff9e20a88
4 changed files with 11 additions and 5 deletions
|
|
@ -71,6 +71,7 @@ export const E2E_AFFECTED_MANIFEST = [
|
||||||
'src/utilities/homeSearch',
|
'src/utilities/homeSearch',
|
||||||
'src/utilities/campaignDashboardData',
|
'src/utilities/campaignDashboardData',
|
||||||
'src/lib/campaignHomeSearchHits',
|
'src/lib/campaignHomeSearchHits',
|
||||||
|
'src/lib/homeSearchShare',
|
||||||
],
|
],
|
||||||
specs: ['campaignHomeActions'],
|
specs: ['campaignHomeActions'],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,10 @@ export const HomeSearchShareAction = ({
|
||||||
title: string
|
title: string
|
||||||
detailPath: string
|
detailPath: string
|
||||||
}) => {
|
}) => {
|
||||||
const strategy = resolveHomeSearchShareStrategy()
|
|
||||||
|
|
||||||
const handleShare = async () => {
|
const handleShare = async () => {
|
||||||
const absoluteUrl = buildHomeSearchDetailUrl(detailPath)
|
const absoluteUrl = buildHomeSearchDetailUrl(detailPath)
|
||||||
const shareText = buildHomeSearchShareText(title, absoluteUrl)
|
const shareText = buildHomeSearchShareText(title, absoluteUrl)
|
||||||
|
const strategy = resolveHomeSearchShareStrategy()
|
||||||
|
|
||||||
if (strategy === 'native') {
|
if (strategy === 'native') {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,9 @@ export const buildWhatsAppTextShareUrl = (message: string): string => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const canUseNativeWebShare = (): boolean =>
|
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'
|
export type HomeSearchShareStrategy = 'native' | 'whatsapp'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
import { fireEvent, render, screen } from '@testing-library/react'
|
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
|
||||||
import { describe, expect, it, vi } from 'vitest'
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||||
|
|
||||||
import { HomeSearchHitRow } from '@/components/campaign/dashboard/HomeSearchHitRow'
|
import { HomeSearchHitRow } from '@/components/campaign/dashboard/HomeSearchHitRow'
|
||||||
import { HomeSearchShareAction } from '@/components/campaign/dashboard/HomeSearchShareAction'
|
import { HomeSearchShareAction } from '@/components/campaign/dashboard/HomeSearchShareAction'
|
||||||
import { HomeSearchWhatsAppAction } from '@/components/campaign/dashboard/HomeSearchWhatsAppAction'
|
import { HomeSearchWhatsAppAction } from '@/components/campaign/dashboard/HomeSearchWhatsAppAction'
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
cleanup()
|
||||||
|
})
|
||||||
|
|
||||||
describe('HomeSearchWhatsAppAction', () => {
|
describe('HomeSearchWhatsAppAction', () => {
|
||||||
it('renders WhatsApp link when phone normalizes', () => {
|
it('renders WhatsApp link when phone normalizes', () => {
|
||||||
render(<HomeSearchWhatsAppAction phone="71999998888" contactName="Maria Silva" />)
|
render(<HomeSearchWhatsAppAction phone="71999998888" contactName="Maria Silva" />)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue