Skip to content

🧪 test: add error path test for orderBridge.read JSON parsing#66

Closed
dhaatrik wants to merge 1 commit into
mainfrom
testing-improvement-orderbridge-json-parsing-16743211526671032895
Closed

🧪 test: add error path test for orderBridge.read JSON parsing#66
dhaatrik wants to merge 1 commit into
mainfrom
testing-improvement-orderbridge-json-parsing-16743211526671032895

Conversation

@dhaatrik

Copy link
Copy Markdown
Owner

This PR addresses a testing gap in src/services/orderBridge.ts by adding a test case for the error path in localStorage JSON parsing.

🎯 What:

  • Created src/services/orderBridge.test.ts to test the orderBridge service.
  • Created src/services/setup-bun.ts to mock DOM globals (localStorage, window, CustomEvent, etc.) for bun test.

📊 Coverage:

  • Scenarios now tested include:
    • getActiveOrders: empty storage, valid JSON, and invalid JSON (the identified gap).
    • publishOrder: new order, updating existing order, and event dispatching.
    • updateOrderStatus: successful update and non-existent order.
    • removeOrder: removing by ID.
    • onOrderChange: handling storage and custom fd-order-change events, plus unsubscription.

Result:

  • Increased test coverage for core service logic.
  • Robust verification of error handling in orderBridge.read.
  • Established a pattern for running tests with bun test when standard Vitest environments are unavailable.

PR created automatically by Jules for task 16743211526671032895 started by @DhaatuTheGamer

- Added comprehensive tests for `orderBridge.ts` service.
- Implemented specific test case to verify that `read()` returns an empty array when `localStorage` contains invalid JSON.
- Added `setup-bun.ts` to polyfill DOM globals for `bun test` compatibility in constrained environments.
- Verified all tests pass with `bun test`.

Co-authored-by: DhaatuTheGamer <90041791+DhaatuTheGamer@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@dhaatrik dhaatrik closed this Mar 31, 2026
@dhaatrik dhaatrik deleted the testing-improvement-orderbridge-json-parsing-16743211526671032895 branch March 31, 2026 06:13
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