-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
288 additions
and
34 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: playwright-test | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
playwright-test: | ||
runs-on: ubuntu-latest | ||
services: | ||
sapphire-localnet-ci: | ||
image: ghcr.io/oasisprotocol/sapphire-localnet:latest | ||
ports: | ||
- 8545:8545 | ||
- 8546:8546 | ||
env: | ||
OASIS_DEPOSIT_BINARY: /oasis-deposit -test-mnemonic -n 5 | ||
options: >- | ||
--rm | ||
--health-cmd="test -f /CONTAINER_READY" | ||
--health-start-period=90s | ||
env: | ||
SAPPHIRE_LOCALNET_HTTP_PROXY_PORT: 3001 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Install jq | ||
run: sudo apt install -y jq | ||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
id: pnpm-install | ||
with: | ||
version: 8 | ||
run_install: false | ||
- name: Get pnpm store directory | ||
id: pnpm-cache | ||
run: | | ||
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT | ||
- uses: actions/cache@v4 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Build JS client | ||
run: make -C clients/js build | ||
- name: Build Integrations | ||
run: make -C integrations build | ||
- uses: JarvusInnovations/background-action@v1 | ||
name: RPC proxy will error if non-encrypted calls are made | ||
with: | ||
run: pnpm run proxy & | ||
wait-on: http://127.0.0.1:${{ env.SAPPHIRE_LOCALNET_HTTP_PROXY_PORT }} | ||
tail: true | ||
log-output-resume: true | ||
wait-for: 31sec | ||
log-output: true | ||
log-output-if: true | ||
working-directory: clients/js | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Set up playwright tests | ||
run: npx playwright install --with-deps | ||
working-directory: examples/wagmi-v2 | ||
- name: Set up playwright tests | ||
run: npx install @playwright/test | ||
working-directory: examples/wagmi-v2 | ||
- name: Run playwright tests | ||
working-directory: examples/wagmi-v2 | ||
run: npx playwright test test/e2e.spec.ts | ||
- name: 'Upload playwright test-results' | ||
if: ${{ failure() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: playwright-test-results | ||
path: playwright/test-results | ||
retention-days: 5 |
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,46 @@ | ||
import { defineConfig, devices } from "@playwright/test"; | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
timeout: 2 * 60 * 1000, | ||
testDir: "./test/e2e/", | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: [["html"], ["list", { printSteps: true }]], | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
baseURL: process.env.FRONTEND_URL || "http://localhost:3000/", | ||
trace: "on-first-retry", | ||
headless: false, | ||
screenshot: { | ||
mode: "only-on-failure", | ||
fullPage: true, | ||
}, | ||
}, | ||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'main', | ||
testDir: './test/', | ||
use: { | ||
...devices['Desktop Chrome'], | ||
}, | ||
}, | ||
], | ||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: 'pnpm run start:server', | ||
url: 'http://localhost:3000', | ||
reuseExistingServer: !process.env.CI, | ||
// stdout: 'ignore', | ||
stderr: 'pipe', | ||
}, | ||
}); |
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,58 @@ | ||
import { BrowserContext, expect, test as baseTest } from "@playwright/test"; | ||
import dappwright, { Dappwright, MetaMaskWallet } from "@tenkeylabs/dappwright"; | ||
|
||
export const test = baseTest.extend<{ | ||
context: BrowserContext; | ||
wallet: Dappwright; | ||
}>({ | ||
context: async ({}, use) => { | ||
// Launch context with extension | ||
const [wallet, _, context] = await dappwright.bootstrap("", { | ||
wallet: "metamask", | ||
version: MetaMaskWallet.recommendedVersion, | ||
seed: "test test test test test test test test test test test junk", // Hardhat's default https://hardhat.org/hardhat-network/docs/reference#accounts | ||
headless: false, | ||
}); | ||
|
||
// Add Hardhat as a custom network | ||
await wallet.addNetwork({ | ||
networkName: "Sapphire Localnet", | ||
rpc: "http://localhost:8545", | ||
chainId: 23293, | ||
symbol: "ROSE", | ||
}); | ||
|
||
await use(context); | ||
}, | ||
|
||
wallet: async ({ context }, use) => { | ||
const metamask = await dappwright.getWallet("metamask", context); | ||
|
||
await use(metamask); | ||
}, | ||
}); | ||
|
||
test.beforeEach(async ({ wallet, page }) => { | ||
await wallet.switchAccount(1); | ||
await page.bringToFront(); | ||
}); | ||
|
||
test("deploy contract and send encrypted transaction", async ({ wallet, page }) => { | ||
await page.goto("http://localhost:3000"); | ||
|
||
await page.getByText("Injected (Sapphire)").click(); | ||
await wallet.approve(); | ||
await expect(page.getByText("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266")).toBeVisible(); | ||
|
||
await page.getByText("Deploy").click(); | ||
await wallet.confirmTransaction(); | ||
await expect(page.getByText("Contract:")).toBeVisible(); | ||
|
||
await page.getByText("Write").click(); | ||
await wallet.confirmTransaction(); | ||
await expect(page.getByText("Contract:")).toBeVisible(); | ||
await expect(page.getByTestId('is-write-enveloped')).toHaveText('encrypted'); | ||
|
||
await page.getByText("Read").click(); | ||
await expect(page.getByTestId("read-result")).not.toBeEmpty(); | ||
}); |
Oops, something went wrong.