-
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
Closed
Closed
Feat/e2e pipeline #1238
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
d4470a4
chore: skeleton e2e structure
JonathanConn 1af8c2a
merge V2 into feat/e2e
JonathanConn 0d6fb93
feat: explorer tests
JonathanConn be42dcc
feat: made wallet tests in explorer view modular to write wallet test…
JonathanConn 07e9095
feat: tested web3modal using lab against our web3wallet example, adde…
JonathanConn 21fe637
fix: minor cleanup, added tags to ui, added a test for chain switching
JonathanConn 4aecdce
feat: Modularized modal and wallet pages by createing custom pages, a…
JonathanConn 1ccbcbf
feat: started to split functional tests and ui tests apart, making it…
JonathanConn ddde48e
feat: finished refactor, test skeleton is now much more flexible and …
JonathanConn 6614c80
fix: added remaining tests to suite, started experimenting with diffe…
JonathanConn da7fb2f
feat: finished basic validators, configuerd fixturers and tests to us…
JonathanConn 7c58986
fix: regen package lock
JonathanConn 47d4834
fix: removed workflow to reduce confusion, improved naming of validat…
JonathanConn 47dfb2f
Merge branch 'V2' into feat/e2e-wallet
JonathanConn d42c8c7
feat: initial pipeline for testing
JonathanConn d6101cb
fix: added new deps
JonathanConn 57767ae
fix: added build step
JonathanConn eb121ca
fix: added env to build
JonathanConn 965c68c
fix: moved workflow to new file. Started testing cloudflare preview u…
JonathanConn cee2564
fix: switched CF zone ID to CF project ID to correctly use CF API
JonathanConn 67de1ef
chore: switching run to test cf sol
JonathanConn 0324688
chore: adding in cf url to playwright test env
JonathanConn f5879d0
fix: added missing env var
JonathanConn a01672d
fix: added missing env var
JonathanConn e79f92a
fix: fixed playwright config file + vars
JonathanConn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: E2E tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- feat/e2e-pipeline | ||
|
||
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_PROJECT_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 | ||
env: | ||
LABS_URL: ${{ steps.cloudflare_preview_url.outputs.preview_url }} | ||
WALLET_URL: "https://react-wallet.walletconnect.com/" | ||
NEXT_PUBLIC_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_PROJECT_ID }} | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: ./laboratory/playwright-report/ | ||
retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.CI ? process.env.LABS_URL : process.env.LOCAL_LABS_URL | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I did not ignore your pervious feedback
This draft pr was never meant to be reviewed
I was using this PR to test solutions to an issue I linked in our slack
I agree with the changes you suggested and they will be there in the final version