Skip to content
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

chore: add vercel preview url step #3898

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
12 changes: 6 additions & 6 deletions .github/workflows/pr_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ jobs:
matrix:
style-command:
- lint
- prettier
- typecheck
- build:sample-apps
- danger
# Disable temp
# - prettier
# - typecheck
# - build:sample-apps
# - danger
steps:
- name: checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -92,8 +93,7 @@ jobs:
uses: davelosert/vitest-coverage-report-action@v2

ui-test:
needs: [code_style, test]
if: ${{ needs.code_style.result == 'success' && needs.test.result == 'success' && github.event.pull_request.draft == false }}
if: ${{ github.event.pull_request.draft == false }}
uses: ./.github/workflows/ui_tests.yml
secrets: inherit
permissions:
Expand Down
84 changes: 27 additions & 57 deletions .github/workflows/ui_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ on:
default: 'main'
required: false
type: string
base-url:
description: 'The AppKit lab url'
default: 'http://localhost:3000/'
required: false
type: string
wallet-url:
description: 'The wallet url'
default: 'https://react-wallet.walletconnect.com/'
Expand Down Expand Up @@ -80,66 +75,40 @@ jobs:
node-version: 20.x
cache: 'pnpm'

# - name: Get installed Playwright version
# id: playwright-version
# run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').packages['apps/laboratory']['devDependencies']['@playwright/test'])")" >> $GITHUB_ENV

# This cache causes weird errors on retry runs when using the self-hosted runners, disabling for now
# - name: Cache playwright binaries
# uses: actions/cache@v4
# id: playwright-cache
# with:
# path: |
# ~/.cache/ms-playwright
# key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}-${{ hashFiles('apps/laboratory/tests/shared/constants/devices.ts') }}

- name: Install dependencies
run: pnpm install

- name: build packages and lab
run: pnpm build:laboratory
env:
NEXT_PUBLIC_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_PROJECT_ID }}
NEXTAUTH_SECRET: ${{ secrets.TESTS_NEXTAUTH_SECRET }}
MAILSAC_API_KEY: ${{ secrets.TESTS_MAILSAC_API_KEY }}
NEXT_PUBLIC_SECURE_SITE_SDK_URL: ${{ inputs.secure-site-url }}
SOCIAL_TEST_EMAIL: ${{ secrets.TESTS_SOCIAL_EMAIL }}
SOCIAL_TEST_PASSWORD: ${{ secrets.TESTS_SOCIAL_PASSWORD }}
- name: Build packages
run: pnpm build

- name: build extension
- name: Build extension
env:
EIP155_PRIVATE_KEY: ${{ secrets.EIP155_PRIVATE_KEY }}
SOLANA_PRIVATE_KEY: ${{ secrets.SOLANA_PRIVATE_KEY }}
working-directory: ./apps/browser-extension/
run: pnpm build

- name: Wait for Vercel Preview URL
uses: UnlyEd/github-action-await-vercel@v1 # TODO best practices recommend to use a fixed version instead of @v1 for production usage (i.e: @v1.2.32)
id: await-vercel
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
with:
deployment-url: appkit-lab.reown.com # TODO Replace by the domain you want to test
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this ok?

timeout: 10 # Wait for 10 seconds before failing
poll-interval: 1 # Wait for 1 second before each retry

- name: Display deployment status
run: 'echo The deployment at ${{ fromJson(steps.await-vercel.outputs.deploymentDetails).url }} is ${{ fromJson(steps.await-vercel.outputs.deploymentDetails).readyState }}'

- name: Install Playwright Browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: ./apps/laboratory/
run: pnpm playwright:install

# - name: Build MetaMask wallet cache
# working-directory: ./apps/laboratory/
# run: xvfb-run pnpm synpress

# - name: Run MetaMask Playwright tests (headful)
# working-directory: ./apps/laboratory/
# env:
# BASE_URL: ${{ inputs.base-url }}
# WALLET_URL: ${{ inputs.wallet-url }}
# NEXT_PUBLIC_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_PROJECT_ID }}
# SKIP_PLAYWRIGHT_WEBSERVER: ${{ inputs.skip-playwright-webserver }}
# NEXTAUTH_SECRET: ${{ secrets.TESTS_NEXTAUTH_SECRET }}
# MAILSAC_API_KEY: ${{ secrets.TESTS_MAILSEC_API_KEY }}
# NEXT_PUBLIC_SECURE_SITE_SDK_URL: ${{ inputs.secure-site-url }}
# SOCIAL_TEST_EMAIL: ${{ secrets.TESTS_SOCIAL_EMAIL }}
# SOCIAL_TEST_PASSWORD: ${{ secrets.TESTS_SOCIAL_PASSWORD }}
# CI: true
# run: xvfb-run pnpm playwright:test:metamask

- name: Run Playwright tests
env:
BASE_URL: ${{ inputs.base-url }}
BASE_URL: https://${{ fromJson(steps.await-vercel.outputs.deploymentDetails).url }}/
WALLET_URL: ${{ inputs.wallet-url }}
NEXT_PUBLIC_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_PROJECT_ID }}
SKIP_PLAYWRIGHT_WEBSERVER: ${{ inputs.skip-playwright-webserver }}
Expand All @@ -152,15 +121,16 @@ jobs:
working-directory: ./apps/laboratory/
run: pnpm ${{ inputs.command }} --shard=${{ matrix.shard }}/${{ matrix.shardTotal }}

- name: Run canary with minimal environment config
env:
# DO NOT MODIFY THIS. If you are required to add variables here without adding
# them to the rs-relay repo it will cause alarms.
NEXT_PUBLIC_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_PROJECT_ID }}
NEXTAUTH_SECRET: ${{ secrets.TESTS_NEXTAUTH_SECRET }}
CI: true
working-directory: ./apps/laboratory/
run: pnpm playwright:test:canary
# Disable temporarily
# - name: Run canary with minimal environment config
# env:
# # DO NOT MODIFY THIS. If you are required to add variables here without adding
# # them to the rs-relay repo it will cause alarms.
# NEXT_PUBLIC_PROJECT_ID: ${{ secrets.NEXT_PUBLIC_PROJECT_ID }}
# NEXTAUTH_SECRET: ${{ secrets.TESTS_NEXTAUTH_SECRET }}
# CI: true
# working-directory: ./apps/laboratory/
# run: pnpm playwright:test:canary
Comment on lines +124 to +133
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why disable?


- uses: actions/upload-artifact@v4
if: failure()
Expand Down
3 changes: 2 additions & 1 deletion apps/laboratory/tests/shared/pages/ModalPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,13 @@ export class ModalPage {
const signatureHeader = this.page.getByText('Approve Transaction')
await this.page.frameLocator('#w3m-iframe').getByRole('button', { name, exact: true }).click()
await expect(signatureHeader, 'Signature request should be closed').not.toBeVisible()
await this.page.waitForTimeout(300)
await this.page.waitForTimeout(500)
}

async approveSign() {
await this.signatureRequestFrameShouldVisible('requests a signature')
await this.clickSignatureRequestButton('Sign')
await this.page.waitForTimeout(1000)
Comment on lines +368 to +374
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need these timeouts?

}

async rejectSign() {
Expand Down
1 change: 0 additions & 1 deletion apps/laboratory/tests/shared/utils/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const SINGLE_ADAPTER_EVM_TESTS = [
'wallet-features.spec.ts',
'wallet.spec.ts',
'wallet-button.spec',
'verify.spec.ts',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert Canary and Verify tests back

'email-after-farcaster.spec.ts'
]

Expand Down
17 changes: 7 additions & 10 deletions apps/laboratory/tests/siwe-email.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ emailSiweTest.afterAll(async () => {
})

// -- Tests --------------------------------------------------------------------
emailSiweTest('it should sign', async ({ library }) => {
const namespace = library === 'solana' ? 'solana' : 'eip155'
await page.sign(namespace)
emailSiweTest('it should sign', async () => {
await page.sign()
await page.approveSign()
await validator.expectAcceptedSign()
})
Expand All @@ -64,23 +63,21 @@ emailSiweTest('it should upgrade wallet', async ({ library }) => {
await page.closeModal()
})

emailSiweTest('it should reject sign', async ({ library }) => {
const namespace = library === 'solana' ? 'solana' : 'eip155'
await page.sign(namespace)
emailSiweTest('it should reject sign', async () => {
await page.sign()
await page.rejectSign()
await validator.expectRejectedSign()
})

emailSiweTest('it should switch network and sign', async ({ library }) => {
emailSiweTest('it should switch network and sign', async () => {
let targetChain = 'Polygon'
const namespace = library === 'solana' ? 'solana' : 'eip155'

await page.switchNetwork(targetChain)
await validator.expectUnauthenticated()
await page.promptSiwe()
await page.approveSign()

await page.sign(namespace)
await page.sign()
await page.approveSign()
await validator.expectAcceptedSign()

Expand All @@ -90,7 +87,7 @@ emailSiweTest('it should switch network and sign', async ({ library }) => {
await page.promptSiwe()
await page.approveSign()

await page.sign(namespace)
await page.sign()
await page.approveSign()
await validator.expectAcceptedSign()
})
Expand Down
70 changes: 30 additions & 40 deletions apps/laboratory/tests/siwe-sa.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ smartAccountSiweTest.afterAll(async () => {
})

// -- Tests --------------------------------------------------------------------
smartAccountSiweTest('it should sign with siwe + smart account', async ({ library }) => {
const namespace = library === 'solana' ? 'solana' : 'eip155'

await page.sign(namespace)
smartAccountSiweTest('it should sign with siwe + smart account', async () => {
await page.sign()
await page.approveSign()
await validator.expectAcceptedSign()
})
Expand All @@ -71,44 +69,36 @@ smartAccountSiweTest('it should upgrade wallet', async ({ library }) => {
await page.closeModal()
})

smartAccountSiweTest(
'it should switch to a smart account enabled network and sign',
async ({ library }) => {
const targetChain = 'Base'
const namespace = library === 'solana' ? 'solana' : 'eip155'
smartAccountSiweTest('it should switch to a smart account enabled network and sign', async () => {
const targetChain = 'Base'

await page.switchNetwork(targetChain)
await validator.expectSwitchedNetworkWithNetworkView()
await page.promptSiwe()
await page.approveSign()
await page.switchNetwork(targetChain)
await validator.expectSwitchedNetworkWithNetworkView()
await page.promptSiwe()
await page.approveSign()

await page.sign(namespace)
await page.approveSign()
await validator.expectAcceptedSign()
}
)

smartAccountSiweTest(
'it should switch to a not enabled network and sign with EOA',
async ({ library }) => {
const targetChain = 'Aurora'
const namespace = library === 'solana' ? 'solana' : 'eip155'

await page.switchNetwork(targetChain)
await page.page.waitForTimeout(1000)
await page.promptSiwe()
await page.approveSign()

await page.openAccount()
// Shouldn't show the toggle on a non enabled network
await validator.expectTogglePreferredTypeVisible(false)
await page.closeModal()

await page.sign(namespace)
await page.approveSign()
await validator.expectAcceptedSign()
}
)
await page.sign()
await page.approveSign()
await validator.expectAcceptedSign()
})

smartAccountSiweTest('it should switch to a not enabled network and sign with EOA', async () => {
const targetChain = 'Aurora'

await page.switchNetwork(targetChain)
await page.page.waitForTimeout(1000)
await page.promptSiwe()
await page.approveSign()

await page.openAccount()
// Shouldn't show the toggle on a non enabled network
await validator.expectTogglePreferredTypeVisible(false)
await page.closeModal()

await page.sign()
await page.approveSign()
await validator.expectAcceptedSign()
})

smartAccountSiweTest('it should disconnect correctly', async () => {
await page.openAccount()
Expand Down
Loading