Skip to content

test(e2e): spec cross-chain swaps - #8039

Open
shoom3301 wants to merge 9 commits into
e2e-tests/p3from
e2e-tests/p4
Open

test(e2e): spec cross-chain swaps#8039
shoom3301 wants to merge 9 commits into
e2e-tests/p3from
e2e-tests/p4

Conversation

@shoom3301

@shoom3301 shoom3301 commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • Adds bridge-provider mocks: Bungee (destination-token list, intermediate-token list, quote fixtures) and NEAR Intents (attestation, destination-token list, quote fixtures), a fixture-loading helper, and a socket verifier (+ test) that validates mocked WebSocket bridge-status updates.
  • Adds nestedRpcCallRegistry.test.ts, covering the RPC-call tracking shared across bridge specs.
  • Adds cross-chain-swaps.spec.ts — 8 @smoke Playwright tests covering: the cross-chain UI's entry point from the Swap form, a NEAR-provider swap, a Bungee-provider swap, an ETH-flow (native ETH) source sent cross-chain, a swap to Solana (SOL/SPL destination), a swap to Bitcoin (BTC destination), and two calculation-parity checks (swap form "Receive" vs. bridge widget "Expected to receive", and bridge "Min. to deposit" vs. swap "Min. to receive").

Why

  • Extends the e2e suite to the bridging/cross-chain flow — the highest-complexity trade path (multiple bridge providers, non-EVM destinations, extra calculation surfaces) — using the mock-wallet/API infrastructure from PR #8035 and the NEAR Intents signature bypass and locator hooks from PR #8036.

QA Testing

Reviewer note:

  • Test-only change (new spec + mock/fixture files, no production code); the smoke CI check is the verification for this PR.

Developer verification:

  • pnpm e2e:smoke (or pnpm --filter @cowprotocol/cowswap-e2e-pw exec playwright test cross-chain-swaps.spec.ts) runs the new spec locally.

Preview URLs

Surface URL
swap-dev - branch preview URL https://swap-dev-git-e2e-tests-p4-cowswap-dev.vercel.app
explorer-dev - branch preview URL https://explorer-dev-git-e2e-tests-p4-cowswap-dev.vercel.app
widget-configurator - branch preview URL https://widget-configurator-git-e2e-tests-p4-cowswap-dev.vercel.app
storybook - branch preview URL https://storybook-git-e2e-tests-p4-cowswap-dev.vercel.app

@vercel

vercel Bot commented Aug 25, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cowfi Ready Ready Preview Aug 28, 2026 12:03pm
explorer-dev Ready Ready Preview Aug 28, 2026 12:03pm
storybook Ready Ready Preview Aug 28, 2026 12:03pm
swap-dev Ready Ready Preview Aug 28, 2026 12:03pm
widget-configurator Ready Ready Preview Aug 28, 2026 12:03pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
cosmos Ignored Ignored Aug 28, 2026 12:03pm
sdk-tools Ignored Ignored Preview Aug 28, 2026 12:03pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dd6414c0-3011-4c36-b6fa-a8ac262ce6f2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@shoom3301 shoom3301 changed the title E2e tests/p4 test(e2e): spec cross-chain swaps Aug 25, 2026
@shoom3301 shoom3301 self-assigned this Aug 25, 2026
@shoom3301
shoom3301 requested review from a team August 25, 2026 11:02
@shoom3301
shoom3301 marked this pull request as ready for review August 25, 2026 11:03
Comment thread apps/cowswap-e2e-tests/src/tests/cross-chain-swaps.spec.ts
@Danziger

Copy link
Copy Markdown
Contributor
⚠️ AI Review (Cursor Grok 4.6, worked 8m): [BLOCKING] CS-310/CS-311 can stay on Bungee after setFlag

Finding: [BLOCKING] Provider switches still need page.reload() — CS-310/CS-311 do not do that

  • Location: apps/cowswap-e2e-tests/src/tests/cross-chain-swaps.spec.ts:105 (comment), 147, and the CS-310/CS-311 loops at 554 / 601
  • This one is important: the comment describes a live featureFlagsUpdate path that is not implemented, and the parity tests can pass without ever leaving Bungee.

Verified against current code:

  • installLaunchDarkly.setFlag only calls context.addInitScript. That runs on the next document load, not on the already-open page.
  • useFeatureFlags (libs/common-hooks/src/useFeatureFlags.ts) reads window.__COWSWAP_E2E_FEATURE_FLAGS__ inside useMemo(..., [flags]). There is no featureFlagsUpdate listener, so even a live window write would not update BridgeProvidersUpdater.
  • wallet.openApp / openCrossChainSwap use page.goto('/#/...'). After the first load that is a hash-only navigation, so the new init script does not run.
  • Receipt: e2e AGENTS.md already says a mid-test setFlag needs page.reload() after the new hash is in the address bar.

CS-285 reloads before the Near half, so that test does switch. CS-310/CS-311 call configureProviders again and only assert amounts, not bridgeStopTitle('Near Intents'), so a stuck Bungee quote still satisfies them.

Suggested fix

  • Drop the featureFlagsUpdate claim. Match the AGENTS.md reload rule.
  • After each configureProviders in CS-310/CS-311 (and anywhere else that switches providers on an already-loaded page), await swapPage.page.reload() — same pattern as CS-285.
  • Assert the active provider in those loops, e.g. bridgeStopTitle('Bungee'|'Near Intents'), so a missed reload fails the test instead of silently testing Bungee twice.
Review scope and related context

This is a reply on the existing reload/setFlag thread, not a second top-level comment.

Not repeated here:

  • configureProviders takes unused rpcProxy and its comment still says it stubs Bungee's on-chain check; installSocketVerifier already does that globally.
  • CS-287 flaked once in smoke (expectOrderToBePosted 10s timeout) then passed on retry; CS-68 also flaked in that run, so this looks like suite load rather than a separate provider-switch bug.
🤖 Prompt for AI agents
Verify this finding against current code. Fix only if still valid, keep the change minimal, and validate with the targeted tests.

Context:
- apps/cowswap-e2e-tests/src/tests/cross-chain-swaps.spec.ts (openCrossChainSwap comment ~105, CS-285 reload ~148, CS-310 ~554, CS-311 ~601)
- apps/cowswap-e2e-tests/src/mocks/launchDarkly.ts setFlag is addInitScript-only
- libs/common-hooks/src/useFeatureFlags.ts memos on LaunchDarkly flags only; no featureFlagsUpdate event
- Failure mode: mid-test setFlag + hash goto does not change bridgingSdk providers; CS-310/CS-311 can pass while still on Bungee
- Expected fix: reload after configureProviders when the page is already loaded; assert bridgeStopTitle per provider in the loops; align the comment with AGENTS.md
- Validate: pnpm --filter @cowprotocol/cowswap-e2e-pw exec playwright test cross-chain-swaps.spec.ts -g "CS-310|CS-311|CS-285"

Generated using the pr-review skill from the CoW Protocol skills repo.

shoom3301 added a commit that referenced this pull request Aug 27, 2026
## What changed
- Adds a new `apps/cowswap-e2e-tests` Playwright + Synpress suite:
project config, a mock-wallet fixture (viem-backed, instant signing, no
MetaMask extension), a per-worker RPC proxy, and page objects for the
Swap/Limit/TWAP/Account/Trade flows.
- Mocks for `api.cow.fi`/`barn.api.cow.fi` (orders, quotes, trades,
appData, etc., recorded from the live barn API), balances/allowances,
node RPC calls, LaunchDarkly flags, and the Safe SDK.
- Two new CI workflows: `e2e-pw-smoke` (runs `@smoke`-tagged tests on
PRs touching frontend/e2e/libs code) and `e2e-pw-nightly` (full suite,
4-way sharded, cron + manual dispatch) — replacing the previously
disabled Cypress job in `ci.yml`. `.mergify.yml`'s merge gate switches
from `check-success=Cypress` to `check-success=smoke`.
- Drops the old `cowswap-frontend-e2e` (Cypress) app from `enabledApps`
and its now-unused deps/patches.
- `AGENTS.md`/`README.md` docs for the new suite (architecture, mocking
mechanics, known flakiness and how it was diagnosed).
- No `cowswap-frontend` production code changes.

## Why
- Replaces the disabled Cypress e2e setup with a faster, mock-first
Playwright suite that doesn't need a live testnet/relayer for most
scenarios, and wires it into CI as a PR-gating smoke check plus a
nightly full run.

## QA Testing
Reviewer note:
- Pure test-infrastructure change with no production code diff — nothing
to browser-test here. The suite's actual test coverage is added in the
stacked [PR #8038](#8038)
(market orders) and [PR
#8039](#8039) (cross-chain).

Developer verification:
- `smoke` CI check passed on this PR (no specs exist yet at this point
in the stack, so it currently confirms the pipeline wiring itself).

## Preview URLs

| Surface | URL |
| --- | --- |
| swap-dev - branch preview URL |
https://swap-dev-git-e2e-tests-p1-cowswap-dev.vercel.app |
| explorer-dev - branch preview URL |
https://explorer-dev-git-e2e-tests-p1-cowswap-dev.vercel.app |
| widget-configurator - branch preview URL |
https://widget-configurator-git-e2e-tests-p1-cowswap-dev.vercel.app |
| storybook - branch preview URL |
https://storybook-git-e2e-tests-p1-cowswap-dev.vercel.app |
| cowfi - branch preview URL |
https://cowfi-git-e2e-tests-p1-cowswap.vercel.app |

---------

Co-authored-by: cowswap-release-sync[bot] <274575433+cowswap-release-sync[bot]@users.noreply.github.com>
Co-authored-by: Elena <70885163+elena-zh@users.noreply.github.com>
Co-authored-by: elena-zh <elena@cow.fi>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
@shoom3301

Copy link
Copy Markdown
Collaborator Author

Confirmed, this was a real bug — fixed:

  • [CS-310]/[CS-311]'s loops now reload after configureProviders (skipped on the first iteration, since nothing has navigated yet), same pattern [CS-285] already uses.
  • Both loops now assert bridgeStopTitle(...) for the intended provider each iteration, so a missed reload fails the test instead of silently re-testing Bungee twice.
  • Dropped the false featureFlagsUpdate claim from openCrossChainSwap's doc comment and replaced it with the actual mechanism (why a hash-only nav can't pick up new flags) plus a pointer to AGENTS.md's reload rule.
  • Left the unused rpcProxy param on configureProviders alone, per your own note that it's already known and not part of this finding.

Verified with playwright test cross-chain-swaps.spec.ts — all 8 tests pass, including [CS-310]/[CS-311] now genuinely exercising Near Intents on their second iteration (the new bridgeStopTitle assertion would have caught it otherwise).

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants