Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
46 changes: 46 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: E2E Tests with Core Wallet

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]

jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Install Playwright Browsers
run: yarn playwright install --with-deps chromium

- name: Run Playwright tests
run: yarn test

- name: Upload Playwright Report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30

- name: Upload test screenshots
uses: actions/upload-artifact@v4
if: always()
with:
name: test-screenshots
path: tests/screenshots/
retention-days: 30

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,10 @@ content/docs/cross-chain/teleporter/deep-dive.mdx
content/docs/cross-chain/teleporter/overview.mdx
content/docs/cross-chain/teleporter/upgradeability.mdx

# Playwright test artifacts
/tests/extensions/
/tests/screenshots/
/test-results/
/playwright-report/
/playwright/.cache/

11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
"start": "pnpm build:remote && next build && next start",
"check-links": "tsx .github/linkChecker.ts",
"postinstall": "prisma generate && fumadocs-mdx && node ./scripts/update_docker_tags.mjs",
"postbuild": "tsx ./utils/update-index.ts"
"postbuild": "tsx ./utils/update-index.ts",
"test": "playwright test",
"test:headed": "playwright test --headed",
"test:ui": "playwright test --ui",
"test:debug": "playwright test --debug"
},
"dependencies": {
"@ai-sdk/openai": "^1.3.24",
Expand Down Expand Up @@ -129,14 +133,19 @@
"zustand": "^5.0.8"
},
"devDependencies": {
"@playwright/test": "^1.48.2",
"@tailwindcss/postcss": "^4.1.13",
"@tailwindcss/typography": "^0.5.16",
"@types/adm-zip": "^0.5.5",
"@types/canvas-confetti": "^1.9.0",
"@types/mdx": "^2.0.13",
"@types/node": "^24.5.0",
"@types/prismjs": "^1.26.5",
"@types/react": "^19.1.13",
"@types/react-dom": "^19.1.9",
"adm-zip": "^0.5.16",
"dotenv": "^17.2.3",
"playwright-core": "^1.48.2",
"postcss": "^8.5.6",
"prisma": "^6.16.1",
"tailwindcss": "^4.1.13",
Expand Down
61 changes: 61 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { defineConfig, devices } from '@playwright/test';

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',

/* Run tests in files in parallel */
fullyParallel: false, // Set to false when using extensions

/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,

/* Retry on CI only */
retries: process.env.CI ? 2 : 0,

/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : 1, // Extensions work best with single worker

/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [
['html'],
['list'],
],

/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.BASE_URL || 'http://localhost:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',

/* Screenshot on failure */
screenshot: 'only-on-failure',

/* Video on failure */
video: 'retain-on-failure',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium-with-core-wallet',
use: {
...devices['Desktop Chrome'],
// Extension-specific settings will be handled in test setup
},
},
],

/* Run your local dev server before starting the tests */
webServer: {
command: 'yarn dev',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
timeout: 120000,
},
});

8 changes: 4 additions & 4 deletions scripts/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"avaplatform/icm-relayer": "v1.7.3"
},
"testnet": {
"avaplatform/avalanchego": "v1.14.0",
"avaplatform/subnet-evm_avalanchego": "v0.8.0_v1.14.0",
"avaplatform/icm-relayer": "v1.7.3"
"avaplatform/avalanchego": "v1.14.0-fuji",
"avaplatform/subnet-evm_avalanchego": "v0.8.0-fuji_v1.14.0-fuji",
"avaplatform/icm-relayer": "v1.7.2-fuji"
},
"ava-labs/icm-contracts": "4d5ab0b6dbc653770cfe9709878c9406eb28b71c"
}
}
137 changes: 137 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Automated QA Testing with Core Wallet

This directory contains automated end-to-end tests using Playwright with the Core Wallet extension preinstalled.

## Setup

1. Install dependencies:
```bash
yarn install
```

2. Install Playwright browsers (first time only):
```bash
yarn playwright install chromium
```

3. Configure your wallet (in project root `.env`):
```bash
# NEVER use a wallet with real funds for testing!
CORE_WALLET_MNEMONIC="your twelve or twenty four word recovery phrase goes here"
CORE_WALLET_PASSWORD="TestPassword123!"
```

See `tests/.env.example` for the template.

## Running Tests

### Run all tests (headless):
```bash
yarn test
```

### Run tests with visible browser:
```bash
yarn test:headed
```

### Run tests with Playwright UI (interactive):
```bash
yarn test:ui
```

### Debug tests step-by-step:
```bash
yarn test:debug
```

## Core Wallet Setup

The Core Wallet extension is automatically downloaded and configured the first time you run the tests. The extension files are cached in `tests/extensions/core-wallet/` and will be reused for subsequent test runs.

### How it works:

1. **Automatic Download**: The setup script downloads Core Wallet from the Chrome Web Store
2. **Extension Loading**: Playwright launches Chrome with the extension pre-installed
3. **Persistent Context**: Tests run with the extension active

## Test Structure

```
tests/
├── setup/
│ └── core-wallet.setup.ts # Extension download and setup utilities
├── core-wallet.spec.ts # Example test file
└── README.md # This file
```

## Writing Tests

Example test with Core Wallet:

```typescript
import { test, expect } from '@playwright/test';
import { createBrowserWithCoreWallet } from './setup/core-wallet.setup';

test('my test', async () => {
const context = await createBrowserWithCoreWallet();
const page = await context.newPage();

// Your test code here
await page.goto('https://your-app.com');

// Core Wallet is now available in the browser

await context.close();
});
```

## GitHub Actions

To run tests in CI/CD, add this workflow configuration (the extension will be automatically downloaded in CI):

```yaml
name: E2E Tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: yarn install
- run: yarn playwright install --with-deps chromium
- run: yarn test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
```

## Troubleshooting

### Extension not loading
- Make sure you're running in headed mode for debugging: `yarn test:headed`
- Check that the extension directory exists: `tests/extensions/core-wallet/`
- Delete the extensions folder and re-run to force a fresh download

### Tests timing out
- Increase timeout in `playwright.config.ts`
- Extensions may take longer to initialize, add `await page.waitForTimeout(5000)` after opening pages

### Can't find Core Wallet in window
- The extension may inject different global variables depending on the page
- Check browser console for what's actually injected
- Some extensions only inject on specific domains

## Notes

- Tests run with `headless: false` by default because Chrome extensions require a visible browser window
- The Core Wallet extension files are gitignored and will be downloaded automatically
- Each test gets a fresh browser context with the extension pre-loaded

10 changes: 10 additions & 0 deletions tests/env-template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Core Wallet Testing Configuration
# Copy this to your project root .env file

# Your 12 or 24 word recovery phrase for testing
# NEVER use a wallet with real funds for testing!
CORE_WALLET_MNEMONIC="your twelve or twenty four word recovery phrase goes here"

# Password to set for the wallet in tests (optional, defaults to TestPassword123!)
CORE_WALLET_PASSWORD="TestPassword123!"

Loading