Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
8a71b3d0
Commit
8a71b3d0
authored
Feb 14, 2024
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests
parent
b1fdc64b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
0 deletions
+66
-0
audits.ts
mocks/contract/audits.ts
+8
-0
configs.ts
playwright/utils/configs.ts
+6
-0
ContractCode.pw.tsx
ui/address/contract/ContractCode.pw.tsx
+52
-0
ContractCode.pw.tsx_default_with-audits-feature-has-audits-1.png
...tCode.pw.tsx_default_with-audits-feature-has-audits-1.png
+0
-0
ContractCode.pw.tsx_default_with-audits-feature-no-audits-1.png
...ctCode.pw.tsx_default_with-audits-feature-no-audits-1.png
+0
-0
No files found.
mocks/contract/audits.ts
0 → 100644
View file @
8a71b3d0
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
'
},
],
};
playwright/utils/configs.ts
View file @
8a71b3d0
...
...
@@ -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"]
'
},
...
...
ui/address/contract/ContractCode.pw.tsx
View file @
8a71b3d0
...
...
@@ -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/monaco-editor@0.33.0/**
'
,
(
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/monaco-editor@0.33.0/**
'
,
(
route
)
=>
route
.
abort
());
const
component
=
await
mount
(
<
TestApp
>
<
ContractCode
addressHash=
{
addressHash
}
noSocket
/>
</
TestApp
>,
{
hooksConfig
},
);
await
expect
(
component
).
toHaveScreenshot
();
});
ui/address/contract/__screenshots__/ContractCode.pw.tsx_default_with-audits-feature-has-audits-1.png
0 → 100644
View file @
8a71b3d0
109 KB
ui/address/contract/__screenshots__/ContractCode.pw.tsx_default_with-audits-feature-no-audits-1.png
0 → 100644
View file @
8a71b3d0
102 KB
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment