Skip to content

Commit

Permalink
e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-yangy committed Jul 27, 2024
1 parent e8e835d commit 991eb66
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 6 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/check-examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: setup
uses: ./.github/actions/pr-setup

- name: Build
- name: Lint
run: yarn workspaces foreach -A --include='examples/**' run lint

test:
Expand All @@ -42,7 +42,7 @@ jobs:
- name: setup
uses: ./.github/actions/pr-setup

- name: Build
- name: Test
run: yarn workspaces foreach -A --include='examples/**' run test
e2e:
name: E2E examples
Expand All @@ -54,5 +54,25 @@ jobs:
- name: setup
uses: ./.github/actions/pr-setup

- name: Build
- name: Cache Playwright browsers
uses: actions/cache@v3
id: cache-playwright-browsers
with:
path: ~/.cache/ms-playwright/
key: ${{ runner.OS }}-playwright-browsers-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-playwright-browsers-
- name: Install Playwright Browsers
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: npx playwright install --with-deps

- name: E2E
run: yarn workspaces foreach -A --include='examples/**' run e2e
env:
NEXT_PUBLIC_PUBLISHABLE_KEY: "pk_imapik-test-5ss4GpFy-n@$$Ye3LSox"
NEXT_PUBLIC_CLIENT_ID: "K846H940Uxokhz1aDb034QwBclYnAH24"
# add to github secrets, I don't have access
# NEXT_PUBLIC_PUBLISHABLE_KEY: ${{ secrets.PUBLISHABLE_KEY }}
# NEXT_PUBLIC_CLIENT_ID: ${{ secrets.CLIENT_ID }}

4 changes: 3 additions & 1 deletion examples/passport/wallets-connect-with-nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"e2e": "npx playwright test"
},
"dependencies": {
"@ethersproject/providers": "^5.7.2",
Expand All @@ -19,6 +20,7 @@
"wagmi": "^2.11.3"
},
"devDependencies": {
"@playwright/test": "^1.45.3",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
Expand Down
25 changes: 25 additions & 0 deletions examples/passport/wallets-connect-with-nextjs/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
outputDir: 'test-results/',

use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
},

projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
],

webServer: {
command: 'yarn dev',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
},
});
52 changes: 52 additions & 0 deletions examples/passport/wallets-connect-with-nextjs/tests/base.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { test, expect } from '@playwright/test';

test.beforeEach(async ({ page }) => {
await page.goto('/');
});

test.describe('home page', () => {
test('has title, heading and link', async ({ page }) => {
await expect(page).toHaveTitle('Passport Wallets Connect');

await expect(page.getByRole('heading', { name: 'Passport Wallets Connect Examples' })).toBeVisible();

await expect(page.getByRole('link', { name: 'Connect Wallet with EtherJS' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Connect Wallet with EIP1193' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Connect Wallet with Wagmi' })).toBeVisible();
});
});

test.describe('connect wallet with etherjs', () => {
test('has heading, login button and initial account status set correctly', async ({ page }) => {
await page.click('text=Connect Wallet with EtherJS');

await expect(page.getByRole('heading', { name: 'Passport Wallet - Connect with EtherJS' })).toBeVisible();

await expect(page.getByRole('button', { name: 'Passport Login' })).toBeVisible();
await expect(page.getByText('Connected Account:')).toBeVisible();
await expect(page.getByRole('link', { name: 'Return to Examples' })).toBeVisible();
});
});

test.describe('connect wallet with eip1193', () => {
test('has heading, login button and initial account status set correctly', async ({ page }) => {
await page.click('text=Connect Wallet with EIP1193');

await expect(page.getByRole('heading', { name: 'Passport Wallet - Connect with EIP-1193' })).toBeVisible();

await expect(page.getByRole('button', { name: 'Passport Login' })).toBeVisible();
await expect(page.getByText('Connected Account:')).toBeVisible();
await expect(page.getByRole('link', { name: 'Return to Examples' })).toBeVisible();
});
});

test.describe('connect wallet with wagmi', () => {
test('has heading and login button set correctly', async ({ page }) => {
await page.click('text=Connect Wallet with Wagmi');

await expect(page.getByRole('heading', { name: 'Passport Wallet - Connect with Wagmi' })).toBeVisible();

await expect(page.getByRole('button', { name: 'Immutable Passport' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Return to Examples' })).toBeVisible();
});
});
40 changes: 38 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7119,6 +7119,17 @@ __metadata:
languageName: node
linkType: hard

"@playwright/test@npm:^1.45.3":
version: 1.45.3
resolution: "@playwright/test@npm:1.45.3"
dependencies:
playwright: "npm:1.45.3"
bin:
playwright: cli.js
checksum: 10/50b53fdaa495f734ce0dc21a9947513fd40b76672e7d8e4947124bb87bfa9cefdbb5da1ac53054802961dc82a408c5291aa3f7655732cfe8cf9d102dc8b1a501
languageName: node
linkType: hard

"@pmmmwh/react-refresh-webpack-plugin@npm:^0.5.3":
version: 0.5.10
resolution: "@pmmmwh/react-refresh-webpack-plugin@npm:0.5.10"
Expand Down Expand Up @@ -19686,7 +19697,7 @@ __metadata:
languageName: node
linkType: hard

"fsevents@npm:^2.3.2, fsevents@npm:~2.3.2":
"fsevents@npm:2.3.2, fsevents@npm:^2.3.2, fsevents@npm:~2.3.2":
version: 2.3.2
resolution: "fsevents@npm:2.3.2"
dependencies:
Expand All @@ -19706,7 +19717,7 @@ __metadata:
languageName: node
linkType: hard

"fsevents@patch:fsevents@npm%3A^2.3.2#optional!builtin<compat/fsevents>, fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin<compat/fsevents>":
"fsevents@patch:fsevents@npm%3A2.3.2#optional!builtin<compat/fsevents>, fsevents@patch:fsevents@npm%3A^2.3.2#optional!builtin<compat/fsevents>, fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin<compat/fsevents>":
version: 2.3.2
resolution: "fsevents@patch:fsevents@npm%3A2.3.2#optional!builtin<compat/fsevents>::version=2.3.2&hash=df0bf1"
dependencies:
Expand Down Expand Up @@ -26947,6 +26958,30 @@ __metadata:
languageName: node
linkType: hard

"playwright-core@npm:1.45.3":
version: 1.45.3
resolution: "playwright-core@npm:1.45.3"
bin:
playwright-core: cli.js
checksum: 10/6540ae149a8deaceb3dc6f60ea7a7052894aebb651b8c187c97c5532b50ee6c812e7f9644a15ecbfb146d5e7880dbb23010df2bac012493bd75b5624710df6bd
languageName: node
linkType: hard

"playwright@npm:1.45.3":
version: 1.45.3
resolution: "playwright@npm:1.45.3"
dependencies:
fsevents: "npm:2.3.2"
playwright-core: "npm:1.45.3"
dependenciesMeta:
fsevents:
optional: true
bin:
playwright: cli.js
checksum: 10/86959666c68f53b984df3d4a4aa3a7806fff95d5735dc4c16f5cef0889ab07180e1600792f0e66f9b84250931f5971077774cd8f2f077d8b02171f89a33ab588
languageName: node
linkType: hard

"pluralize@npm:^7.0.0":
version: 7.0.0
resolution: "pluralize@npm:7.0.0"
Expand Down Expand Up @@ -33579,6 +33614,7 @@ __metadata:
dependencies:
"@ethersproject/providers": "npm:^5.7.2"
"@imtbl/sdk": "npm:latest"
"@playwright/test": "npm:^1.45.3"
"@tanstack/react-query": "npm:^5.51.11"
"@types/node": "npm:^20"
"@types/react": "npm:^18"
Expand Down

0 comments on commit 991eb66

Please sign in to comment.