Skip to content

Fix checkout-to-receipt transition crashes and lost links#77

Merged
kilbot merged 2 commits intomainfrom
fix/checkout-receipt-navigation
Feb 6, 2026
Merged

Fix checkout-to-receipt transition crashes and lost links#77
kilbot merged 2 commits intomainfrom
fix/checkout-receipt-navigation

Conversation

@kilbot
Copy link
Copy Markdown
Contributor

@kilbot kilbot commented Feb 6, 2026

Summary

  • Guard new URL() in PaymentWebview useMemo against undefined paymentURL — after incrementalPatch updates the order, the payment link can become undefined causing new URL(undefined) to throw mid-render
  • Preserve existing order links (receipt, payment) when the payment response doesn't include them — parseRestResponse defaults missing array properties to [], which incrementalPatch then overwrites, wiping out the receipt URL
  • Remove leading / from receipt navigation pathname so expo-router resolves it as a route name (matching the Stack.Screen) instead of an absolute URL path

Test plan

  • Process a payment through checkout
  • Verify no TypeError: Failed to construct 'URL' in console
  • Verify receipt modal opens with the receipt loaded
  • Verify closing receipt returns to POS cart
  • Verify checkout with autoShowReceipt disabled navigates back to cart

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Prevented potential runtime errors in payment processing when critical payment data is unavailable, ensuring a more stable experience
    • Enhanced preservation of receipt and payment links throughout the payment workflow, preventing loss of transaction references
    • Improved navigation behavior when automatically displaying the receipt modal after payment completion

- Guard `new URL()` in PaymentWebview useMemo against undefined paymentURL,
  which threw after incrementalPatch changed the order data mid-render
- Preserve existing order links (receipt, payment) when the payment response
  doesn't include them, preventing parseRestResponse from wiping them with
  empty defaults
- Remove leading `/` from receipt navigation pathname so expo-router resolves
  it as a route name instead of an absolute URL path
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 6, 2026

📝 Walkthrough

Walkthrough

Payment webview component enhanced with defensive checks for missing payment URLs and logic to preserve existing payment/receipt links during payload parsing. Receipt modal navigation path adjusted to remove leading slash. Receipt component formatting adjusted with whitespace addition.

Changes

Cohort / File(s) Summary
Payment Flow Safeguards
packages/core/src/screens/main/pos/checkout/components/payment-webview.tsx
Added null safety check returning empty string for falsy paymentURL; implemented link preservation by merging existing order links into parsed payment data; adjusted receipt modal route pathname by removing leading slash for autoShowReceipt flow.
Formatting
packages/core/src/screens/main/receipt/receipt.tsx
Added blank line after receiptURL assignment for improved code readability.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A hop and a skip through payment's delight,
Links now preserved, routing set right,
Empty strings guard where URLs might fail,
Receipt paths trimmed—a cleaner trail!
Formatting polished, the code looks so neat,
Another bug fixed, our work is complete! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix checkout-to-receipt transition crashes and lost links' accurately summarizes the main changes: preventing crashes during checkout-to-receipt navigation and preserving lost payment/receipt links.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/checkout-receipt-navigation

Warning

Tools execution failed with the following error:

Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error)


Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2026

🚀 Deployment Summary

Item Status
Preview URL https://wcpos--wnd9ssmve2.expo.app
E2E Tests ❌ Failed
Commit 15a3ad0

🔗 Quick Links

❌ Failed Tests (4 total)

settings.spec.ts

  • [free-authenticated] should change language to French and load translations from CDN

    Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed

  • [free-authenticated] should persist language after closing and reopening settings

    Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed

  • [pro-authenticated] should change language to French and load translations from CDN

    Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed
    ...and 1 more in this file

📋 Full error details (first 5)

settings.spec.ts - should change language to French and load translations from CDN

Project: free-authenticated

Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed

Locator: getByText('Produit')
Expected: visible
Timeout: 15000ms
Error: element(s) not found

Call log:
�[2m  - Expect "toBeVisible" with timeout 15000ms�[22m
�[2m  - waiting for getByText('Produit')�[22m

settings.spec.ts - should persist language after closing and reopening settings

Project: free-authenticated

Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed

Locator: getByText('Produit')
Expected: visible
Timeout: 15000ms
Error: element(s) not found

Call log:
�[2m  - Expect "toBeVisible" with timeout 15000ms�[22m
�[2m  - waiting for getByText('Produit')�[22m

settings.spec.ts - should change language to French and load translations from CDN

Project: pro-authenticated

Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed

Locator: getByText('Produit')
Expected: visible
Timeout: 15000ms
Error: element(s) not found

Call log:
�[2m  - Expect "toBeVisible" with timeout 15000ms�[22m
�[2m  - waiting for getByText('Produit')�[22m

settings.spec.ts - should persist language after closing and reopening settings

Project: pro-authenticated

Error: �[2mexpect(�[22m�[31mlocator�[39m�[2m).�[22mtoBeVisible�[2m(�[22m�[2m)�[22m failed

Locator: getByText('Produit')
Expected: visible
Timeout: 15000ms
Error: element(s) not found

Call log:
�[2m  - Expect "toBeVisible" with timeout 15000ms�[22m
�[2m  - waiting for getByText('Produit')�[22m

📸 Failure Screenshots

📷 settings Language Settings 2a494 sing and reopening settings free authenticated

settings Language Settings 2a494 sing and reopening settings free authenticated

📷 settings Language Settings 2a494 sing and reopening settings free authenticated

settings Language Settings 2a494 sing and reopening settings free authenticated

📷 settings Language Settings 53f0f load translations from CDN free authenticated

settings Language Settings 53f0f  load translations from CDN free authenticated

📷 settings Language Settings 53f0f load translations from CDN free authenticated

settings Language Settings 53f0f  load translations from CDN free authenticated

📷 settings Language Settings 53f0f load translations from CDN pro authenticated

settings Language Settings 53f0f  load translations from CDN pro authenticated

📷 settings Language Settings 53f0f load translations from CDN pro authenticated

settings Language Settings 53f0f  load translations from CDN pro authenticated

🔗 Debug Links


🤖 Updated by GitHub Actions

@kilbot kilbot merged commit 6902148 into main Feb 6, 2026
3 checks passed
@kilbot kilbot deleted the fix/checkout-receipt-navigation branch February 6, 2026 17:19
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2026

📊 Test Coverage Report

Package Statements Branches Functions Lines
@wcpos/core 🔴 37.5% 🔴 44.0% 🔴 43.2% 🔴 36.2%
@wcpos/components 🔴 44.9% 🟡 60.9% 🔴 24.2% 🔴 47.3%
@wcpos/database 🔴 33.2% 🔴 35.9% 🔴 40.3% 🔴 32.9%
@wcpos/hooks 🔴 45.5% 🔴 46.8% 🔴 44.8% 🔴 45.7%
@wcpos/utils 🔴 35.0% 🔴 0.0% 🔴 50.0% 🔴 33.3%
@wcpos/query 🟡 68.0% 🔴 52.6% 🟡 66.1% 🟡 68.0%
Average 🔴 44.0% 🔴 40.0% 🔴 44.7% 🔴 43.9%
Coverage Legend
  • 🟢 Good (≥80%)
  • 🟡 Moderate (60-79%)
  • 🔴 Needs improvement (<60%)
  • ⚪ No coverage data
--- 🤖 Updated by GitHub Actions • [View full report](https://github.com/wcpos/monorepo/actions/runs/21759435704)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant