Skip to content
Merged
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
7 changes: 4 additions & 3 deletions react/lib/tests/components/Widget.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { TEST_ADDRESSES } from '../util/constants'
import copyToClipboard from 'copy-to-clipboard'
import type { Currency } from '../../util'
import { isFiat } from '../../util';
import config from '../../paybutton-config.json'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# 1. Confirm paybutton-config.json exists at the expected path
echo "=== Searching for paybutton-config.json ==="
fd -e json "paybutton-config.json" 2>/dev/null || echo "No matches found"

# 2. Print its contents to verify apiBaseUrl is present
echo -e "\n=== Contents of paybutton-config.json ==="
fd -e json "paybutton-config.json" -x cat {} 2>/dev/null || echo "File not found"

# 3. Verify Jest config handles JSON imports
echo -e "\n=== Jest configuration ==="
fd "jest.config" -type f | head -5 | xargs -I {} sh -c 'echo "File: {}"; cat {}' 2>/dev/null || echo "Jest config not found"

# 4. Check package.json for Jest config inline
echo -e "\n=== Jest config in package.json ==="
fd "package.json" -type f | head -1 | xargs -I {} sh -c 'cat {} | grep -A 20 "jest"' 2>/dev/null || echo "No Jest config in package.json"

Repository: PayButton/paybutton

Length of output: 573


🏁 Script executed:

#!/bin/bash
# 1. List all JSON files in the repo
echo "=== All JSON files in repo ==="
find . -name "*.json" -type f | grep -E "(paybutton|jest|package)" | head -20

# 2. Check directory structure of react/lib
echo -e "\n=== Files in react/lib ==="
find react/lib -maxdepth 2 -type f -name "*.json" 2>/dev/null | head -20

# 3. Check if Widget.test.tsx exists
echo -e "\n=== Widget.test.tsx location ==="
find . -name "Widget.test.tsx" -type f 2>/dev/null

# 4. Look for any jest.config file
echo -e "\n=== Jest config files ==="
find . -name "jest.config*" -type f 2>/dev/null | head -10

# 5. Check package.json for jest config
echo -e "\n=== Package.json with jest section ==="
find . -name "package.json" -type f | head -1 | xargs grep -A 15 '"jest"' 2>/dev/null || echo "No jest in package.json"

Repository: PayButton/paybutton

Length of output: 573


🏁 Script executed:

#!/bin/bash
# 1. Read Widget.test.tsx around line 10 to see the actual import
echo "=== Widget.test.tsx lines 1-30 ==="
head -30 "./react/lib/tests/components/Widget.test.tsx"

# 2. Check jest.config.js to see JSON handling config
echo -e "\n=== Jest config (react/jest.config.js) ==="
cat "./react/jest.config.js"

# 3. Look for WidgetContainer or Widget component definition
echo -e "\n=== WidgetContainer location ==="
find ./react -name "WidgetContainer*" -o -name "Widget.tsx" -o -name "Widget.jsx" | head -10

# 4. Check what config files actually exist in react directory
echo -e "\n=== All config files in react/lib ==="
find ./react/lib -name "*config*" -type f

Repository: PayButton/paybutton

Length of output: 2592


🏁 Script executed:

#!/bin/bash
# 1. Check example-config.json to see if it has apiBaseUrl
echo "=== example-config.json contents ==="
cat "./react/lib/example-config.json"

# 2. Read WidgetContainer.tsx to check how createPayment is called
echo -e "\n=== WidgetContainer.tsx first 100 lines ==="
head -100 "./react/lib/components/Widget/WidgetContainer.tsx"

# 3. Search for createPayment calls in WidgetContainer
echo -e "\n=== All createPayment calls in WidgetContainer ==="
grep -n "createPayment" "./react/lib/components/Widget/WidgetContainer.tsx"

# 4. Check git log for recent changes to paybutton-config files
echo -e "\n=== Git log for config files ==="
git log --oneline -20 -- "*paybutton-config*" "*example-config*" 2>/dev/null || echo "No git history"

Repository: PayButton/paybutton

Length of output: 3308


🏁 Script executed:

#!/bin/bash
# 1. Check git history for paybutton-config.json (was it deleted?)
echo "=== Git history showing paybutton-config.json ==="
git log --all --full-history -- "react/lib/paybutton-config.json" 2>/dev/null | head -30 || echo "No history"

# 2. Check if paybutton-config.json was ever committed
echo -e "\n=== Check git ls-files for paybutton-config.json ==="
git ls-files "react/lib/paybutton-config.json" 2>/dev/null || echo "Not in git index"

# 3. Look at the recent commit that mentioned undefined apiBaseUrl
echo -e "\n=== Git show for commit a354dfc ==="
git show a354dfc --stat 2>/dev/null | head -50

# 4. Check if there's a build script that generates paybutton-config.json
echo -e "\n=== Build/generate scripts in package.json ==="
cat "./react/package.json" | grep -A 20 '"scripts"'

# 5. Look at the actual test to see what it expects
echo -e "\n=== Widget.test.tsx around assertions (lines 60-70) ==="
sed -n '60,70p' "./react/lib/tests/components/Widget.test.tsx"

Repository: PayButton/paybutton

Length of output: 4474


The import on line 10 references a non-existent file that will cause tests to fail at load time.

The file react/lib/paybutton-config.json does not exist in the repository. This import will throw a MODULE_NOT_FOUND error when Jest tries to load the test file, preventing any tests from running.

The existing react/lib/example-config.json contains the required apiBaseUrl key. Either:

  1. Create react/lib/paybutton-config.json (likely by copying example-config.json), or
  2. Update the import on line 10 to reference ../../example-config.json instead

Note: WidgetContainer.tsx has the same broken import and will need the same fix.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@react/lib/tests/components/Widget.test.tsx` at line 10, The failing import in
Widget.test.tsx uses '../../paybutton-config.json' which doesn't exist; update
the import to use '../../example-config.json' (or add a new
paybutton-config.json copied from example-config.json) and apply the same fix in
WidgetContainer.tsx so both the test (Widget.test.tsx) and the component
(WidgetContainer.tsx) load the valid config (look for the import statements
referencing paybutton-config.json and replace them or add the missing file).


jest.mock('copy-to-clipboard', () => jest.fn())

Expand Down Expand Up @@ -62,7 +63,7 @@ describe('Widget – standalone paymentId (crypto)', () => {
)

await waitFor(() => {
expect(createPayment).toHaveBeenCalledWith(5, to, undefined)
expect(createPayment).toHaveBeenCalledWith(5, to, config.apiBaseUrl)
})
}
)
Expand Down Expand Up @@ -195,7 +196,7 @@ describe('Widget – standalone paymentId (crypto)', () => {
await waitFor(() => {
expect(createPayment).toHaveBeenCalledTimes(1)
})
expect(createPayment).toHaveBeenCalledWith(undefined, to, undefined)
expect(createPayment).toHaveBeenCalledWith(undefined, to, config.apiBaseUrl)
}
)
})
Expand All @@ -222,7 +223,7 @@ describe('Widget – standalone paymentId (fiat)', () => {
const expectedCrypto = amount / price

await waitFor(() => {
expect(createPayment).toHaveBeenCalledWith(expectedCrypto, to, undefined)
expect(createPayment).toHaveBeenCalledWith(expectedCrypto, to, config.apiBaseUrl)
})
}
)
Expand Down