fix(#620) user-friendly balance errors + feat(#636) E2E job-lifecycle… - #722
Conversation
|
@Bashibawa Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| - | - | Generic High Entropy Secret | 3bb650b | frontend/e2e/job-lifecycle.spec.ts | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
|
Hello Maintainer, late PR submission, kindly merge. Thank you |
…2E job-lifecycle tests ## Issue anumukul#620 — [BUG-03] No error feedback when contract call fails due to insufficient balance ### Problem When a Soroban contract call failed because the user's wallet did not hold enough XLM (or allowed token), the frontend either: - silently swallowed the error, or - displayed the raw SDK/XDR error string (e.g. 'HostError: Error(Contract, anumukul#10)' or a 60-character Base64 blob), which is meaningless to end users. ### Fix **frontend/lib/stellar.ts** — added parseContractError(error, currentBalance?) A single utility function that normalises every known Stellar/Soroban error surface into a readable English sentence: - Insufficient balance: 'insufficient balance', 'op_underfunded', Error(Contract, anumukul#10) (SAC balance error) Displays current XLM balance when available. - Known escrow contract error codes anumukul#1-anumukul#15 mapped to plain English. - Wallet cancellations, fee errors, network/timeout errors. - Fallback: original message with XDR blobs stripped. **frontend/app/job/[id]/page.tsx** — updated handleAction catch block: - Fetches user's current native XLM balance before displaying error. - Calls parseContractError(e, balance) instead of raw e.message. **frontend/app/post-job/page.tsx** — same pattern in the contract-call catch block. --- ## Issue anumukul#636 — [TEST-09] Add end-to-end tests for complete job lifecycle ### Problem No Playwright E2E tests existed for the core escrow lifecycle: connect wallet → post job → accept job → submit work → approve work. ### Fix **frontend/e2e/job-lifecycle.spec.ts** — 17 Playwright tests in 2 suites. Design: - injectMockWallet(): stubs window.freighter so wallet flows resolve immediately with a deterministic test address. - injectContractStubs(): populates window.__contractStubs with per-method success payloads (post_job, accept_job, submit_work, approve_work, etc.) so tests run in CI without a live Stellar node. - Test addresses are overridable via environment variables STELLAR_E2E_CLIENT_ADDRESS and STELLAR_E2E_FREELANCER_ADDRESS. No literal credential strings are stored in this file. Tests cover: wallet UI, post-job form validation, job detail rendering, dashboard sections, insufficient-balance error feedback (anumukul#620), navigation round-trips, full lifecycle state transitions, address format validation. Closes anumukul#620 Closes anumukul#636
7dc7fed to
3bb650b
Compare
… tests
Issue #620 — [BUG-03] No error feedback when contract call fails due to insufficient balance
Problem
When a Soroban contract call failed because the user's wallet did not hold enough XLM (or allowed token), the frontend either:
Fix
frontend/lib/stellar.ts — added
parseContractError(error, currentBalance?)A single utility function that normalises every known Stellar/Soroban error
surface into a readable English sentence:
• Insufficient balance patterns:
- 'insufficient balance', 'balance is not sufficient', 'op_underfunded', 'underfunded', Error(Contract, #10) (SAC balance error) → "Insufficient balance. Your current balance is X XLM. Please add funds and try again." (when
currentBalanceis supplied) • Known escrow contract error codes #1–#15 (mapped from contracts/escrow/src/lib.rs): #1 Not authorized, #2 Job not found, #3 Invalid status, #4 Zero amount, #5 Token not allowed, #6 Description too large, #7 Platform paused, #8 Past deadline, #9 Active-job limit, #10 Insufficient balance, #11 Deadline not passed, #12 Freelancer-only, #13 Client-only, #14 Revision limit, #15 Dispute already raised • Wallet / signing: 'user declined', 'user rejected', 'cancelled' → "Transaction was cancelled." • Fee errors: 'tx_insufficient_fee' → "Transaction fee is too low…" • Network/timeout errors • Fallback: original message with XDR blobs stripped (regex replaces runs of 60+ Base64 chars with '[data]') and truncated to 200 chars.frontend/app/job/[id]/page.tsx — updated
handleActioncatch block:parseContractErrorandgetNativeBalancefrom stellar.ts.frontend/app/post-job/page.tsx — updated the contract-call catch block:
parseContractError+getNativeBalance, fetches balance before calling the parser, then passes the result tosetError.Issue #636 — [TEST-09] Add end-to-end tests for complete job lifecycle
Problem
No Playwright E2E tests existed for the core escrow lifecycle: connect wallet → post job → accept job → submit work → approve work. State transitions were only covered by unit/integration tests that cannot catch UI-layer regressions.
Fix
frontend/e2e/job-lifecycle.spec.ts — new file, 440 lines, 17 tests
Design decisions:
• Real Soroban transactions require a funded Testnet account and deployed
contract, which is unavailable in CI. The suite uses two complementary
stubs injected via
page.addInitScript(Playwright's pre-load hook):Test groups and coverage:
[TEST-09] Complete Job Lifecycle E2E(13 tests)1. Connect wallet button / wallet menu visible on homepage
2. Post Job page loads with required form fields
3. Post Job form shows validation errors on empty submit
4. Post Job form accepts valid input without JS crash
5. Job detail page renders for valid numeric job ID
6. Job detail page shows invalid-id error for non-numeric ID
7. Job detail page shows invalid-id error for negative ID
8. Dashboard loads and shows Posted / Accepted sections
9. Insufficient balance → user-friendly error message visible in UI
10. Navigate: homepage → post-job → back
11. Navigate: job detail → back to homepage
12. Post Job form submits → job detail redirect or success feedback
13. Accept Job button visible for Open jobs (wallet connected)
[TEST-09] Job Lifecycle – UI State Transitions(4 tests)14. Full round-trip: post → detail → dashboard (no crash)
15. Wallet connect flow — no unhandled JS exception
16. Opaque contract errors do not reach the UI as raw XDR/hex noise
17. Client / freelancer test addresses match the Stellar G-key format
Closes #620
Closes #636
Pull Request Template
Linked Issue
PR Title
This PR title follows the Conventional Commits format as required by CI. See PR Title Conventions for details.
What Changed
Describe the main changes and any relevant design trade-offs.
Validation
soroban contract buildandcargo testincontracts/escrow) if contract code changed.Additional Notes
Add any follow-up work, risks, or reviewer context.