mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
test fixes
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { compile } from 'path-to-regexp';
|
||||
|
||||
import type { ResourceName } from 'lib/api/resources';
|
||||
import { RESOURCES } from 'lib/api/resources';
|
||||
|
||||
export default function buildApiUrl(resourceName: ResourceName, pathParams?: Record<string, string>) {
|
||||
const resource = RESOURCES[resourceName];
|
||||
return compile('/proxy/poa/core' + resource.path)(pathParams);
|
||||
}
|
||||
@@ -4,11 +4,12 @@ import React from 'react';
|
||||
|
||||
import * as internalTxsMock from 'mocks/txs/internalTxs';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import AddressInternalTxs from './AddressInternalTxs';
|
||||
|
||||
const ADDRESS_HASH = internalTxsMock.base.from.hash;
|
||||
const API_URL_TX_INTERNALS = `/node-api/addresses/${ ADDRESS_HASH }/internal-transactions`;
|
||||
const API_URL_TX_INTERNALS = buildApiUrl('address_internal_txs', { id: ADDRESS_HASH });
|
||||
const hooksConfig = {
|
||||
router: {
|
||||
query: { id: ADDRESS_HASH },
|
||||
@@ -29,7 +30,5 @@ test('base view +@mobile', async({ mount, page }) => {
|
||||
{ hooksConfig },
|
||||
);
|
||||
|
||||
await page.waitForResponse(API_URL_TX_INTERNALS),
|
||||
|
||||
await expect(component).toHaveScreenshot();
|
||||
});
|
||||
|
||||
@@ -4,10 +4,11 @@ import React from 'react';
|
||||
|
||||
import { base as txMock } from 'mocks/txs/tx';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import AddressTxs from './AddressTxs';
|
||||
|
||||
const API_URL = '/node-api/addresses/0xd789a607CEac2f0E14867de4EB15b15C9FFB5859/transactions';
|
||||
const API_URL = buildApiUrl('address_txs', { id: '0xd789a607CEac2f0E14867de4EB15b15C9FFB5859' });
|
||||
|
||||
const hooksConfig = {
|
||||
router: {
|
||||
@@ -29,7 +30,5 @@ test('address txs +@mobile +@desktop-xl', async({ mount, page }) => {
|
||||
{ hooksConfig },
|
||||
);
|
||||
|
||||
await page.waitForResponse(API_URL),
|
||||
|
||||
await expect(component).toHaveScreenshot();
|
||||
});
|
||||
|
||||
@@ -6,13 +6,14 @@ import * as coinBalanceMock from 'mocks/address/coinBalanceHistory';
|
||||
import * as tokenBalanceMock from 'mocks/address/tokenBalance';
|
||||
import * as socketServer from 'playwright/fixtures/socketServer';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
import MockAddressPage from 'ui/address/testUtils/MockAddressPage';
|
||||
|
||||
import TokenSelect from './TokenSelect';
|
||||
|
||||
const ASSET_URL = 'https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/poa/assets/0xb2a90505dc6680a7a695f7975d0d32EeF610f456/logo.png';
|
||||
const TOKENS_API_URL = '/node-api/addresses/1/token-balances';
|
||||
const ADDRESS_API_URL = '/node-api/addresses/1';
|
||||
const TOKENS_API_URL = buildApiUrl('address_token_balances', { id: '1' });
|
||||
const ADDRESS_API_URL = buildApiUrl('address', { id: '1' });
|
||||
const hooksConfig = {
|
||||
router: {
|
||||
query: { id: '1' },
|
||||
|
||||
@@ -3,13 +3,14 @@ import React from 'react';
|
||||
|
||||
import * as blockMock from 'mocks/blocks/block';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import BlockDetails from './BlockDetails';
|
||||
|
||||
const API_URL = '/node-api/blocks/1';
|
||||
const API_URL = buildApiUrl('block', { id: '1' });
|
||||
const hooksConfig = {
|
||||
router: {
|
||||
query: { id: 1 },
|
||||
query: { id: '1' },
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -5,11 +5,12 @@ import * as blockMock from 'mocks/blocks/block';
|
||||
import * as statsMock from 'mocks/stats/index';
|
||||
import * as socketServer from 'playwright/fixtures/socketServer';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import LatestBlocks from './LatestBlocks';
|
||||
|
||||
const STATS_API_URL = '/node-api/home-stats';
|
||||
const BLOCKS_API_URL = '/node-api/index/blocks';
|
||||
const STATS_API_URL = buildApiUrl('homepage_stats');
|
||||
const BLOCKS_API_URL = buildApiUrl('blocks');
|
||||
|
||||
export const test = base.extend<socketServer.SocketServerFixture>({
|
||||
createSocket: socketServer.createSocket,
|
||||
|
||||
@@ -6,6 +6,7 @@ import * as statsMock from 'mocks/stats/index';
|
||||
import * as txMock from 'mocks/txs/tx';
|
||||
import * as socketServer from 'playwright/fixtures/socketServer';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import LatestTxs from './LatestTxs';
|
||||
|
||||
@@ -14,11 +15,11 @@ export const test = base.extend<socketServer.SocketServerFixture>({
|
||||
});
|
||||
|
||||
test('default view +@mobile +@dark-mode', async({ mount, page }) => {
|
||||
await page.route('/node-api/home-stats', (route) => route.fulfill({
|
||||
await page.route(buildApiUrl('homepage_stats'), (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify(statsMock.base),
|
||||
}));
|
||||
await page.route('/node-api/index/txs', (route) => route.fulfill({
|
||||
await page.route(buildApiUrl('homepage_txs'), (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify([
|
||||
txMock.base,
|
||||
@@ -47,11 +48,11 @@ test.describe('socket', () => {
|
||||
};
|
||||
|
||||
test('new item', async({ mount, page, createSocket }) => {
|
||||
await page.route('/node-api/home-stats', (route) => route.fulfill({
|
||||
await page.route(buildApiUrl('homepage_stats'), (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify(statsMock.base),
|
||||
}));
|
||||
await page.route('/node-api/index/txs', (route) => route.fulfill({
|
||||
await page.route(buildApiUrl('homepage_txs'), (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify([
|
||||
txMock.base,
|
||||
|
||||
@@ -4,10 +4,11 @@ import React from 'react';
|
||||
import * as statsMock from 'mocks/stats/index';
|
||||
import contextWithEnvs from 'playwright/fixtures/contextWithEnvs';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import Stats from './Stats';
|
||||
|
||||
const API_URL = '/node-api/home-stats';
|
||||
const API_URL = buildApiUrl('homepage_stats');
|
||||
|
||||
test('all items +@mobile +@dark-mode +@desktop-xl', async({ mount, page }) => {
|
||||
await page.route(API_URL, (route) => route.fulfill({
|
||||
|
||||
@@ -4,11 +4,12 @@ import React from 'react';
|
||||
import * as dailyTxsMock from 'mocks/stats/daily_txs';
|
||||
import * as statsMock from 'mocks/stats/index';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import ChainIndicators from './ChainIndicators';
|
||||
|
||||
const STATS_API_URL = '/node-api/home-stats';
|
||||
const TX_CHART_API_URL = '/node-api/home-stats/charts/transactions';
|
||||
const STATS_API_URL = buildApiUrl('homepage_stats');
|
||||
const TX_CHART_API_URL = buildApiUrl('homepage_chart_txs');
|
||||
|
||||
test('daily txs chart +@mobile +@dark-mode +@dark-mode-mobile', async({ mount, page }) => {
|
||||
await page.route(STATS_API_URL, (route) => route.fulfill({
|
||||
|
||||
@@ -5,11 +5,12 @@ import * as blockMock from 'mocks/blocks/block';
|
||||
import * as statsMock from 'mocks/stats/index';
|
||||
import * as socketServer from 'playwright/fixtures/socketServer';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import Blocks from './Blocks';
|
||||
|
||||
const BLOCKS_API_URL = '/node-api/blocks?type=block';
|
||||
const STATS_API_URL = '/node-api/home-stats';
|
||||
const BLOCKS_API_URL = buildApiUrl('blocks') + '?type=block';
|
||||
const STATS_API_URL = buildApiUrl('homepage_stats');
|
||||
const hooksConfig = {
|
||||
router: {
|
||||
query: { tab: 'blocks' },
|
||||
|
||||
@@ -7,22 +7,23 @@ import * as statsMock from 'mocks/stats/index';
|
||||
import * as txMock from 'mocks/txs/tx';
|
||||
import insertAdText from 'playwright/scripts/insertAdText';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import Home from './Home';
|
||||
|
||||
test('default view -@default +@desktop-xl +@mobile +@dark-mode', async({ mount, page }) => {
|
||||
await page.route('/node-api/home-stats', (route) => route.fulfill({
|
||||
await page.route(buildApiUrl('homepage_stats'), (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify(statsMock.base),
|
||||
}));
|
||||
await page.route('/node-api/index/blocks', (route) => route.fulfill({
|
||||
await page.route(buildApiUrl('homepage_blocks'), (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify([
|
||||
blockMock.base,
|
||||
blockMock.base2,
|
||||
]),
|
||||
}));
|
||||
await page.route('/node-api/index/txs', (route) => route.fulfill({
|
||||
await page.route(buildApiUrl('homepage_txs'), (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify([
|
||||
txMock.base,
|
||||
@@ -30,7 +31,7 @@ test('default view -@default +@desktop-xl +@mobile +@dark-mode', async({ mount,
|
||||
txMock.withTokenTransfer,
|
||||
]),
|
||||
}));
|
||||
await page.route('/node-api/home-stats/charts/transactions', (route) => route.fulfill({
|
||||
await page.route(buildApiUrl('homepage_chart_txs'), (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify(dailyTxsMock.base),
|
||||
}));
|
||||
|
||||
@@ -2,10 +2,11 @@ import { test, expect } from '@playwright/experimental-ct-react';
|
||||
import React from 'react';
|
||||
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import Page from './Page';
|
||||
|
||||
const API_URL = '/node-api/index/indexing-status';
|
||||
const API_URL = buildApiUrl('homepage_indexing_status');
|
||||
|
||||
test('without indexing alert +@mobile', async({ mount }) => {
|
||||
const component = await mount(
|
||||
|
||||
@@ -4,10 +4,11 @@ import React from 'react';
|
||||
|
||||
import * as tokenTransferMock from 'mocks/tokens/tokenTransfer';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import TokenTransfer from './TokenTransfer';
|
||||
|
||||
const API_URL = '/node-api/transactions/1/token-transfers';
|
||||
const API_URL = buildApiUrl('tx_token_transfers', { id: '1' });
|
||||
|
||||
test('without tx info +@mobile', async({ mount, page }) => {
|
||||
await page.route(API_URL, (route) => route.fulfill({
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { test, expect } from '@playwright/experimental-ct-react';
|
||||
import React from 'react';
|
||||
|
||||
import { RESOURCES } from 'lib/api/resources';
|
||||
import * as profileMock from 'mocks/user/profile';
|
||||
import authFixture from 'playwright/fixtures/auth';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import ProfileMenuDesktop from './ProfileMenuDesktop';
|
||||
|
||||
@@ -34,7 +34,7 @@ test.describe('auth', () => {
|
||||
});
|
||||
|
||||
extendedTest('+@dark-mode', async({ mount, page }) => {
|
||||
await page.route('/proxy/poa/core' + RESOURCES.user_info.path, (route) => route.fulfill({
|
||||
await page.route(buildApiUrl('user_info'), (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify(profileMock.base),
|
||||
}));
|
||||
|
||||
@@ -3,10 +3,11 @@ import React from 'react';
|
||||
|
||||
import * as txMock from 'mocks/txs/tx';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import TxDetails from './TxDetails';
|
||||
|
||||
const API_URL = '/node-api/transactions/1';
|
||||
const API_URL = buildApiUrl('tx', { id: '1' });
|
||||
const hooksConfig = {
|
||||
router: {
|
||||
query: { id: 1 },
|
||||
|
||||
@@ -4,12 +4,13 @@ import React from 'react';
|
||||
import * as internalTxsMock from 'mocks/txs/internalTxs';
|
||||
import * as txMock from 'mocks/txs/tx';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
|
||||
import TxInternals from './TxInternals';
|
||||
|
||||
const TX_HASH = txMock.base.hash;
|
||||
const API_URL_TX = `/node-api/transactions/${ TX_HASH }`;
|
||||
const API_URL_TX_INTERNALS = `/node-api/transactions/${ TX_HASH }/internal-transactions`;
|
||||
const API_URL_TX = buildApiUrl('tx', { id: TX_HASH });
|
||||
const API_URL_TX_INTERNALS = buildApiUrl('tx_internal_txs', { id: TX_HASH });
|
||||
const hooksConfig = {
|
||||
router: {
|
||||
query: { id: TX_HASH },
|
||||
|
||||
Reference in New Issue
Block a user