-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Feat/e2e pipeline #1238
Feat/e2e pipeline #1238
Changes from 19 commits
d4470a4
1af8c2a
0d6fb93
be42dcc
07e9095
21fe637
4aecdce
1ccbcbf
ddde48e
6614c80
da7fb2f
7c58986
47d4834
47dfb2f
d42c8c7
d6101cb
57767ae
eb121ca
965c68c
cee2564
67de1ef
0324688
f5879d0
a01672d
e79f92a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Pull request E2E tests | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are you ignoring my previous PR feedback here? Please either say you disagree with the feedback or agree with it but don't ignore it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not ignore your pervious feedback |
||
on: | ||
pull_request: | ||
branches: | ||
- V2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. feels like a regression to the previous iteration where you also ran upon There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous iteration did not exist, I never wrote a previous iteration |
||
|
||
jobs: | ||
e2e_tests: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
permissions: | ||
contents: read | ||
deployments: write | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v3 | ||
- name: setup-node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
cache: 'npm' | ||
cache-dependency-path: 'package-lock.json' | ||
- name: install deps | ||
run: npm ci | ||
- name: build | ||
run: npm run build | ||
env: | ||
NEXT_PUBLIC_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_PROJECT_ID }} | ||
- name: Install Playwright Browsers | ||
run: npx playwright install --with-deps | ||
- name: cloudflare-preview-url | ||
id: cloudflare_preview_url | ||
uses: zentered/[email protected] | ||
env: | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }} | ||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }} | ||
with: | ||
cloudflare_project_id: ${{ secrets.CF_ZONE_ID}} | ||
wait_until_ready: true | ||
- name: Get URL | ||
run: echo "https://${{ steps.cloudflare_preview_url.outputs.preview_url }}" | ||
# - name: Run Playwright tests | ||
# working-directory: ./laboratory | ||
# run: npx playwright test | ||
# - uses: actions/upload-artifact@v3 | ||
# if: always() | ||
# with: | ||
# name: playwright-report | ||
# path: ./laboratory/playwright-report/ | ||
# retention-days: 30 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ out | |
lerna-debug.log | ||
.env.local | ||
.env | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
# Get your projectId at https://cloud.walletconnect.com | ||
NEXT_PUBLIC_PROJECT_ID="" | ||
NEXT_PUBLIC_SENTRY_DSN="" # OPTIONAL | ||
|
||
# E2E test vars (optional) | ||
LOCAL_LABS_URL="http://localhost:3000" | ||
LOCAL_WALLET_URL="http://localhost:3001" | ||
|
||
LABS_URL="https://labs.walletconnect.com" | ||
WALLET_URL="https://react-wallet.walletconnect.com/" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
import { config } from 'dotenv' | ||
config({ path: './.env.local' }) | ||
|
||
export default defineConfig({ | ||
testDir: './tests', | ||
|
||
fullyParallel: true, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
reporter: 'list', | ||
|
||
expect: { | ||
timeout: (process.env.CI ? 60 : 5) * 1000 | ||
}, | ||
timeout: 60 * 1000, | ||
|
||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: process.env.CI ? process.env.LABS_URL : process.env.LOCAL_LABS_URL, | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
|
||
video: process.env.CI ? 'off' : 'on-first-retry' | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] } | ||
}, | ||
|
||
{ | ||
name: 'firefox', | ||
use: { ...devices['Desktop Firefox'] } | ||
}, | ||
|
||
{ | ||
name: 'webkit', | ||
use: { ...devices['Desktop Safari'] } | ||
} | ||
/* Test against mobile viewports. */ | ||
/* | ||
* { | ||
* name: 'Mobile Chrome', | ||
* use: { ...devices['Pixel 5'] }, | ||
* }, | ||
* { | ||
* name: 'Mobile Safari', | ||
* use: { ...devices['iPhone 12'] }, | ||
* }, | ||
*/ | ||
|
||
/* Test against branded browsers. */ | ||
/* | ||
* { | ||
* name: 'Microsoft Edge', | ||
* use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
* }, | ||
* { | ||
* name: 'Google Chrome', | ||
* use: { ..devices['Desktop Chrome'], channel: 'chrome' }, | ||
* }, | ||
*/ | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: 'npm run playwright:start', | ||
url: process.env.LOCAL_LABS_URL | ||
} | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { testM, expect } from './shared/fixtures/w3m-fixture' | ||
|
||
testM.describe('Modal only tests', () => { | ||
testM('Should be able to open modal', async ({ modalPage }) => { | ||
await modalPage.page.getByTestId('partial-core-connect-button').click() | ||
await expect(modalPage.page.getByTestId('component-header-action-button')).toBeVisible() | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { SessionParams } from '../types' | ||
|
||
export const DEFAULT_SESSION_PARAMS: SessionParams = { | ||
reqAccounts: ['1', '2'], | ||
optAccounts: ['1', '2'], | ||
accept: true | ||
} | ||
|
||
// Will be moved to env vars in the future | ||
export const LOCAL_LAB_URL = 'http://localhost:3000/with-wagmi/react' | ||
export const LOCAL_WALLET_URL = 'http://localhost:3001' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { testMW, expect } from './w3m-wallet-fixture' | ||
|
||
testMW('Open pages', ({ modalPage, walletPage }) => { | ||
expect(modalPage).toBeDefined() | ||
expect(walletPage).toBeDefined() | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { test as base } from '@playwright/test' | ||
import { ModalPage } from '../pages/ModalPage' | ||
import { ModalValidator } from '../validators/ModalValidator' | ||
|
||
// Declare the types of fixtures to use | ||
interface ModalFixture { | ||
modalPage: ModalPage | ||
modalValidator: ModalValidator | ||
} | ||
|
||
// M -> test Modal | ||
export const testM = base.extend<ModalFixture>({ | ||
modalPage: async ({ page }, use) => { | ||
const modalPage = new ModalPage(page) | ||
await modalPage.load() | ||
await use(modalPage) | ||
}, | ||
modalValidator: async ({ modalPage }, use) => { | ||
const modalValidator = new ModalValidator(modalPage.page) | ||
await use(modalValidator) | ||
} | ||
}) | ||
export { expect } from '@playwright/test' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { testM as base } from './w3m-fixture' | ||
import { WalletPage } from '../pages/WalletPage' | ||
import { WalletValidator } from '../validators/WalletValidator' | ||
|
||
// Declare the types of fixtures to use | ||
interface ModalWalletFixture { | ||
walletPage: WalletPage | ||
walletValidator: WalletValidator | ||
} | ||
|
||
// MW -> test Modal + Wallet | ||
export const testMW = base.extend<ModalWalletFixture>({ | ||
walletPage: async ({ context, browserName }, use) => { | ||
// WalletPage needs clipboard permissions with chromium to paste URI | ||
if (browserName === 'chromium') { | ||
await context.grantPermissions(['clipboard-read', 'clipboard-write']) | ||
} | ||
|
||
// Use a new page, to open alongside the modal | ||
const walletPage = new WalletPage(await context.newPage()) | ||
await walletPage.load() | ||
await use(walletPage) | ||
}, | ||
walletValidator: async ({ walletPage }, use) => { | ||
const walletValidator = new WalletValidator(walletPage.page) | ||
await use(walletValidator) | ||
} | ||
}) | ||
export { expect } from '@playwright/test' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import type { Locator, Page } from '@playwright/test' | ||
import { LOCAL_LAB_URL } from '../constants' | ||
|
||
export class ModalPage { | ||
private readonly baseURL = LOCAL_LAB_URL | ||
|
||
private readonly w3modal: Locator | ||
|
||
constructor(public readonly page: Page) { | ||
this.w3modal = this.page.getByTestId('partial-core-connect-button') | ||
} | ||
|
||
async load() { | ||
await this.page.goto(this.baseURL) | ||
} | ||
|
||
async getUri() { | ||
await this.page.goto(this.baseURL) | ||
await this.w3modal.click() | ||
await this.page.getByTestId('component-header-action-button').click() | ||
} | ||
|
||
async disconnect() { | ||
await this.page.getByTestId('partial-account-address').click() | ||
await this.page.getByTestId('view-account-disconnect-button').click() | ||
} | ||
|
||
async sign() { | ||
await this.page.getByTestId('lab-sign').click() | ||
} | ||
|
||
async signTyped() { | ||
await this.page.getByTestId('lab-sign-typed').click() | ||
} | ||
|
||
async switchChain({ chainName }: { chainName: string }) { | ||
await this.page.getByTestId('partial-network-switch-button').click() | ||
await this.page.getByText(new RegExp(chainName, 'u')).click() | ||
} | ||
|
||
async helpModal() { | ||
await this.page.getByTestId('backcard-help').click() | ||
} | ||
|
||
async closeModal() { | ||
await this.page.getByTestId('backcard-close').click() | ||
} | ||
} |
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.
Any reason you're narrowing it down to PRs now?
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.
Discussed with JS team yesterday, was told to run at the same time as other PR checks