Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
"node_modules/(?!(@wagmi|wagmi|viem|@viem|@walletconnect|@justaname\\.id|@zerodev|permissionless)/)"
],
"moduleNameMapper": {
"\\.(svg|png|jpg|jpeg|gif|webp)$": "jest-transform-stub",
"\\.(svg|png|jpg|jpeg|gif|webp)$": "<rootDir>/src/utils/__mocks__/static-image.ts",
"^@/config/wagmi\\.config$": "<rootDir>/src/utils/__mocks__/wagmi-config.ts",
"^wagmi/chains$": "<rootDir>/src/utils/__mocks__/wagmi.ts",
"^@justaname\\.id/react$": "<rootDir>/src/utils/__mocks__/justaname.ts",
Expand Down
2 changes: 0 additions & 2 deletions src/app/[...recipient]/error.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
'use client'

import { useEffect } from 'react'
import { useRouter } from 'next/navigation'
import { useModalsContext } from '@/context/ModalsContext'
import { Button } from '@/components/0_Bruddle/Button'
import { Card } from '@/components/0_Bruddle/Card'
import { recoverFromChunkError } from '@/utils/chunk-error-recovery'

export default function PaymentError({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) {
const router = useRouter()
const { setIsSupportModalOpen } = useModalsContext()

useEffect(() => {
Expand Down
16 changes: 16 additions & 0 deletions src/components/Badges/__tests__/badge.utils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { BADGES, getBadgeIcon } from '../badge.utils'

describe('getBadgeIcon', () => {
it('returns the badge path for known codes', () => {
expect(getBadgeIcon('WAITLIST_SKIP')).toBe(BADGES.WAITLIST_SKIP.path)
})

it('falls back to a string URL for unknown codes (raw <img src> consumers)', () => {
// Unknown codes happen in prod when the FE BADGES map drops a code the BE
// still awards (the recurring badge-registry silent-drop incident). The
// fallback must unwrap StaticImageData.src — never leak the object.
expect(typeof getBadgeIcon('NOT_A_REAL_BADGE')).toBe('string')
expect(getBadgeIcon('NOT_A_REAL_BADGE')).toBeTruthy()
expect(getBadgeIcon(undefined)).toBe(getBadgeIcon('NOT_A_REAL_BADGE'))
})
})
6 changes: 4 additions & 2 deletions src/components/Badges/badge.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ export const BADGES: Record<string, BadgeMeta> = {
* list. Used by /dev/share-builder + /dev/debug for iteration. */
export const BADGE_CODES: readonly string[] = Object.keys(BADGES)

export function getBadgeIcon(code?: string) {
return (code && BADGES[code]?.path) || PEANUTMAN_LOGO
export function getBadgeIcon(code?: string): string {
// .src: the svg import is StaticImageData (typed `any` by the module shim, so the
// annotation alone can't enforce this) — raw <img src> consumers need a string URL.
return (code && BADGES[code]?.path) || PEANUTMAN_LOGO.src
}

// returns the public-facing description for a badge code (third-person perspective)
Expand Down
2 changes: 1 addition & 1 deletion src/components/Jobs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export function Careers() {
return (
<div className="flex h-full flex-col-reverse items-center justify-center lg:flex-row">
<div className="w-4/5 md:w-1/2">
<img src={PeanutTooCool.src} className="h-full w-auto md:h-fit md:w-fit" />
<img src={PeanutTooCool.src} alt="" className="h-full w-auto md:h-fit md:w-fit" />
</div>
<div>
<div className="font-display text-xl lg:text-3xl">{'<'} Hey there! Want to work at Peanut?</div>
Expand Down
5 changes: 4 additions & 1 deletion src/components/Profile/views/UnlockedRegions.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ const UnlockedRegions = () => {
!!selectedRegion &&
clickedRegionProvider !== null &&
isSumsubApproved &&
(providerRejectionForRegion.state === 'fixable' || providerRejectionForRegion.state === 'blocked')
// Any non-happy state has a dedicated rendering in the ActionModal below.
// Derive from !== 'happy' so a new ProviderRejectionState member can't
// silently miss this gate again (restart-identity did exactly that).
providerRejectionForRegion.state !== 'happy'
const modalVariant = hasProviderRejectionForRegion ? ('provider_rejection' as const) : baseModalVariant

const handleFinalKycSuccess = useCallback(() => {
Expand Down
13 changes: 13 additions & 0 deletions src/utils/__mocks__/static-image.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Jest stand-in for Next.js static asset imports (svg/png/jpg/gif/webp).
// Next yields StaticImageData ({ src, width, height, ... }), but the previous
// jest-transform-stub flattened imports to a bare string — so any code reading
// `.src` (the prod pattern, e.g. getBadgeIcon's fallback) tested against
// fiction. Mirror the real shape so tests and prod agree.
const staticImageStub = {
src: '/test-file-stub',
height: 1,
width: 1,
blurDataURL: '/test-file-stub',
}

export default staticImageStub
Loading