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
ba86df71
Commit
ba86df71
authored
Feb 16, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
d795e14d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
20 deletions
+51
-20
socketServer.ts
playwright/fixtures/socketServer.ts
+2
-0
ContractVerificationForm.pw.tsx
ui/contractVerification/ContractVerificationForm.pw.tsx
+49
-20
ContractVerificationForm.pw.tsx_default_sourcify-with-multiple-contracts-1.png
...orm.pw.tsx_default_sourcify-with-multiple-contracts-1.png
+0
-0
ContractVerificationForm.pw.tsx_default_sourcify-with-multiple-contracts-2.png
...orm.pw.tsx_default_sourcify-with-multiple-contracts-2.png
+0
-0
No files found.
playwright/fixtures/socketServer.ts
View file @
ba86df71
...
@@ -4,6 +4,7 @@ import { WebSocketServer } from 'ws';
...
@@ -4,6 +4,7 @@ import { WebSocketServer } from 'ws';
import
type
{
AddressCoinBalanceHistoryItem
}
from
'
types/api/address
'
;
import
type
{
AddressCoinBalanceHistoryItem
}
from
'
types/api/address
'
;
import
type
{
NewBlockSocketResponse
}
from
'
types/api/block
'
;
import
type
{
NewBlockSocketResponse
}
from
'
types/api/block
'
;
import
type
{
SmartContractVerificationResponse
}
from
'
types/api/contract
'
;
type
ReturnType
=
()
=>
Promise
<
WebSocket
>
;
type
ReturnType
=
()
=>
Promise
<
WebSocket
>
;
...
@@ -59,6 +60,7 @@ export function sendMessage(socket: WebSocket, channel: Channel, msg: 'token_bal
...
@@ -59,6 +60,7 @@ export function sendMessage(socket: WebSocket, channel: Channel, msg: 'token_bal
export
function
sendMessage
(
socket
:
WebSocket
,
channel
:
Channel
,
msg
:
'
transaction
'
,
payload
:
{
transaction
:
number
}):
void
;
export
function
sendMessage
(
socket
:
WebSocket
,
channel
:
Channel
,
msg
:
'
transaction
'
,
payload
:
{
transaction
:
number
}):
void
;
export
function
sendMessage
(
socket
:
WebSocket
,
channel
:
Channel
,
msg
:
'
pending_transaction
'
,
payload
:
{
pending_transaction
:
number
}):
void
;
export
function
sendMessage
(
socket
:
WebSocket
,
channel
:
Channel
,
msg
:
'
pending_transaction
'
,
payload
:
{
pending_transaction
:
number
}):
void
;
export
function
sendMessage
(
socket
:
WebSocket
,
channel
:
Channel
,
msg
:
'
new_block
'
,
payload
:
NewBlockSocketResponse
):
void
;
export
function
sendMessage
(
socket
:
WebSocket
,
channel
:
Channel
,
msg
:
'
new_block
'
,
payload
:
NewBlockSocketResponse
):
void
;
export
function
sendMessage
(
socket
:
WebSocket
,
channel
:
Channel
,
msg
:
'
verification_result
'
,
payload
:
SmartContractVerificationResponse
):
void
;
export
function
sendMessage
(
socket
:
WebSocket
,
channel
:
Channel
,
msg
:
string
,
payload
:
unknown
):
void
{
export
function
sendMessage
(
socket
:
WebSocket
,
channel
:
Channel
,
msg
:
string
,
payload
:
unknown
):
void
{
socket
.
send
(
JSON
.
stringify
([
socket
.
send
(
JSON
.
stringify
([
...
channel
,
...
channel
,
...
...
ui/contractVerification/ContractVerificationForm.pw.tsx
View file @
ba86df71
...
@@ -3,6 +3,7 @@ import React from 'react';
...
@@ -3,6 +3,7 @@ import React from 'react';
import
type
{
SmartContractVerificationConfig
}
from
'
types/api/contract
'
;
import
type
{
SmartContractVerificationConfig
}
from
'
types/api/contract
'
;
import
*
as
socketServer
from
'
playwright/fixtures/socketServer
'
;
import
TestApp
from
'
playwright/TestApp
'
;
import
TestApp
from
'
playwright/TestApp
'
;
import
ContractVerificationForm
from
'
./ContractVerificationForm
'
;
import
ContractVerificationForm
from
'
./ContractVerificationForm
'
;
...
@@ -85,26 +86,54 @@ test('standard input json method', async({ mount, page }) => {
...
@@ -85,26 +86,54 @@ test('standard input json method', async({ mount, page }) => {
await
expect
(
component
).
toHaveScreenshot
();
await
expect
(
component
).
toHaveScreenshot
();
});
});
test
(
'
sourcify method +@dark-mode +@mobile
'
,
async
({
mount
,
page
})
=>
{
test
.
describe
(
'
sourcify
'
,
()
=>
{
const
component
=
await
mount
(
const
testWithSocket
=
test
.
extend
<
socketServer
.
SocketServerFixture
>
({
<
TestApp
>
createSocket
:
socketServer
.
createSocket
,
<
ContractVerificationForm
config=
{
formConfig
}
hash=
{
hash
}
/>
});
</
TestApp
>,
testWithSocket
.
describe
.
configure
({
mode
:
'
serial
'
,
timeout
:
20
_000
});
{
hooksConfig
},
);
testWithSocket
.
only
(
'
with multiple contracts
'
,
async
({
mount
,
page
,
createSocket
})
=>
{
const
component
=
await
mount
(
await
component
.
getByLabel
(
/verification method/i
).
focus
();
<
TestApp
withSocket
>
await
component
.
getByLabel
(
/verification method/i
).
type
(
'
solidity
'
);
<
ContractVerificationForm
config=
{
formConfig
}
hash=
{
hash
}
/>
await
page
.
getByRole
(
'
button
'
,
{
name
:
/sourcify/i
}).
click
();
</
TestApp
>,
{
hooksConfig
},
await
page
.
getByText
(
/drop files/i
).
click
();
);
await
page
.
locator
(
'
input[name="sources"]
'
).
setInputFiles
([
'
./playwright/mocks/file_mock_1.json
'
,
await
component
.
getByLabel
(
/verification method/i
).
focus
();
'
./playwright/mocks/file_mock_2.json
'
,
await
component
.
getByLabel
(
/verification method/i
).
type
(
'
solidity
'
);
'
./playwright/mocks/file_mock_with_very_long_name.json
'
,
await
page
.
getByRole
(
'
button
'
,
{
name
:
/sourcify/i
}).
click
();
]);
await
page
.
getByText
(
/drop files/i
).
click
();
await
expect
(
component
).
toHaveScreenshot
();
await
page
.
locator
(
'
input[name="sources"]
'
).
setInputFiles
([
'
./playwright/mocks/file_mock_1.json
'
,
'
./playwright/mocks/file_mock_2.json
'
,
'
./playwright/mocks/file_mock_with_very_long_name.json
'
,
]);
await
expect
(
component
).
toHaveScreenshot
();
const
socket
=
await
createSocket
();
const
channel
=
await
socketServer
.
joinChannel
(
socket
,
`addresses:
${
hash
.
toLowerCase
()
}
`
);
await
page
.
getByRole
(
'
button
'
,
{
name
:
/verify/i
}).
click
();
socketServer
.
sendMessage
(
socket
,
channel
,
'
verification_result
'
,
{
status
:
'
error
'
,
errors
:
{
// eslint-disable-next-line max-len
files
:
[
'
Detected 5 contracts (ERC20, IERC20, IERC20Metadata, Context, MockERC20), but can only verify 1 at a time. Please choose a main contract and click Verify again.
'
],
},
});
await
component
.
getByLabel
(
/contract name/i
).
focus
();
await
component
.
getByLabel
(
/contract name/i
).
type
(
'
e
'
);
const
contractNameOption
=
page
.
getByRole
(
'
button
'
,
{
name
:
/MockERC20/i
});
await
expect
(
contractNameOption
).
toBeVisible
();
await
expect
(
component
).
toHaveScreenshot
();
});
});
});
test
(
'
multi-part files method
'
,
async
({
mount
,
page
})
=>
{
test
(
'
multi-part files method
'
,
async
({
mount
,
page
})
=>
{
...
...
ui/contractVerification/__screenshots__/ContractVerificationForm.pw.tsx_default_sourcify-
method-dark-mode-mobile
-1.png
→
ui/contractVerification/__screenshots__/ContractVerificationForm.pw.tsx_default_sourcify-
with-multiple-contracts
-1.png
View file @
ba86df71
File moved
ui/contractVerification/__screenshots__/ContractVerificationForm.pw.tsx_default_sourcify-with-multiple-contracts-2.png
0 → 100644
View file @
ba86df71
55.6 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