Skip to content

Commit

Permalink
playwright tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaw3d committed Aug 2, 2023
1 parent 9faf925 commit 01b82a1
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 32 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/ci-playwright-preciseNumberFormat.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/ci-playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# NOTE: This name appears in GitHub's Checks API and in workflow's status badge.
name: ci-playwright

# Trigger the workflow when:
on:
# A push occurs to one of the matched branches.
push:
branches: [master]
# Or when a pull request event occurs for a pull request against one of the
# matched branches.
pull_request:
branches: [master]

jobs:
playwright:
# NOTE: This name appears in GitHub's Checks API.
name: playwright
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js 20
uses: actions/setup-node@v3
with:
node-version: '20.x'
cache: yarn
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run dev server
run: yarn start &
- name: Install playwright
run: yarn install --frozen-lockfile
working-directory: playwright
- name: Install playwright dependencies
run: yarn playwright install --with-deps
working-directory: playwright
- name: Run playwright tests
run: yarn playwright test --browser all
working-directory: playwright
6 changes: 5 additions & 1 deletion playwright/package.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{}
{
"devDependencies": {
"@playwright/test": "^1.36.2"
}
}
47 changes: 47 additions & 0 deletions playwright/tests/getPreciseNumberFormat.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { expect, test } from '@playwright/test'
import { RuntimeAccount } from '../../src/oasis-nexus/api'

test('getPreciseNumberFormat', async ({ page }) => {
await page.route(
'https://api.coingecko.com/api/v3/simple/price?ids=oasis-network&vs_currencies=usd',
route => {
// Don't respond
},
)
await page.route('**/v1/', route => {
// Don't respond
})
await page.route('**/v1/sapphire/status', route => {
// Don't respond
})

await page.route('**/v1/sapphire/accounts/oasis1qq2v39p9fqk997vk6742axrzqyu9v2ncyuqt8uek', route => {
route.fulfill({
body: JSON.stringify({
address: 'oasis1qq2v39p9fqk997vk6742axrzqyu9v2ncyuqt8uek',
address_preimage: {
address_data: 'AAAAAAAAAAAAAAAAAAAAAAAAAAA=',
context: 'oasis-runtime-sdk/address: secp256k1eth',
context_version: 0,
},
balances: [],
evm_balances: [],
stats: {
num_txns: 0,
total_received: '111222333444555666777888999111222333444555666',
total_sent: '0',
},
} satisfies Partial<RuntimeAccount>),
})
})

await page.goto(
'http://localhost:1234/mainnet/sapphire/address/0x0000000000000000000000000000000000000000/tokens/erc-20#tokens',
)
await expect(
page
.getByText('111,222,333,444,555,666,777,888,999.111222333444555666')
// Expect precise fallback when browser doesn't support precise formatting
.or(page.getByText('111222333444555666777888999.111222333444555666')),
).toBeVisible()
})
10 changes: 0 additions & 10 deletions playwright/tests/preciseNumberFormat.spec.ts

This file was deleted.

28 changes: 28 additions & 0 deletions playwright/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@playwright/test@^1.36.2":
version "1.36.2"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.36.2.tgz#9edd68a02b0929c5d78d9479a654ceb981dfb592"
integrity sha512-2rVZeyPRjxfPH6J0oGJqE8YxiM1IBRyM8hyrXYK7eSiAqmbNhxwcLa7dZ7fy9Kj26V7FYia5fh9XJRq4Dqme+g==
dependencies:
"@types/node" "*"
playwright-core "1.36.2"
optionalDependencies:
fsevents "2.3.2"

"@types/node@*":
version "20.4.5"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.5.tgz#9dc0a5cb1ccce4f7a731660935ab70b9c00a5d69"
integrity sha512-rt40Nk13II9JwQBdeYqmbn2Q6IVTA5uPhvSO+JVqdXw/6/4glI6oR9ezty/A9Hg5u7JH4OmYmuQ+XvjKm0Datg==

[email protected]:
version "2.3.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

[email protected]:
version "1.36.2"
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.36.2.tgz#32382f2d96764c24c65a86ea336cf79721c2e50e"
integrity sha512-sQYZt31dwkqxOrP7xy2ggDfEzUxM1lodjhsQ3NMMv5uGTRDsLxU0e4xf4wwMkF2gplIxf17QMBCodSFgm6bFVQ==

0 comments on commit 01b82a1

Please sign in to comment.