-
Notifications
You must be signed in to change notification settings - Fork 159
chore: restore e2e tests #6789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
chore: restore e2e tests #6789
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughAdded Infura E2E env support and README updates, increased Cypress timeouts and introduced SMALL_TIMEOUT/LARGE_TIMEOUT, refactored token-selection and test helpers, standardized timeouts and signer caching across tests, suppressed a ResizeObserver exception, and updated CI to pass the Infura key. Changes
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
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this 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
📒 Files selected for processing (5)
.env.local.example.github/workflows/ci.ymlREADME.mdapps/cowswap-frontend-e2e/src/support/e2e.tsapps/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.
9f845a6 to
83b7f7f
Compare
There was a problem hiding this 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 (3)
.env.local.example (1)
7-7: Address dotenv-linter warnings for formatting consistency.Static analysis flagged two minor issues:
- Line 7: Extra blank line (consider removing one of the two blank lines separating sections)
- Lines 15–16: Keys out of alphabetical order (ALCHEMY_KEY and INFURA_KEY should come before PRIVATE_KEY)
These are lint warnings and won't affect functionality, but aligning with linter expectations keeps the file consistent.
🔧 Proposed fix (optional)
# Enable Telegram development bypass mode # When enabled, Telegram verification is bypassed and uses a mock user (@devuser) 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_TESTS_ALCHEMY_KEY= +CYPRESS_INTEGRATION_TESTS_INFURA_KEY= +CYPRESS_INTEGRATION_TEST_PRIVATE_KEY=Also applies to: 15-16
apps/cowswap-frontend-e2e/src/support/commands.ts (2)
99-104: Standardize timeout with LARGE_TIMEOUT constant.The hard-coded
20_000timeout should use theLARGE_TIMEOUTconstant introduced inapps/cowswap-frontend-e2e/src/config.tsfor consistency with the timeout standardization effort across other e2e tests.♻️ Proposed refactor
Import the timeout constant at the top of the file:
+import { LARGE_TIMEOUT } from '../config'Then update the function:
function _clickOnToken(inputOrOutput: string) { const buttonSelector = `#${inputOrOutput}-currency-input .open-currency-select-button` - cy.get(buttonSelector, { timeout: 20_000 }).should('not.be.disabled') + cy.get(buttonSelector, { timeout: LARGE_TIMEOUT }).should('not.be.disabled') cy.get(buttonSelector).click() }
108-116: Standardize timeout and document force click necessity.Two observations:
- The hard-coded
20_000timeout should useLARGE_TIMEOUTfor consistency.- The
force: trueoption bypasses Cypress's actionability checks. If this is necessary due to virtualization or overlays in the token list, consider adding a comment explaining why natural clicks fail.♻️ Proposed refactor
function _selectTokenFromSelector(tokenAddress: string, inputOrOutput: string) { const tokenSelector = `#token-search-results div[data-address="${tokenAddress.toLowerCase()}"]` const searchSelector = '#token-search-input' - 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) + // force: true required due to virtualized token list rendering + cy.get(tokenSelector, { timeout: LARGE_TIMEOUT }).should('be.visible').click({ force: true }) cy.get(`#${inputOrOutput}-currency-input .token-amount-input`).should('be.visible') }
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
.env.env.local.example.github/workflows/ci.ymlREADME.mdapps/cowswap-frontend-e2e/cypress.config.tsapps/cowswap-frontend-e2e/src/config.tsapps/cowswap-frontend-e2e/src/e2e/fiat-amounts.test.tsapps/cowswap-frontend-e2e/src/e2e/limit-orders.test.tsapps/cowswap-frontend-e2e/src/e2e/lists.test.tsapps/cowswap-frontend-e2e/src/e2e/search.test.tsapps/cowswap-frontend-e2e/src/e2e/swap.test.tsapps/cowswap-frontend-e2e/src/e2e/swapMod.test.tsapps/cowswap-frontend-e2e/src/support/commands.tsapps/cowswap-frontend-e2e/src/support/e2e.tsapps/cowswap-frontend-e2e/src/support/ethereum.ts
💤 Files with no reviewable changes (1)
- .env
🚧 Files skipped from review as they are similar to previous changes (10)
- apps/cowswap-frontend-e2e/cypress.config.ts
- apps/cowswap-frontend-e2e/src/e2e/search.test.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/config.ts
- .github/workflows/ci.yml
- README.md
- apps/cowswap-frontend-e2e/src/e2e/lists.test.ts
- apps/cowswap-frontend-e2e/src/support/ethereum.ts
- apps/cowswap-frontend-e2e/src/support/e2e.ts
🧰 Additional context used
🧠 Learnings (13)
📚 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/swapMod.test.tsapps/cowswap-frontend-e2e/src/e2e/swap.test.ts
📚 Learning: 2025-02-20T15:59:33.749Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 5443
File: apps/cowswap-frontend/src/modules/swap/containers/ConfirmSwapModalSetup/index.tsx:71-71
Timestamp: 2025-02-20T15:59:33.749Z
Learning: The swap module in apps/cowswap-frontend/src/modules/swap/ is marked for deletion in PR #5444 as part of the swap widget unification effort.
Applied to files:
apps/cowswap-frontend-e2e/src/e2e/swapMod.test.ts
📚 Learning: 2025-10-10T20:28:16.565Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6347
File: apps/cowswap-frontend/src/modules/trade/pure/TradeConfirmation/index.tsx:49-49
Timestamp: 2025-10-10T20:28:16.565Z
Learning: In apps/cowswap-frontend/src/modules/trade, TradeConfirmation follows a two-layer architecture: TradeConfirmationView (pure/stateless) in pure/TradeConfirmation/index.tsx renders the UI, while TradeConfirmation (container) in containers/TradeConfirmation/index.tsx wraps it to freeze props during pending trades (via useStableTradeConfirmationProps), wire in signing state (useSigningStep), and inject trade confirmation state (useTradeConfirmState). Consuming modules should import the container TradeConfirmation from 'modules/trade' to preserve this stateful behavior.
<!-- [add_learning]
When reviewing component refactoring in apps/cowswap-frontend/src/modules/trade, recognize the pattern where a pure view component (e.g., TradeConfirmationView) is separated from a stateful container (e.g., TradeConfirmation) that wraps it. The container adds runtime state management (prop stabilization, signing state, etc.) while the view remains testable and composable. Do not flag usages that import th...
Applied to files:
apps/cowswap-frontend-e2e/src/e2e/swapMod.test.tsapps/cowswap-frontend-e2e/src/e2e/swap.test.ts
📚 Learning: 2025-10-13T19:41:31.440Z
Learnt from: limitofzero
Repo: cowprotocol/cowswap PR: 6351
File: apps/cowswap-frontend/src/modules/erc20Approve/containers/TradeApproveModal/useTradeApproveCallback.ts:87-121
Timestamp: 2025-10-13T19:41:31.440Z
Learning: In apps/cowswap-frontend/src/modules/erc20Approve, useApproveCallback returns Promise<TransactionResponse | undefined> and is distinct from useApproveCurrency, which can return Promise<TransactionReceipt | SafeMultisigTransactionResponse>. When reviewing approval flows, verify which hook is actually being used before flagging Safe wallet concerns.
Applied to files:
apps/cowswap-frontend-e2e/src/e2e/swapMod.test.tsapps/cowswap-frontend-e2e/src/e2e/swap.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/swapMod.test.tsapps/cowswap-frontend-e2e/src/e2e/swap.test.ts
📚 Learning: 2025-05-26T12:39:29.009Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 5715
File: libs/common-const/src/tokens.ts:539-555
Timestamp: 2025-05-26T12:39:29.009Z
Learning: The team accepts using NATIVE_CURRENCY_ADDRESS as a temporary placeholder for COW token contract addresses on new networks (Polygon, Avalanche) until actual COW contracts are deployed.
Applied to files:
apps/cowswap-frontend-e2e/src/e2e/swapMod.test.ts
📚 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-08-08T13:56:18.009Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6125
File: libs/tokens/src/updaters/TokensListsUpdater/index.tsx:29-31
Timestamp: 2025-08-08T13:56:18.009Z
Learning: In libs/tokens/src/updaters/TokensListsUpdater/index.tsx, the project’s current Jotai version requires using `unstable_getOnInit` (not `getOnInit`) in atomWithStorage options; keep `{ unstable_getOnInit: true }` until Jotai is upgraded.
Applied to files:
apps/cowswap-frontend-e2e/src/support/commands.ts
📚 Learning: 2025-08-21T08:13:23.325Z
Learnt from: alfetopito
Repo: cowprotocol/cowswap PR: 6170
File: apps/cowswap-frontend/src/modules/twap/services/cancelTwapOrderTxs.ts:73-86
Timestamp: 2025-08-21T08:13:23.325Z
Learning: On zkSync chains, the standard ethers.js gas estimation approach using `{ from: address }` overrides doesn't work. The `.connect(FAKE_OWNER)` pattern with a plain address string is used instead, even though this seems unconventional compared to standard ethers.js usage where connect() expects a signer.
Applied to files:
apps/cowswap-frontend-e2e/src/e2e/swap.test.ts
📚 Learning: 2025-05-28T16:50:12.273Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 5768
File: apps/cow-fi/components/LearnPageComponent.tsx:184-185
Timestamp: 2025-05-28T16:50:12.273Z
Learning: In apps/cow-fi/components/LearnPageComponent.tsx, the user prefers to keep the inconsistent link behavior where featured articles always open in new tabs (target="_blank") while media coverage links conditionally open in new tabs based on the linkExternal flag. This inconsistency should not be flagged as an issue in future reviews.
Applied to files:
apps/cowswap-frontend-e2e/src/e2e/swap.test.ts
📚 Learning: 2025-07-24T16:42:53.154Z
Learnt from: cowdan
Repo: cowprotocol/cowswap PR: 6009
File: apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/HighFeeWarningTooltipContent.tsx:23-33
Timestamp: 2025-07-24T16:42:53.154Z
Learning: In apps/cowswap-frontend/src/modules/tradeWidgetAddons/containers/HighFeeWarning/HighFeeWarningTooltipContent.tsx, the use of toFixed(2) for percentage formatting in tooltip content is intentional and differs from the banner message formatting that uses toSignificant(2, undefined, Rounding.ROUND_DOWN). This formatting difference serves different UX purposes and should not be flagged as inconsistent.
Applied to files:
apps/cowswap-frontend-e2e/src/e2e/swap.test.ts
📚 Learning: 2025-08-21T08:13:23.325Z
Learnt from: alfetopito
Repo: cowprotocol/cowswap PR: 6170
File: apps/cowswap-frontend/src/modules/twap/services/cancelTwapOrderTxs.ts:73-86
Timestamp: 2025-08-21T08:13:23.325Z
Learning: In ethers.js, when estimating gas costs on zkSync chains, using `{ from: address }` as an override parameter doesn't work as expected. The `.connect()` method with an address string is the correct approach for setting the caller for gas estimation on zkSync, even though it may seem unconventional.
Applied to files:
apps/cowswap-frontend-e2e/src/e2e/swap.test.ts
🧬 Code graph analysis (2)
apps/cowswap-frontend-e2e/src/e2e/swapMod.test.ts (2)
apps/cowswap-frontend-e2e/src/support/mocks/mockSendCall.ts (2)
mockSendCall(141-152)handleNativeBalance(137-139)apps/cowswap-frontend-e2e/src/config.ts (1)
SMALL_TIMEOUT(1-1)
apps/cowswap-frontend-e2e/src/e2e/swap.test.ts (1)
apps/cowswap-frontend-e2e/src/support/mocks/mockSendCall.ts (2)
mockSendCall(141-152)handleNativeBalance(137-139)
🪛 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 (4)
.env.local.example (1)
7-16: E2E test configuration section looks good.The addition of the "End To End Test" section with Cypress integration keys is appropriate for the PR objective and well-documented with clear headers and comments.
apps/cowswap-frontend-e2e/src/e2e/swap.test.ts (2)
60-81: LGTM! Efficient address caching pattern.Fetching the signer address once in
onBeforeLoadand reusing it inhandleNativeBalanceis more efficient than callingawait win.ethereum.signer.getAddress()inline multiple times. The async callback is properly supported by Cypress.
84-110: LGTM! Robust banner interaction and consistent address caching.The changes improve test reliability:
- Address caching pattern is consistent with the previous test
- Text-based banner selection (lines 105-108) is more resilient than relying solely on IDs, as it validates the user-visible content
apps/cowswap-frontend-e2e/src/e2e/swapMod.test.ts (1)
1-1: LGTM! Timeout standardization and address caching.The changes improve test reliability and maintainability:
SMALL_TIMEOUTconstant (line 1, 96) standardizes timeout values across e2e tests- Address caching pattern (lines 82, 86) is consistent with
swap.test.ts, avoiding repeated async calls during test setupAlso applies to: 79-97
Summary
Fixes e2e test flakiness.
Builts on top of #6751
To Test
To launch it with our development server (so you have live-reloading):
If we want to use the Cypress UI, with the production build:
Summary by CodeRabbit
Tests
Chores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.