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
1a6be1a0
Commit
1a6be1a0
authored
Jul 02, 2024
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add mockRpcResponse fixture and skip marketplace app test
parent
03d23931
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
2 deletions
+57
-2
mockRpcResponse.ts
playwright/fixtures/mockRpcResponse.ts
+52
-0
lib.tsx
playwright/lib.tsx
+3
-0
MarketplaceApp.pw.tsx
ui/pages/MarketplaceApp.pw.tsx
+2
-2
No files found.
playwright/fixtures/mockRpcResponse.ts
0 → 100644
View file @
1a6be1a0
import
type
{
TestFixture
,
Page
}
from
'
@playwright/test
'
;
import
_isEqual
from
'
lodash/isEqual
'
;
import
type
{
PublicRpcSchema
}
from
'
viem
'
;
import
{
getEnvValue
}
from
'
configs/app/utils
'
;
type
Params
=
PublicRpcSchema
[
number
];
export
type
MockRpcResponseFixture
=
(
params
:
Params
)
=>
Promise
<
void
>
;
// WIP
const
fixture
:
TestFixture
<
MockRpcResponseFixture
,
{
page
:
Page
}
>
=
async
({
page
},
use
)
=>
{
await
use
(
async
({
Method
,
ReturnType
})
=>
{
const
rpcUrl
=
getEnvValue
(
'
NEXT_PUBLIC_NETWORK_RPC_URL
'
);
if
(
!
rpcUrl
)
{
return
;
}
await
page
.
route
(
rpcUrl
,
(
route
)
=>
{
const
method
=
route
.
request
().
method
();
if
(
method
!==
'
POST
'
)
{
route
.
continue
();
return
;
}
const
json
=
route
.
request
().
postDataJSON
();
const
id
=
json
?.
id
;
const
payload
=
{
id
,
jsonrpc
:
'
2.0
'
,
method
:
Method
,
// TODO: add params to match actual payload
};
if
(
_isEqual
(
json
,
payload
)
&&
id
!==
undefined
)
{
return
route
.
fulfill
({
status
:
200
,
body
:
JSON
.
stringify
({
id
,
jsonrpc
:
'
2.0
'
,
result
:
ReturnType
,
}),
});
}
});
});
};
export
default
fixture
;
playwright/lib.tsx
View file @
1a6be1a0
...
...
@@ -8,6 +8,7 @@ import * as mockConfigResponse from './fixtures/mockConfigResponse';
import
*
as
mockContractReadResponse
from
'
./fixtures/mockContractReadResponse
'
;
import
*
as
mockEnvs
from
'
./fixtures/mockEnvs
'
;
import
*
as
mockFeatures
from
'
./fixtures/mockFeatures
'
;
import
*
as
mockRpcResponse
from
'
./fixtures/mockRpcResponse
'
;
import
*
as
mockTextAd
from
'
./fixtures/mockTextAd
'
;
import
*
as
render
from
'
./fixtures/render
'
;
import
*
as
socketServer
from
'
./fixtures/socketServer
'
;
...
...
@@ -20,6 +21,7 @@ interface Fixtures {
mockContractReadResponse
:
mockContractReadResponse
.
MockContractReadResponseFixture
;
mockEnvs
:
mockEnvs
.
MockEnvsFixture
;
mockFeatures
:
mockFeatures
.
MockFeaturesFixture
;
mockRpcResponse
:
mockRpcResponse
.
MockRpcResponseFixture
;
createSocket
:
socketServer
.
CreateSocketFixture
;
injectMetaMaskProvider
:
injectMetaMaskProvider
.
InjectMetaMaskProvider
;
mockTextAd
:
mockTextAd
.
MockTextAdFixture
;
...
...
@@ -33,6 +35,7 @@ const test = base.extend<Fixtures>({
mockContractReadResponse
:
mockContractReadResponse
.
default
,
mockEnvs
:
mockEnvs
.
default
,
mockFeatures
:
mockFeatures
.
default
,
mockRpcResponse
:
mockRpcResponse
.
default
,
// FIXME: for some reason Playwright does not intercept requests to text ad provider when running multiple tests in parallel
// even if we have a global request interceptor (maybe it is related to service worker issue, maybe not)
// so we have to inject mockTextAd fixture in each test and mock the response where it is needed
...
...
ui/pages/MarketplaceApp.pw.tsx
View file @
1a6be1a0
...
...
@@ -33,9 +33,9 @@ const testFn: Parameters<typeof test>[1] = async({ render, mockConfigResponse, m
await
expect
(
component
).
toHaveScreenshot
();
};
test
(
'
base view +@dark-mode
'
,
testFn
);
test
.
fixme
(
'
base view +@dark-mode
'
,
testFn
);
test
.
describe
(
'
mobile
'
,
()
=>
{
test
.
use
({
viewport
:
devices
[
'
iPhone 13 Pro
'
].
viewport
});
test
(
'
base view
'
,
testFn
);
test
.
fixme
(
'
base view
'
,
testFn
);
});
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