Skip to content

fix: GuessTheNumber error handling; submission in react - #286

Merged
chadoh merged 1 commit into
mainfrom
fix/guess-the-number-bugs
Oct 23, 2026
Merged

chadoh merged 1 commit into
mainfrom
fix/guess-the-number-bugs

Conversation

@chadoh

@chadoh chadoh commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #285

  • Add e2e/tests/guess-the-number.spec.ts to verify that the page works as expected in both templates
    • Add e2e/util with fake Freighter and stub RPC
    • Run this spec in CI
  • React: added name="guess" to the input.
  • Both templates: failures from the catch block and from isErr() now go to a separate error state that shows “Couldn’t submit your guess: …” and leaves Submit enabled.
  • Shared helper: errorMessage() in app-lib/format.ts formats both Errors and the plain {code, message} objects that wallets reject with.
  • Beyond the issue: added required to the input in both templates. Without it, an empty submit still shows “Incorrect guess.”

@chadoh
chadoh requested a review from willemneal October 23, 2026 17:08
@socket-security

socket-security Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​stellar/​stellar-sdk@​16.4.199100100100100

View full report

willemneal
willemneal previously approved these changes Oct 23, 2026
@chadoh
chadoh marked this pull request as draft October 23, 2026 17:52
Fixes #285

- Add `e2e/tests/guess-the-number.spec.ts` to verify that the page works as expected in both templates
  - Add `e2e/util` with fake Freighter and stub RPC
  - Run this spec in CI
- React: added `name="guess"` to the input.
- Both templates: failures from the `catch` block and from `isErr()` now go to a separate error state that shows “Couldn’t submit your guess: …” and leaves Submit enabled.
- Shared helper: `errorMessage()` in `app-lib/format.ts` formats both `Errors` and the plain `{code, message}` objects that wallets reject with.
- Beyond the issue: added `required` to the input in both templates. Without it, an empty submit still shows “Incorrect guess.”
@chadoh
chadoh force-pushed the fix/guess-the-number-bugs branch from a5e3434 to a9e910b Compare October 23, 2026 18:22
@chadoh
chadoh marked this pull request as ready for review October 23, 2026 18:24
@chadoh
chadoh requested a review from willemneal October 23, 2026 18:25
@chadoh

chadoh commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

@willemneal moved a bunch of stuff to e2e/util and made it a little more feature-complete, so it actually weighs a little more now (happy path is now tested, so tests ensure that guessing a number actually works, not just that failing to guess a number shows a helpful message).

I think we'll be able to replace e2e/util/stub-rpc.ts with your simulator? So that'll cut down 200 lines here.

fake-freighter could maybe be extracted to its on lib later, but it seems fine/helpful to keep it here for now?

@chadoh
chadoh merged commit 8ad2013 into main Oct 23, 2026
3 checks passed
@chadoh
chadoh deleted the fix/guess-the-number-bugs branch October 23, 2026 20:09
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.

React template: Guess the Number never submits (input missing name), and errors show as "Incorrect guess"

2 participants