|
| 1 | +import { Page, expect, test } from '@playwright/test' |
| 2 | +import { Transaction } from '../../src/oasis-nexus/api' |
| 3 | + |
| 4 | +async function setup(page: Page) { |
| 5 | + await page.route( |
| 6 | + 'https://api.coingecko.com/api/v3/simple/price?ids=oasis-network&vs_currencies=usd', |
| 7 | + route => { |
| 8 | + // Don't respond |
| 9 | + }, |
| 10 | + ) |
| 11 | + await page.route( |
| 12 | + url => url.href.includes('.oasis.io/v1/'), |
| 13 | + route => { |
| 14 | + // Don't respond |
| 15 | + }, |
| 16 | + ) |
| 17 | + await page.route( |
| 18 | + '**/v1/consensus/transactions/10dc8edd24ae89b264a295a046d9ac9b99a59d81acf3b0394bac309c09bdd7c7', |
| 19 | + route => { |
| 20 | + route.fulfill({ |
| 21 | + body: JSON.stringify({ |
| 22 | + is_total_count_clipped: false, |
| 23 | + total_count: 1, |
| 24 | + transactions: [ |
| 25 | + { |
| 26 | + block: 10759920, |
| 27 | + body: { |
| 28 | + amount_change: '1000000000', |
| 29 | + beneficiary: 'oasis1qqczuf3x6glkgjuf0xgtcpjjw95r3crf7y2323xd', |
| 30 | + }, |
| 31 | + fee: '0', |
| 32 | + gas_limit: '1288', |
| 33 | + hash: '10dc8edd24ae89b264a295a046d9ac9b99a59d81acf3b0394bac309c09bdd7c7', |
| 34 | + index: 0, |
| 35 | + method: 'staking.Allow', |
| 36 | + nonce: 41, |
| 37 | + sender: 'oasis1qrtyn2q78jv6plrmexrsrv4dh89wv4n49udtg2km', |
| 38 | + success: true, |
| 39 | + timestamp: '2022-07-20T17:20:45Z', |
| 40 | + } satisfies Partial<Transaction>, |
| 41 | + ], |
| 42 | + }), |
| 43 | + }) |
| 44 | + }, |
| 45 | + ) |
| 46 | + await page.route( |
| 47 | + '**/v1/consensus/transactions/4d4903206ee68d5c60ea9b26f4a7b218b263e66e032772f2faa61a2bf7d27b2b', |
| 48 | + route => { |
| 49 | + route.fulfill({ |
| 50 | + body: JSON.stringify({ |
| 51 | + is_total_count_clipped: false, |
| 52 | + total_count: 1, |
| 53 | + transactions: [ |
| 54 | + { |
| 55 | + block: 20780944, |
| 56 | + body: { |
| 57 | + amount_change: '5000000000000000', |
| 58 | + beneficiary: 'oasis1qrd3mnzhhgst26hsp96uf45yhq6zlax0cuzdgcfc', |
| 59 | + negative: true, |
| 60 | + }, |
| 61 | + fee: '0', |
| 62 | + gas_limit: '1290', |
| 63 | + hash: '4d4903206ee68d5c60ea9b26f4a7b218b263e66e032772f2faa61a2bf7d27b2b', |
| 64 | + index: 24, |
| 65 | + method: 'staking.Allow', |
| 66 | + nonce: 6, |
| 67 | + sender: 'oasis1qppz78n4lpnw9knz7d7jz7vvjrt7qd2c6ypsa7me', |
| 68 | + success: true, |
| 69 | + timestamp: '2024-08-28T02:00:29Z', |
| 70 | + } satisfies Partial<Transaction>, |
| 71 | + ], |
| 72 | + }), |
| 73 | + }) |
| 74 | + }, |
| 75 | + ) |
| 76 | +} |
| 77 | + |
| 78 | +test('Allowance transaction should display relative amount', async ({ page }) => { |
| 79 | + await setup(page) |
| 80 | + await page.goto( |
| 81 | + 'http://localhost:1234/testnet/consensus/tx/10dc8edd24ae89b264a295a046d9ac9b99a59d81acf3b0394bac309c09bdd7c7', |
| 82 | + ) |
| 83 | + await expect(page.getByText('+1 TEST')).toBeVisible() |
| 84 | +}) |
| 85 | + |
| 86 | +test('Allowance transaction should display negative amount', async ({ page }) => { |
| 87 | + await setup(page) |
| 88 | + await page.goto( |
| 89 | + 'http://localhost:1234/mainnet/consensus/tx/4d4903206ee68d5c60ea9b26f4a7b218b263e66e032772f2faa61a2bf7d27b2b', |
| 90 | + ) |
| 91 | + await expect(page.getByText('-5,000,000 ROSE')).toBeVisible() |
| 92 | +}) |
0 commit comments