Skip to content

Conversation

@kernelwhisperer
Copy link
Contributor

@kernelwhisperer kernelwhisperer commented Jan 5, 2026

Summary

Fixes e2e test flakiness.
Builts on top of #6751

To Test

⚠️ To run the tests. Make sure you add the required environment variables to
your root .env.local file with:

  • CYPRESS_INTEGRATION_TEST_PRIVATE_KEY=<your-private-key>: Private key
  • CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY=<your-alchemy-key>: Alchemy key

To launch it with our development server (so you have live-reloading):

# Terminal 1
yarn start
# Terminal 2
yarn e2e

If we want to use the Cypress UI, with the production build:

# Terminal 1
npx nx run cowswap-frontend:serve-static --port 3000
# Terminal 2
yarn e2e:open

Summary by CodeRabbit

  • Tests

    • Improved E2E reliability: increased timeouts, added small/large timeout constants, refined mocks/waits, streamlined token selection, and stabilized signer/address handling.
    • Suppressed a noisy ResizeObserver uncaught exception.
  • Chores

    • Updated E2E configuration, test support utilities, and CI test environment provisioning to pass the new integration-test key.
  • Documentation

    • Updated README and env examples with new integration-test key guidance and placeholders; removed deprecated keys from runtime env.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 5, 2026

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

Project Deployment Review Updated (UTC)
cowfi Ready Ready Preview Jan 7, 2026 11:22am
explorer-dev Ready Ready Preview Jan 7, 2026 11:22am
swap-dev Ready Ready Preview Jan 7, 2026 11:22am
widget-configurator Ready Ready Preview Jan 7, 2026 11:22am
2 Skipped Deployments
Project Deployment Review Updated (UTC)
cosmos Ignored Ignored Jan 7, 2026 11:22am
sdk-tools Ignored Ignored Preview Jan 7, 2026 11:22am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

Walkthrough

Updated Cypress E2E test infrastructure: added/removed env keys and README entries, increased global timeouts and introduced SMALL_TIMEOUT/LARGE_TIMEOUT constants, refactored token-selection helpers to a search flow, standardized timeouts in tests, cached signer addresses, added ResizeObserver suppression, and extended provider URL fallback to include Infura.

Changes

Cohort / File(s) Summary
Environment & CI
\.env\.local\.example, \.env, .github/workflows/ci.yml, README.md
Added Infura-related E2E placeholders to the example, removed some keys from .env, CI now passes CYPRESS_INTEGRATION_TESTS_INFURA_KEY, and README updated to prefer Infura/Alchemy key selection.
Cypress config & timeout constants
apps/cowswap-frontend-e2e/cypress.config.ts, apps/cowswap-frontend-e2e/src/config.ts
Increased Cypress timeouts (defaultCommandTimeout → 25000, pageLoadTimeout → 25000) and added SMALL_TIMEOUT (10_000) and LARGE_TIMEOUT (20_000) exports.
E2E tests (timeouts, signer caching, assertions, flows)
apps/cowswap-frontend-e2e/src/e2e/*.test.ts
(fiat-amounts.test.ts, limit-orders.test.ts, lists.test.ts, search.test.ts, swap.test.ts, swapMod.test.ts)
Replaced hard-coded timeouts with SMALL_TIMEOUT/LARGE_TIMEOUT; updated assertions to .should() style; cache signer address in onBeforeLoad and use it in native-balance mocks; adjusted swap banner/wrap-to-WETH interaction.
Support helpers & hooks
apps/cowswap-frontend-e2e/src/support/commands.ts, apps/cowswap-frontend-e2e/src/support/e2e.ts, apps/cowswap-frontend-e2e/src/support/ethereum.ts
Refactored token selection to a search-and-select flow with explicit visibility/timeouts; added uncaught exception handler to suppress ResizeObserver loop warnings; extended provider URL selection to consider INTEGRATION_TESTS_INFURA_KEY as a fallback after Alchemy.

Sequence Diagram(s)

(omitted — changes are test infra, helpers, and configuration without new multi-component runtime control flow)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • chore: restore e2e tests #6751 — Overlaps on E2E infra and support helpers (cypress config, support/e2e, support/commands) and provider-selection/test setup logic.

Suggested reviewers

  • alfetopito
  • limitofzero

Poem

🐇 I hopped through envs and test-timeouts wide,

I searched for tokens, then clicked with pride.
I cached the signer so flows run smooth,
Quieted ResizeObserver’s gruff hoof.
🥕 E2E carrots—ready for the ride.

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive The description includes Summary and To Test sections as per template, but lacks a Background section and is missing updated environment variable documentation reflecting the Infura key addition mentioned in the file changes. Add a Background section explaining the timeout and configuration changes. Update the To Test section to document both CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY and CYPRESS_INTEGRATION_TESTS_INFURA_KEY environment variables.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: restore e2e tests' accurately describes the main objective of the PR, which is to fix e2e test flakiness through configuration and timeout adjustments.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5912691 and 9f845a6.

📒 Files selected for processing (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Setup
  • GitHub Check: Cypress

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 and usage tips.

@kernelwhisperer kernelwhisperer force-pushed the chore/restore-e2e-tests-2 branch from ea1536b to ee493a7 Compare January 7, 2026 10:07
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
.env.local.example (1)

5-15: Optional: Address static analysis hints.

The static analysis tool flagged:

  1. Extra blank line at line 7
  2. Keys not in alphabetical order (CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY should precede CYPRESS_INTEGRATION_TEST_PRIVATE_KEY)

These are minor formatting preferences. While the current order is logical (private key before API key), alphabetical ordering can improve consistency if that's the project standard.

♻️ Optional fix
 REACT_APP_TG_DEV_BYPASS=true
-

 
 #######################################
 # End To End Test
 #######################################
 # ⚠️ Required for E2E tests to run
 
 # Cypress Integration Tests
+CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY=
 CYPRESS_INTEGRATION_TEST_PRIVATE_KEY=
-CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY=
apps/cowswap-frontend-e2e/src/support/commands.ts (1)

108-116: Good refactor: search-based token selection improves robustness.

The new search-and-select approach is more resilient than clicking from a static list, as it better mimics user interaction and handles dynamic token lists.

Optional considerations:

  1. The { force: true } on line 113 bypasses Cypress actionability checks. While it may be necessary for flaky tests, consider whether the underlying cause (e.g., element not fully interactive) could be addressed instead.

  2. The hard-coded 20_000 timeout appears multiple times. Consider extracting it to a shared constant (e.g., LARGE_TIMEOUT from config) for consistency with other test files.

♻️ Optional: Extract timeout constant

At the top of the file, import the timeout:

+import { LARGE_TIMEOUT } from '../config'

Then replace hard-coded values:

-  cy.get(buttonSelector, { timeout: 20_000 }).should('not.be.disabled')
+  cy.get(buttonSelector, { timeout: LARGE_TIMEOUT }).should('not.be.disabled')
   cy.get(buttonSelector).click()
-  cy.get(searchSelector, { timeout: 20_000 }).should('be.visible').clear().type(tokenAddress)
-  cy.get(tokenSelector, { timeout: 20_000 }).should('be.visible').click({ force: true })
+  cy.get(searchSelector, { timeout: LARGE_TIMEOUT }).should('be.visible').clear().type(tokenAddress)
+  cy.get(tokenSelector, { timeout: LARGE_TIMEOUT }).should('be.visible').click({ force: true })
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea1536b and ee493a7.

📒 Files selected for processing (12)
  • .env
  • .env.local.example
  • apps/cowswap-frontend-e2e/cypress.config.ts
  • apps/cowswap-frontend-e2e/src/config.ts
  • apps/cowswap-frontend-e2e/src/e2e/fiat-amounts.test.ts
  • apps/cowswap-frontend-e2e/src/e2e/limit-orders.test.ts
  • apps/cowswap-frontend-e2e/src/e2e/lists.test.ts
  • apps/cowswap-frontend-e2e/src/e2e/search.test.ts
  • apps/cowswap-frontend-e2e/src/e2e/swap.test.ts
  • apps/cowswap-frontend-e2e/src/e2e/swapMod.test.ts
  • apps/cowswap-frontend-e2e/src/support/commands.ts
  • apps/cowswap-frontend-e2e/src/support/e2e.ts
💤 Files with no reviewable changes (1)
  • .env
🚧 Files skipped from review as they are similar to previous changes (6)
  • apps/cowswap-frontend-e2e/src/e2e/swapMod.test.ts
  • apps/cowswap-frontend-e2e/src/e2e/lists.test.ts
  • apps/cowswap-frontend-e2e/src/e2e/search.test.ts
  • apps/cowswap-frontend-e2e/src/config.ts
  • apps/cowswap-frontend-e2e/src/e2e/swap.test.ts
  • apps/cowswap-frontend-e2e/cypress.config.ts
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6034
File: apps/cowswap-frontend-e2e/src/e2e/fiat-amounts.test.ts:44-47
Timestamp: 2025-07-28T16:26:08.051Z
Learning: In the cowswap codebase, using trivial placeholder tests like `it('should be true', () => { expect(true).to.be.true })` in e2e test files is an intentional pattern when disabling broken tests to keep CI green while maintaining build efficiency.
📚 Learning: 2025-09-19T11:38:59.206Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6232
File: apps/cowswap-frontend/src/modules/tokensList/pure/ChainsSelector/index.tsx:199-200
Timestamp: 2025-09-19T11:38:59.206Z
Learning: The makeBuildClickEvent function in apps/cowswap-frontend/src/modules/tokensList/pure/ChainsSelector/index.tsx takes five parameters: defaultChainId, contextLabel, mode, isSwapMode, and chainsCount. The chainsCount parameter is used to determine the CrossChain flag in analytics events.

Applied to files:

  • apps/cowswap-frontend-e2e/src/support/commands.ts
📚 Learning: 2025-08-08T13:55:17.528Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6125
File: libs/tokens/src/state/tokens/allTokensAtom.ts:78-78
Timestamp: 2025-08-08T13:55:17.528Z
Learning: In libs/tokens/src/state/tokens/allTokensAtom.ts (TypeScript/Jotai), the team prefers to wait for token lists to initialize (listsStatesListAtom non-empty) before returning tokens. No fallback to favorites/user-added/native tokens should be used when listsStatesList is empty.

Applied to files:

  • apps/cowswap-frontend-e2e/src/support/commands.ts
📚 Learning: 2025-07-28T16:26:08.051Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6034
File: apps/cowswap-frontend-e2e/src/e2e/fiat-amounts.test.ts:44-47
Timestamp: 2025-07-28T16:26:08.051Z
Learning: In the cowswap codebase, using trivial placeholder tests like `it('should be true', () => { expect(true).to.be.true })` in e2e test files is an intentional pattern when disabling broken tests to keep CI green while maintaining build efficiency.

Applied to files:

  • apps/cowswap-frontend-e2e/src/e2e/limit-orders.test.ts
  • apps/cowswap-frontend-e2e/src/e2e/fiat-amounts.test.ts
📚 Learning: 2025-09-25T08:49:32.256Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:62-67
Timestamp: 2025-09-25T08:49:32.256Z
Learning: In the cowswap-frontend codebase, when testing hooks that use multiple bridge providers, both providers are always properly mocked as complete jest.Mocked<BridgeProvider<BridgeQuoteResult>> objects with all required methods stubbed, ensuring no undefined returns that could break the hook logic.

Applied to files:

  • apps/cowswap-frontend-e2e/src/e2e/fiat-amounts.test.ts
📚 Learning: 2025-09-25T08:48:53.495Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:58-60
Timestamp: 2025-09-25T08:48:53.495Z
Learning: In the cowswap-frontend codebase, when writing SWR tests, the team prefers maximum test isolation by using `provider: () => new Map()` in SWRConfig wrappers, even if it recreates cache on every render, to ensure tests don't share any state.

Applied to files:

  • apps/cowswap-frontend-e2e/src/support/e2e.ts
🧬 Code graph analysis (1)
apps/cowswap-frontend-e2e/src/e2e/limit-orders.test.ts (1)
apps/cowswap-frontend-e2e/src/config.ts (1)
  • SMALL_TIMEOUT (1-1)
🪛 dotenv-linter (4.0.0)
.env.local.example

[warning] 7-7: [ExtraBlankLine] Extra blank line detected

(ExtraBlankLine)


[warning] 15-15: [UnorderedKey] The CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY key should go before the CYPRESS_INTEGRATION_TEST_PRIVATE_KEY key

(UnorderedKey)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Setup
  • GitHub Check: Cypress
🔇 Additional comments (5)
apps/cowswap-frontend-e2e/src/e2e/limit-orders.test.ts (1)

1-2: Good refactor: centralized timeout constant.

Extracting the hard-coded timeout into a shared constant improves maintainability and ensures consistency across the test suite.

Also applies to: 8-8

apps/cowswap-frontend-e2e/src/support/e2e.ts (1)

58-62: Good addition: suppressing benign ResizeObserver errors.

This handler prevents test flakiness by suppressing a common, harmless browser error that occurs during rapid UI updates. The implementation correctly targets only this specific error message.

apps/cowswap-frontend-e2e/src/e2e/fiat-amounts.test.ts (2)

15-18: Excellent improvement: mocking USD price for test stability.

Mocking the USD price endpoint with a fixed value ensures deterministic test behavior and prevents flakiness from external API dependencies. The explicit cy.wait('@usdPrice') ensures the price loads before assertions run.

Also applies to: 24-24


35-35: Good refactor: using .should() for better retry logic.

Switching from .then() to .should() leverages Cypress's built-in retry mechanism, which will automatically retry the assertion until it passes or times out. This improves test reliability and aligns with Cypress best practices.

apps/cowswap-frontend-e2e/src/support/commands.ts (1)

99-104: Good refactor: explicit disabled state check.

Computing the button selector once and checking that it's not disabled before clicking improves clarity and prevents premature clicks on disabled elements.

@socket-security
Copy link

socket-security bot commented Jan 7, 2026

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @README.md:
- Around line 119-121: Change the inconsistent environment variable name in the
E2E test docs: replace the incorrect INTEGRATION_TESTS_ALCHEMY_KEY with
CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY so all three listed vars share the
CYPRESS_ prefix (matching the documented yarn e2e usage and the other entries
CYPRESS_INTEGRATION_TEST_PRIVATE_KEY and CYPRESS_INTEGRATION_TESTS_INFURA_KEY).
🧹 Nitpick comments (1)
.env.local.example (1)

7-16: Consider addressing dotenv-linter formatting suggestions.

The static analysis tool flagged a couple of minor formatting issues:

  • Line 7 has an extra blank line
  • Keys on lines 15-16 could be alphabetically ordered before the PRIVATE_KEY on line 14

These are purely stylistic and don't affect functionality.

📝 Proposed formatting cleanup
 REACT_APP_TG_DEV_BYPASS=true
-

 
 #######################################
 # End To End Test
 #######################################
 # ⚠️ Required for E2E tests to run
 
 # Cypress Integration Tests
-CYPRESS_INTEGRATION_TEST_PRIVATE_KEY=
 CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY=
 CYPRESS_INTEGRATION_TESTS_INFURA_KEY=
+CYPRESS_INTEGRATION_TEST_PRIVATE_KEY=
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ee493a7 and 5912691.

📒 Files selected for processing (5)
  • .env.local.example
  • .github/workflows/ci.yml
  • README.md
  • apps/cowswap-frontend-e2e/src/support/e2e.ts
  • apps/cowswap-frontend-e2e/src/support/ethereum.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/cowswap-frontend-e2e/src/support/e2e.ts
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6034
File: apps/cowswap-frontend-e2e/src/e2e/fiat-amounts.test.ts:44-47
Timestamp: 2025-07-28T16:26:08.051Z
Learning: In the cowswap codebase, using trivial placeholder tests like `it('should be true', () => { expect(true).to.be.true })` in e2e test files is an intentional pattern when disabling broken tests to keep CI green while maintaining build efficiency.
📚 Learning: 2025-09-25T08:48:53.495Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:58-60
Timestamp: 2025-09-25T08:48:53.495Z
Learning: In the cowswap-frontend codebase, when writing SWR tests, the team prefers maximum test isolation by using `provider: () => new Map()` in SWRConfig wrappers, even if it recreates cache on every render, to ensure tests don't share any state.

Applied to files:

  • apps/cowswap-frontend-e2e/src/support/ethereum.ts
🪛 dotenv-linter (4.0.0)
.env.local.example

[warning] 7-7: [ExtraBlankLine] Extra blank line detected

(ExtraBlankLine)


[warning] 15-15: [UnorderedKey] The CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY key should go before the CYPRESS_INTEGRATION_TEST_PRIVATE_KEY key

(UnorderedKey)


[warning] 16-16: [UnorderedKey] The CYPRESS_INTEGRATION_TESTS_INFURA_KEY key should go before the CYPRESS_INTEGRATION_TEST_PRIVATE_KEY key

(UnorderedKey)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Cypress
  • GitHub Check: Setup
🔇 Additional comments (3)
.github/workflows/ci.yml (1)

204-204: LGTM! Infura key properly added as fallback.

The new environment variable follows the same pattern as the Alchemy key and is correctly passed from GitHub secrets to the Cypress test environment.

apps/cowswap-frontend-e2e/src/support/ethereum.ts (2)

14-25: LGTM! Infura fallback properly implemented.

The provider URL resolution now correctly falls back through: NETWORK_URL → Alchemy → Infura → undefined. The logic correctly prioritizes Alchemy over Infura as documented in the README.


29-29: LGTM! Assertion message updated.

The error message now includes the Infura key variable, which will help with debugging provider configuration issues.

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.

3 participants