Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,3 @@ 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=
64 changes: 1 addition & 63 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,69 +187,9 @@ jobs:
- name: Run typecheck
run: pnpm run typecheck

integration-tests:
name: Cypress
if: ${{ false }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Increase watchers
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

- name: Install pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8

- name: Set up node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm

- name: Install dependencies
run: pnpm run install:ci

- name: Install Cypress binary
working-directory: apps/cowswap-frontend-e2e
run: npx cypress install

- name: Start server in the background
run: pnpm run preview &

# Actually run tests, building repo
- name: Cypress run
id: cypress-run
uses: cypress-io/github-action@b7a7441d775af8f8b9d19945c10dd689a51dba68 # v7.2.0
with:
wait-on: http://[::1]:3000
wait-on-timeout: 600
install: false
working-directory: apps/cowswap-frontend-e2e
env:
CYPRESS_INTEGRATION_TEST_PRIVATE_KEY: ${{ secrets.CYPRESS_INTEGRATION_TEST_PRIVATE_KEY }}
CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY: ${{ secrets.CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY }}
CYPRESS_INTEGRATION_TESTS_INFURA_KEY: ${{ secrets.CYPRESS_INTEGRATION_TESTS_INFURA_KEY }}

# - uses: actions/upload-artifact@v3
# if: always()
# with:
# name: cypress-videos
# path: |
# cypress-custom/videos
# cypress-custom/screenshots

# Open tmate ssh connection on failure for debugging
# Uncomment when needed and push upstream
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# if: ${{ failure() }}

notify-failure:
name: Notify Slack on Failure
needs: [setup, test, lint, typecheck, agent-harness, integration-tests]
needs: [setup, test, lint, typecheck, agent-harness]
runs-on: ubuntu-latest
if: always() && failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')

Expand All @@ -261,7 +201,6 @@ jobs:
[ "$LINT_RESULT" = "failure" ] && failed_jobs+=("Lint")
[ "$TYPECHECK_RESULT" = "failure" ] && failed_jobs+=("Typecheck")
[ "$AGENT_HARNESS_RESULT" = "failure" ] && failed_jobs+=("Agent Harness")
[ "$INTEGRATION_TESTS_RESULT" = "failure" ] && failed_jobs+=("Cypress")

if [ ${#failed_jobs[@]} -eq 0 ]; then
failure_summary="CI"
Expand All @@ -280,4 +219,3 @@ jobs:
LINT_RESULT: ${{ needs.lint.result }}
TYPECHECK_RESULT: ${{ needs.typecheck.result }}
AGENT_HARNESS_RESULT: ${{ needs.agent-harness.result }}
INTEGRATION_TESTS_RESULT: ${{ needs.integration-tests.result }}
53 changes: 53 additions & 0 deletions .github/workflows/e2e-pw-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: E2E PW nightly

on:
schedule:
- cron: '0 2 * * *' # every day at 2:00 AM
workflow_dispatch:

jobs:
full:
runs-on: ubuntu-latest
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
env:
INTEGRATION_TEST_PRIVATE_KEY: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
REACT_APP_NETWORK_URL_11155111: ${{ secrets.REACT_APP_NETWORK_URL_11155111 }}
E2E_PW_MM_SEED: ${{ secrets.E2E_PW_MM_SEED }}
CI: 'true'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: lts/jod
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm --filter @cowprotocol/cowswap-e2e-pw exec playwright install --with-deps chromium
- run: pnpm --filter @cowprotocol/cowswap-e2e-pw exec playwright test --shard=${{ matrix.shard }}/4
- if: always()
Comment thread
azebuado marked this conversation as resolved.
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: playwright-report-shard-${{ matrix.shard }}
path: apps/cowswap-e2e-tests/playwright-report
retention-days: 14

notify-failure:
name: Notify Slack on Failure
needs: [full]
runs-on: ubuntu-latest
if: always() && failure()

steps:
- name: Notify Failure
run: |
curl -X POST -H "Content-type: application/json" --data "{\"text\": \"❌ E2E PW nightly failed on \`$REF_NAME\`. <$SERVER_URL/$REPOSITORY/actions/runs/$RUN_ID|See run $RUN_ID on GH>.\"}" "$SLACK_WEBHOOK_URL"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
REF_NAME: ${{ github.ref_name }}
SERVER_URL: ${{ github.server_url }}
REPOSITORY: ${{ github.repository }}
RUN_ID: ${{ github.run_id }}
40 changes: 40 additions & 0 deletions .github/workflows/e2e-pw-smoke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: E2E PW smoke

on:
pull_request:
paths:
- 'apps/cowswap-frontend/**'
- 'apps/cowswap-e2e-tests/**'
- 'libs/**'
- 'package.json'
- 'pnpm-lock.yaml'
Comment thread
shoom3301 marked this conversation as resolved.

concurrency:
group: e2e-pw-smoke-${{ github.ref }}
cancel-in-progress: true

jobs:
smoke:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
INTEGRATION_TEST_PRIVATE_KEY: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
REACT_APP_NETWORK_URL_11155111: ${{ secrets.REACT_APP_NETWORK_URL_11155111 }}
E2E_PW_MM_SEED: ${{ secrets.E2E_PW_MM_SEED }}
CI: 'true'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Comment thread
shoom3301 marked this conversation as resolved.
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: lts/jod
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm --filter @cowprotocol/cowswap-e2e-pw exec playwright install --with-deps chromium
- run: pnpm e2e:smoke
- if: always()
Comment thread
shoom3301 marked this conversation as resolved.
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: playwright-report
path: apps/cowswap-e2e-tests/playwright-report
retention-days: 7
4 changes: 2 additions & 2 deletions .mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ queue_rules:
- name: default
conditions:
- check-success=Deploy
- check-success=Cypress
- check-success=smoke

pull_request_rules:
- name: Merge approved and green PRs when tagged with 'Auto-merge'
conditions:
- '#approved-reviews-by>=2'
- label="Auto-merge"
- check-success=Deploy
- check-success=Cypress
- check-success=smoke
actions:
queue:
method: squash
Expand Down
36 changes: 20 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,31 +147,35 @@ pnpm run cosmos

# 🤓 Development

## Integration test
## E2E tests

> ⚠️ To run the tests. Make sure you add the required environment variables to
> your root `.env.local` file with:
CoW Swap's e2e suite lives in [`apps/cowswap-e2e-tests`](apps/cowswap-e2e-tests) (Playwright +
Synpress). See that app's [README](apps/cowswap-e2e-tests/README.md) for the full guide — mocks, page
objects, wallet fixtures, and troubleshooting.

> ⚠️ Add the required environment variables to your root `.env.local` file:
>
> - `CYPRESS_INTEGRATION_TEST_PRIVATE_KEY=<your-private-key>`: Private key
> - `CYPRESS_INTEGRATION_TESTS_INFURA_KEY=<your-infura-key>`: Infura key
> - `CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY=<your-alchemy-key>`: Alchemy key (preferred if both are set)
> - `INTEGRATION_TEST_PRIVATE_KEY=<a throwaway Sepolia private key>`
> - `REACT_APP_NETWORK_URL_11155111=<a Sepolia RPC URL>`

To launch it with our development server (so you have live-reloading):
Build the Synpress MetaMask cache once (required for the real-wallet fixtures):

```bash
# Terminal 1
pnpm run start
# Terminal 2
pnpm run e2e
pnpm e2e:build-cache
```
Comment thread
shoom3301 marked this conversation as resolved.
Outdated

If we want to use the Cypress UI, with the production build:
Then run the suite. Playwright builds and serves the app itself, so there's no need to start a dev
server in a separate terminal:

```bash
# Terminal 1
npx nx run cowswap-frontend:serve-static --port 3000
# Terminal 2
pnpm run e2e:open
# Full suite
pnpm e2e

# PR smoke subset only
pnpm e2e:smoke

# Playwright UI mode, for interactive debugging
pnpm e2e:ui
```

## Analyze build
Expand Down
8 changes: 0 additions & 8 deletions apps/cowswap-frontend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ node_modules

# testing
/coverage
cypress.env.json

# builds
/build
Expand Down Expand Up @@ -43,13 +42,6 @@ notes.txt

package-lock.json

cypress/videos
cypress/screenshots
cypress/fixtures/example.json
cypress-custom/videos
cypress-custom/screenshots
cypress-custom/fixtures/example.json

# public
public/version.json
.vercel
2 changes: 1 addition & 1 deletion apps/cowswap-frontend/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default defineConfig(({ mode, isPreview }) => {
minify: true,
injectManifest: {
// Preview build currently emits a large main chunk.
// If this value is smaller, pnpm preview will fail to start and Cypress will hang in CI and eventually timeout.
// If this value is smaller, pnpm preview will fail to start and Playwright will hang in CI and eventually timeout.
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10 MiB
globPatterns: ['**/*.{js,css,html,png,jpg,svg,json,woff,woff2,md}'],
},
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"test:tools": "node --test tools/scripts/*.test.mjs",
"typecheck": "nx run cowswap-frontend:typecheck && pnpm run typecheck:workspaces",
"typecheck:workspaces": "node tools/scripts/typecheck-workspaces.mjs",
"e2e:open": "nx run-many -t e2e:open",
"lint": "nx run-many -t lint",
"agents:check": "node tools/scripts/agents-check.mjs && node tools/scripts/check-pinned-package-versions.mjs",
"lint:fix": "pnpm run lint --fix --skip-nx-cache",
Expand Down Expand Up @@ -168,7 +167,6 @@
"@eslint/js": "9.39.2",
"@lingui/vite-plugin": "5.5.1",
"@next/eslint-plugin-next": "16.1.6",
"@nx/cypress": "22.4.2",
"@nx/eslint": "22.4.2",
"@nx/eslint-plugin": "22.4.2",
"@nx/jest": "22.4.2",
Expand Down Expand Up @@ -201,7 +199,6 @@
"eslint": "9.37.0",
"eslint-config-next": "16.1.5",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-cypress": "5.2.0",
"eslint-plugin-import": "2.32.0",
"eslint-plugin-jest": "29.0.1",
"eslint-plugin-jsx-a11y": "6.10.2",
Expand Down
Loading
Loading