-
Notifications
You must be signed in to change notification settings - Fork 494
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
1 parent
566389a
commit db39b10
Showing
7 changed files
with
84 additions
and
0 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,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' }, | ||
], | ||
}; |
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 |
---|---|---|
|
@@ -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(); | ||
}); |
Binary file added
BIN
+109 KB
..._screenshots__/ContractCode.pw.tsx_default_with-audits-feature-has-audits-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+102 KB
...__screenshots__/ContractCode.pw.tsx_default_with-audits-feature-no-audits-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions
18
ui/address/contract/contractSubmitAuditForm/ContractSubmitAuditForm.pw.tsx
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,18 @@ | ||
import { test, expect } from '@playwright/experimental-ct-react'; | ||
import React from 'react'; | ||
|
||
import TestApp from 'playwright/TestApp'; | ||
|
||
import ContractSubmitAuditForm from './ContractSubmitAuditForm'; | ||
|
||
test('base view', async({ mount }) => { | ||
|
||
const component = await mount( | ||
<TestApp> | ||
{ /* eslint-disable-next-line react/jsx-no-bind */ } | ||
<ContractSubmitAuditForm address="hash" onSuccess={ () => {} }/> | ||
</TestApp>, | ||
); | ||
|
||
await expect(component).toHaveScreenshot(); | ||
}); |
Binary file added
BIN
+30.6 KB
...uditForm/__screenshots__/ContractSubmitAuditForm.pw.tsx_default_base-view-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.