Skip to content

Add TradeBox component tests with prod-like mock infrastructure FEDEV-4024#2618

Open
qwinndev wants to merge 2 commits into
releasefrom
tradebox-component-tests
Open

Add TradeBox component tests with prod-like mock infrastructure FEDEV-4024#2618
qwinndev wants to merge 2 commits into
releasefrom
tradebox-component-tests

Conversation

@qwinndev

@qwinndev qwinndev commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What

Linear: FEDEV-4024

54 Playwright component tests for the trade widget (TradeBoxHeaderTabs + TradeBox), running against the production provider stack with mocked chain data.

Mock infrastructure

  • MockSyntheticsStateProvider — assembles SyntheticsState from the real stateful hooks (useTradeboxState, settings, order/position editor states, permits, subaccount) over static fixtures, so every derived selector (increaseAmounts, fees, leverage, swap path) computes through the production pipeline.
  • Fixtures: ETH/USD market (+ second ETH-ETH pool, capped-OI variant), USDC/ETH/native tokens, 2x long position, gas limits/price, positions constants.
  • wagmi mock connector (connected story prop) unlocks submit-button validation states.
  • SyntheticsEvents replaced with an idle no-events stub via vite alias in playwright-ct.config.ts (websocket layer; documented limitation: txn/approval event flows are not observable in CT).
  • Hermetic network: all non-localhost http(s) aborted per test; localStorage seeding for stored options/leverage/denomination scenarios.

Covered

  • Field interactions in slider mode (margin ↔ size, percentage slider, token/USD display modes) and manual leverage mode (independent inputs, fixed-percentage slider, max-leverage validation)
  • Limit/Stop flows: trigger price participation in sizing, mark-price fallback, price resets, direction validations
  • Swap mode (real swap path, switch ball, min receive, ratio input) and wrap 1:1; TWAP rows and parts bounds
  • Submit validations (enter amount/price, balances, min margin/position size, OI cap), TP/SL entries, pool switch + pool/collateral warnings, high swap impact card
  • Seeded scenarios: native ETH gas buffer on max, leverage clamp to market cap (95x), persisted size denomination, Trigger-mode fallback invariant

55 Playwright CT tests covering the trade widget (TradeBoxHeaderTabs + TradeBox):
field interactions in slider and manual leverage modes, limit/stop price flows,
swap and TWAP modes, submit validations, pool switching, TP/SL, warnings and
localStorage-seeded scenarios.

Infra: MockSyntheticsStateProvider assembles SyntheticsState from real hooks
(useTradeboxState, settings, order/position editor states) over static chain
fixtures; wagmi mock connector; position/market/gas fixtures; SyntheticsEvents
replaced with an idle stub via vite alias; network blocked per test.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 6, 2026

Copy link
Copy Markdown

Deploying gmx-interface-home with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8b1d14a
Status: ✅  Deploy successful!
Preview URL: https://cd7ec9a2.gmx-interface-home.pages.dev
Branch Preview URL: https://tradebox-component-tests.gmx-interface-home.pages.dev

View logs

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 6, 2026

Copy link
Copy Markdown

Deploying gmx-interface with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8b1d14a
Status: ✅  Deploy successful!
Preview URL: https://d7d01323.gmx-interface.pages.dev
Branch Preview URL: https://tradebox-component-tests.gmx-interface.pages.dev

View logs

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Playwright Component Test Report

All tests passed.

View Report

Commit 8b1d14a

@qwinndev qwinndev marked this pull request as ready for review July 6, 2026 13:34
@qwinndev qwinndev changed the title Add TradeBox component tests with prod-like mock infrastructure Add TradeBox component tests with prod-like mock infrastructure FEDEV-4024 Jul 6, 2026
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