mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
tests
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import type { SmartContractSecurityAudits } from 'types/api/contract';
|
||||
|
||||
export const contractAudits: SmartContractSecurityAudits = {
|
||||
items: [
|
||||
{ audit_company_name: 'Company-Name 1', audit_publish_date: '2024-01-31', audit_report_url: 'https://ya.ru' },
|
||||
{ audit_company_name: 'Company-Name 1', audit_publish_date: '2024-01-31', audit_report_url: 'https://ya.ru' },
|
||||
],
|
||||
};
|
||||
@@ -56,6 +56,12 @@ export const viewsEnvs = {
|
||||
},
|
||||
};
|
||||
|
||||
export const UIEnvs = {
|
||||
hasContractAuditReports: [
|
||||
{ name: 'NEXT_PUBLIC_HAS_CONTRACT_AUDIT_REPORTS', value: 'true' },
|
||||
],
|
||||
};
|
||||
|
||||
export const stabilityEnvs = [
|
||||
{ name: 'NEXT_PUBLIC_VIEWS_ADDRESS_HIDDEN_VIEWS', value: '["top_accounts"]' },
|
||||
{ name: 'NEXT_PUBLIC_VIEWS_TX_HIDDEN_FIELDS', value: '["value","fee_currency","gas_price","gas_fees","burnt_fees"]' },
|
||||
|
||||
@@ -2,16 +2,20 @@ import { test as base, expect } from '@playwright/experimental-ct-react';
|
||||
import React from 'react';
|
||||
|
||||
import * as addressMock from 'mocks/address/address';
|
||||
import { contractAudits } from 'mocks/contract/audits';
|
||||
import * as contractMock from 'mocks/contract/info';
|
||||
import contextWithEnvs from 'playwright/fixtures/contextWithEnvs';
|
||||
import * as socketServer from 'playwright/fixtures/socketServer';
|
||||
import TestApp from 'playwright/TestApp';
|
||||
import buildApiUrl from 'playwright/utils/buildApiUrl';
|
||||
import * as configs from 'playwright/utils/configs';
|
||||
import MockAddressPage from 'ui/address/testUtils/MockAddressPage';
|
||||
|
||||
import ContractCode from './ContractCode';
|
||||
|
||||
const addressHash = 'hash';
|
||||
const CONTRACT_API_URL = buildApiUrl('contract', { hash: addressHash });
|
||||
const CONTRACT_AUDITS_API_URL = buildApiUrl('contract_security_audits', { hash: addressHash });
|
||||
const hooksConfig = {
|
||||
router: {
|
||||
query: { hash: addressHash },
|
||||
@@ -229,3 +233,51 @@ test('non verified', async({ mount, page }) => {
|
||||
|
||||
await expect(component).toHaveScreenshot();
|
||||
});
|
||||
|
||||
const withAuditsTest = test.extend({
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
context: contextWithEnvs(configs.UIEnvs.hasContractAuditReports) as any,
|
||||
});
|
||||
|
||||
withAuditsTest('with audits feature, no audits', async({ mount, page }) => {
|
||||
await page.route(CONTRACT_API_URL, (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify(contractMock.verified),
|
||||
}));
|
||||
await page.route(CONTRACT_AUDITS_API_URL, (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify({ items: [] }),
|
||||
}));
|
||||
await page.route('https://cdn.jsdelivr.net/npm/[email protected]/**', (route) => route.abort());
|
||||
|
||||
const component = await mount(
|
||||
<TestApp>
|
||||
<ContractCode addressHash={ addressHash } noSocket/>
|
||||
</TestApp>,
|
||||
{ hooksConfig },
|
||||
);
|
||||
|
||||
await expect(component).toHaveScreenshot();
|
||||
});
|
||||
|
||||
withAuditsTest('with audits feature, has audits', async({ mount, page }) => {
|
||||
await page.route(CONTRACT_API_URL, (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify(contractMock.verified),
|
||||
}));
|
||||
await page.route(CONTRACT_AUDITS_API_URL, (route) => route.fulfill({
|
||||
status: 200,
|
||||
body: JSON.stringify(contractAudits),
|
||||
}));
|
||||
|
||||
await page.route('https://cdn.jsdelivr.net/npm/[email protected]/**', (route) => route.abort());
|
||||
|
||||
const component = await mount(
|
||||
<TestApp>
|
||||
<ContractCode addressHash={ addressHash } noSocket/>
|
||||
</TestApp>,
|
||||
{ hooksConfig },
|
||||
);
|
||||
|
||||
await expect(component).toHaveScreenshot();
|
||||
});
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 109 KiB |
BIN
Binary file not shown.
|
After Width: | Height: | Size: 102 KiB |
Reference in New Issue
Block a user