diff --git a/laboratory/.github/workflows/playwright.yml b/laboratory/.github/workflows/playwright.yml deleted file mode 100644 index 90b6b700d4..0000000000 --- a/laboratory/.github/workflows/playwright.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Playwright Tests -on: - push: - branches: [ main, master ] - pull_request: - branches: [ main, master ] -jobs: - test: - timeout-minutes: 60 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Install dependencies - run: npm ci - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Run Playwright tests - run: npx playwright test - - uses: actions/upload-artifact@v3 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 diff --git a/laboratory/.gitignore b/laboratory/.gitignore index 4269e15b42..01226ed353 100644 --- a/laboratory/.gitignore +++ b/laboratory/.gitignore @@ -1,9 +1,4 @@ node_modules/ /test-results/ /playwright-report/ -/playwright/.cache/ -/test-results/ -/playwright-report/ -/playwright/.cache/ -/tests/shared/data/ -!/tests/shared/data/extension.txt +/playwright/.cache/ \ No newline at end of file diff --git a/laboratory/package.json b/laboratory/package.json index f6b3380261..a8dabf6758 100644 --- a/laboratory/package.json +++ b/laboratory/package.json @@ -5,6 +5,7 @@ "scripts": { "dev": "rm -rf .next; next dev", "build": "next build", + "playwright:start": "next dev", "playwright:install": "playwright install --with-deps", "playwright:test": "playwright test", "playwright:debug": "playwright test --debug" diff --git a/laboratory/playwright.config.ts b/laboratory/playwright.config.ts index 72c775e27e..fbec84d9e2 100644 --- a/laboratory/playwright.config.ts +++ b/laboratory/playwright.config.ts @@ -41,19 +41,6 @@ export default defineConfig({ name: 'webkit', use: { ...devices['Desktop Safari'] } } - - /* Test against other browsers. */ - /* - * { - * name: 'firefox', - * use: { ...devices['Desktop Firefox'] } - * }, - * - * { - * name: 'webkit', - * use: { ...devices['Desktop Safari'] } - * } - */ /* Test against mobile viewports. */ /* * { @@ -81,8 +68,7 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { - command: 'npm run dev', - url: LOCAL_LAB_URL, - reuseExistingServer: true + command: 'npm run playwright:start', + url: LOCAL_LAB_URL } }) diff --git a/laboratory/tests/basic-tests.spec.ts b/laboratory/tests/basic-tests.spec.ts new file mode 100644 index 0000000000..e8ad258dc6 --- /dev/null +++ b/laboratory/tests/basic-tests.spec.ts @@ -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() + }) +}) diff --git a/laboratory/tests/shared/pages/WalletPage.ts b/laboratory/tests/shared/pages/WalletPage.ts index cfe536ad2a..19139633fe 100644 --- a/laboratory/tests/shared/pages/WalletPage.ts +++ b/laboratory/tests/shared/pages/WalletPage.ts @@ -6,22 +6,22 @@ import { LOCAL_WALLET_URL } from '../constants' export class WalletPage { private readonly baseURL = LOCAL_WALLET_URL - private readonly goToAccounts: Locator + private readonly gotoAccounts: Locator - private readonly goToSessions: Locator + private readonly gotoSessions: Locator - private readonly goToHome: Locator + private readonly gotoHome: Locator - private readonly goToPairings: Locator + private readonly gotoPairings: Locator - private readonly goToSettings: Locator + private readonly gotoSettings: Locator constructor(public readonly page: Page) { - this.goToAccounts = this.page.getByTestId('accounts') - this.goToSessions = this.page.getByTestId('sessions') - this.goToHome = this.page.getByTestId('wc-connect') - this.goToPairings = this.page.getByTestId('pairings') - this.goToSettings = this.page.getByTestId('settings') + this.gotoAccounts = this.page.getByTestId('accounts') + this.gotoSessions = this.page.getByTestId('sessions') + this.gotoHome = this.page.getByTestId('wc-connect') + this.gotoPairings = this.page.getByTestId('pairings') + this.gotoSettings = this.page.getByTestId('settings') } async load() { @@ -29,7 +29,7 @@ export class WalletPage { } async connect() { - await this.goToHome.click() + await this.gotoHome.click() await this.page.getByTestId('uri-input').click() @@ -42,7 +42,7 @@ export class WalletPage { } async disconnect() { - await this.goToSessions.click() + await this.gotoSessions.click() const sessionCard = this.page.getByTestId('session-card').first() await sessionCard.getByTestId('session-icon').click() await this.page.getByTestId('session-delete-button').click() diff --git a/laboratory/tests/shared/validators/ModalValidator.ts b/laboratory/tests/shared/validators/ModalValidator.ts index b647a9414f..9169515cce 100644 --- a/laboratory/tests/shared/validators/ModalValidator.ts +++ b/laboratory/tests/shared/validators/ModalValidator.ts @@ -7,36 +7,36 @@ export class ModalValidator { constructor(public readonly page: Page) {} - async isConnected() { + async expectConnected() { if (this.page.url() !== this.baseURL) { await this.page.goto(this.baseURL) } await expect(this.page.getByTestId('partial-account-address')).toBeVisible() } - async isDisconnected() { + async expectDisconnected() { if (this.page.url() !== this.baseURL) { await this.page.goto(this.baseURL) } await expect(this.page.getByTestId('partial-account-address')).not.toBeVisible() } - async acceptedSign() { + async expectAcceptedSign() { await expect(this.page.getByText('Sign Message')).toBeVisible() await expect(this.page.getByText('0x')).toBeVisible() } - async rejectedSign() { + async expectRejectedSign() { await expect(this.page.getByText('Sign Message')).toBeVisible() await expect(this.page.getByText(/User rejected/u)).toBeVisible() } - async acceptedSignTyped() { + async expectAcceptedSignTyped() { await expect(this.page.getByText('Sign Typed Data')).toBeVisible() await expect(this.page.getByText('0x')).toBeVisible() } - async rejectedSignTyped() { + async expectRejectedSignTyped() { await expect(this.page.getByText('Sign Typed Data')).toBeVisible() await expect(this.page.getByText(/User rejected/u)).toBeVisible() } diff --git a/laboratory/tests/shared/validators/WalletValidator.ts b/laboratory/tests/shared/validators/WalletValidator.ts index a9230607f0..1f8d7246fc 100644 --- a/laboratory/tests/shared/validators/WalletValidator.ts +++ b/laboratory/tests/shared/validators/WalletValidator.ts @@ -5,42 +5,42 @@ import { LOCAL_WALLET_URL } from '../constants' export class WalletValidator { private readonly baseURL = LOCAL_WALLET_URL - private readonly goToAccounts: Locator + private readonly gotoAccounts: Locator - private readonly goToSessions: Locator + private readonly gotoSessions: Locator - private readonly goToHome: Locator + private readonly gotoHome: Locator - private readonly goToPairings: Locator + private readonly gotoPairings: Locator - private readonly goToSettings: Locator + private readonly gotoSettings: Locator constructor(public readonly page: Page) { - this.goToAccounts = this.page.getByTestId('accounts') - this.goToSessions = this.page.getByTestId('sessions') - this.goToHome = this.page.getByTestId('wc-connect') - this.goToPairings = this.page.getByTestId('pairings') - this.goToSettings = this.page.getByTestId('settings') + this.gotoAccounts = this.page.getByTestId('accounts') + this.gotoSessions = this.page.getByTestId('sessions') + this.gotoHome = this.page.getByTestId('wc-connect') + this.gotoPairings = this.page.getByTestId('pairings') + this.gotoSettings = this.page.getByTestId('settings') } - async isConnected() { + async expectConnected() { await this.page.reload() - await this.goToSessions.click() + await this.gotoSessions.click() await expect(this.page.getByTestId('session-card')).toBeVisible() } - async isDisconnected() { + async expectDisconnected() { await this.page.reload() - await this.goToSessions.click() + await this.gotoSessions.click() await expect(this.page.getByTestId('session-card')).not.toBeVisible() } - async recievedSign({ chainName = 'Ethereum' }) { + async expectRecievedSign({ chainName = 'Ethereum' }) { await expect(this.page.getByText('Sign Message')).toBeVisible() await expect(this.page.getByTestId('request-details-chain')).toHaveText(chainName) } - async recievedSignTyped({ chainName = 'Ethereum' }) { + async expectRecievedSignTyped({ chainName = 'Ethereum' }) { await expect(this.page.getByText('Sign Typed Data')).toBeVisible() await expect(this.page.getByTestId('request-details-chain')).toHaveText(chainName) } diff --git a/laboratory/tests/w3m-wallet.spec.ts b/laboratory/tests/w3m-wallet.spec.ts index 7f3f3ff3dc..6d836c4df2 100644 --- a/laboratory/tests/w3m-wallet.spec.ts +++ b/laboratory/tests/w3m-wallet.spec.ts @@ -7,8 +7,8 @@ testMW.describe('W3M using wallet web-example', () => { await walletPage.connect() await walletPage.handleSessionProposal(DEFAULT_SESSION_PARAMS) - await modalValidator.isConnected() - await walletValidator.isConnected() + await modalValidator.expectConnected() + await walletValidator.expectConnected() }) testMW('Should be able to connect', ({ modalPage, walletPage }) => { @@ -20,16 +20,16 @@ testMW.describe('W3M using wallet web-example', () => { 'Should send disconnect to wallet', async ({ modalPage, modalValidator, walletValidator }) => { await modalPage.disconnect() - await modalValidator.isDisconnected() - await walletValidator.isDisconnected() + await modalValidator.expectDisconnected() + await walletValidator.expectDisconnected() } ) testMW( 'Should recieve disconnect from a wallet', async ({ walletPage, modalValidator, walletValidator }) => { await walletPage.disconnect() - await walletValidator.isDisconnected() - await modalValidator.isDisconnected() + await walletValidator.expectDisconnected() + await modalValidator.expectDisconnected() } ) @@ -38,10 +38,10 @@ testMW.describe('W3M using wallet web-example', () => { async ({ modalPage, walletPage, modalValidator, walletValidator }) => { await modalPage.sign() - await walletValidator.recievedSign({}) + await walletValidator.expectRecievedSign({}) await walletPage.handleRequest({ accept: true }) - await modalValidator.acceptedSign() + await modalValidator.expectAcceptedSign() } ) @@ -50,10 +50,10 @@ testMW.describe('W3M using wallet web-example', () => { async ({ modalPage, walletPage, modalValidator, walletValidator }) => { await modalPage.sign() - await walletValidator.recievedSign({}) + await walletValidator.expectRecievedSign({}) await walletPage.handleRequest({ accept: false }) - await modalValidator.rejectedSign() + await modalValidator.expectRejectedSign() } ) @@ -62,10 +62,10 @@ testMW.describe('W3M using wallet web-example', () => { async ({ modalPage, walletPage, modalValidator, walletValidator }) => { await modalPage.signTyped() - await walletValidator.recievedSignTyped({}) + await walletValidator.expectRecievedSignTyped({}) await walletPage.handleRequest({ accept: true }) - await modalValidator.acceptedSignTyped() + await modalValidator.expectAcceptedSignTyped() } ) @@ -74,10 +74,10 @@ testMW.describe('W3M using wallet web-example', () => { async ({ modalPage, walletPage, modalValidator, walletValidator }) => { await modalPage.signTyped() - await walletValidator.recievedSignTyped({}) + await walletValidator.expectRecievedSignTyped({}) await walletPage.handleRequest({ accept: false }) - await modalValidator.acceptedSignTyped() + await modalValidator.expectAcceptedSignTyped() } ) @@ -89,10 +89,10 @@ testMW.describe('W3M using wallet web-example', () => { await modalPage.sign() - await walletValidator.recievedSign({ chainName: 'Polygon' }) + await walletValidator.expectRecievedSign({ chainName: 'Polygon' }) await walletPage.handleRequest({ accept: true }) - await modalValidator.acceptedSign() + await modalValidator.expectAcceptedSign() } ) @@ -104,10 +104,10 @@ testMW.describe('W3M using wallet web-example', () => { await modalPage.signTyped() - await walletValidator.recievedSignTyped({ chainName: 'Polygon' }) + await walletValidator.expectRecievedSignTyped({ chainName: 'Polygon' }) await walletPage.handleRequest({ accept: true }) - await modalValidator.acceptedSignTyped() + await modalValidator.expectAcceptedSignTyped() } ) })