@@ -89,7 +86,4 @@ export function firstName(name: string | null | undefined): string | null { * Taken from the same pair of verbs the response controls use, so the record and * the button above it cannot describe one act two ways. */ -const RESPONSE_WORD = { - stance: { agree: 'agrees', disagree: 'disagrees' }, - veracity: { agree: 'verifies', disagree: 'disputes' }, -} as const; +const RESPONSE_WORD = { agree: 'agrees', disagree: 'disagrees' } as const; diff --git a/apps/web/partials/profile/gallery-claim-card.test.tsx b/apps/web/partials/profile/gallery-claim-card.test.tsx new file mode 100644 index 0000000000..b7a9a30801 --- /dev/null +++ b/apps/web/partials/profile/gallery-claim-card.test.tsx @@ -0,0 +1,92 @@ +import '@testing-library/jest-dom/vitest'; +import { cleanup, render, screen } from '@testing-library/react'; + +import * as React from 'react'; + +import { afterEach, describe, expect, it, vi } from 'vitest'; + +import type { ExploreFeedRow } from '~/core/explore/explore-card-item'; + +import { GalleryClaimCard } from './gallery-claim-card'; + +/** + * Both claim lookups answer with nothing, which is the state the tag used to be hidden behind. + * + * `isResponseKindResolved` is `row !== null || entity !== null`, so this is the case where it never + * becomes true — a claim geo-chat does not index whose entity read also comes back empty. + */ +vi.mock('~/core/debates/hooks', () => ({ + useDebateClaims: () => ({ data: { claims: [] }, isLoading: false, error: null }), +})); + +vi.mock('~/core/sync/use-store', () => ({ + useQueryEntity: () => ({ entity: null, isLoading: false }), +})); + +/** + * `isResponseKindResolved: false` is the state under test — set here rather than inferred from the + * two lookups above, so the case cannot quietly stop being reachable if the hook's definition of + * "resolved" changes. The real hook also reaches wagmi, which this suite has no use for. + */ +vi.mock('~/core/claims/browse/use-claim-response-state', () => ({ + useClaimResponseState: () => ({ + claim: { id: 'claim-1', space_id: 'space-1', claim_entity_id: 'claim-1', claim: 'A claim', description: null }, + positions: [], + readiness: { + response_kind: 'stance', + viewer_response: null, + viewer_debate_ready: false, + readiness_disabled_reason: null, + }, + isResponseKindResolved: false, + isViewerResponseResolved: false, + responseBlockedReason: null, + }), +})); + +vi.mock('~/core/hooks/use-near-viewport', () => ({ + useNearViewport: () => [vi.fn(), true] as const, +})); + +vi.mock('~/core/hooks/use-privy-sign-in', () => ({ usePrivySignIn: () => vi.fn() })); + +/** The card under test only has to hand the note down; the pills themselves are another suite's. */ +vi.mock('~/core/debates/matchmaking/matchmaking-claim-card', () => ({ + MatchmakingClaimCard: ({ noteFor }: { noteFor?: (position: boolean) => React.ReactNode }) => ( +