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
c3a32164
Commit
c3a32164
authored
May 07, 2024
by
Max Alekseenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests for action button
parent
cdfd9cfd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
3 deletions
+79
-3
.env.pw
configs/envs/.env.pw
+2
-1
address.ts
mocks/metadata/address.ts
+15
-0
TxSubHeading.pw.tsx
ui/tx/TxSubHeading.pw.tsx
+62
-2
TxSubHeading.pw.tsx_dark-color-mode_blockscout-provider-with-interpretation-and-action-button-mobile-dark-mode-1.png
...h-interpretation-and-action-button-mobile-dark-mode-1.png
+0
-0
TxSubHeading.pw.tsx_default_blockscout-provider-with-interpretation-and-action-button-mobile-dark-mode-1.png
...h-interpretation-and-action-button-mobile-dark-mode-1.png
+0
-0
TxSubHeading.pw.tsx_default_blockscout-provider-with-interpretation-and-vi-ee08a-k-and-action-button-external-link-mobile-1.png
...d-vi-ee08a-k-and-action-button-external-link-mobile-1.png
+0
-0
TxSubHeading.pw.tsx_mobile_blockscout-provider-with-interpretation-and-action-button-mobile-dark-mode-1.png
...h-interpretation-and-action-button-mobile-dark-mode-1.png
+0
-0
TxSubHeading.pw.tsx_mobile_blockscout-provider-with-interpretation-and-vi-ee08a-k-and-action-button-external-link-mobile-1.png
...d-vi-ee08a-k-and-action-button-external-link-mobile-1.png
+0
-0
No files found.
configs/envs/.env.pw
View file @
c3a32164
...
@@ -51,5 +51,6 @@ NEXT_PUBLIC_AUTH0_CLIENT_ID=xxx
...
@@ -51,5 +51,6 @@ NEXT_PUBLIC_AUTH0_CLIENT_ID=xxx
NEXT_PUBLIC_STATS_API_HOST=http://localhost:3004
NEXT_PUBLIC_STATS_API_HOST=http://localhost:3004
NEXT_PUBLIC_CONTRACT_INFO_API_HOST=http://localhost:3005
NEXT_PUBLIC_CONTRACT_INFO_API_HOST=http://localhost:3005
NEXT_PUBLIC_ADMIN_SERVICE_API_HOST=http://localhost:3006
NEXT_PUBLIC_ADMIN_SERVICE_API_HOST=http://localhost:3006
NEXT_PUBLIC_METADATA_SERVICE_API_HOST=http://localhost:3007
NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY=xxx
NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY=xxx
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=xxx
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=xxx
\ No newline at end of file
mocks/metadata/address.ts
View file @
c3a32164
...
@@ -61,3 +61,18 @@ export const protocolTag: AddressMetadataTagApi = {
...
@@ -61,3 +61,18 @@ export const protocolTag: AddressMetadataTagApi = {
ordinal
:
0
,
ordinal
:
0
,
meta
:
null
,
meta
:
null
,
};
};
export
const
protocolTagWithMeta
:
AddressMetadataTagApi
=
{
slug
:
'
furucombo
'
,
name
:
'
Furucombo
'
,
tagType
:
'
protocol
'
,
ordinal
:
0
,
meta
:
{
appID
:
'
furucombo
'
,
appMarketplaceURL
:
'
https://furucombo.app/decombo?chainId={chainId}&txHash={txHash}&utm_source=Blockscout
'
,
appLogoURL
:
'
https://blockscout-content.s3.amazonaws.com/furucombo-action-btn.svg
'
,
appActionButtonText
:
'
Decombo
'
,
textColor
:
'
#FFFFFF
'
,
bgColor
:
'
#1B1B21
'
,
},
};
ui/tx/TxSubHeading.pw.tsx
View file @
c3a32164
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
type
{
AddressMetadataInfo
,
AddressMetadataTagApi
}
from
'
types/api/addressMetadata
'
;
import
config
from
'
configs/app
'
;
import
{
protocolTagWithMeta
}
from
'
mocks/metadata/address
'
;
import
*
as
txMock
from
'
mocks/txs/tx
'
;
import
*
as
txMock
from
'
mocks/txs/tx
'
;
import
{
txInterpretation
}
from
'
mocks/txs/txInterpretation
'
;
import
{
txInterpretation
}
from
'
mocks/txs/txInterpretation
'
;
import
{
ENVS_MAP
}
from
'
playwright/fixtures/mockEnvs
'
;
import
{
ENVS_MAP
}
from
'
playwright/fixtures/mockEnvs
'
;
...
@@ -16,6 +20,25 @@ const txQuery = {
...
@@ -16,6 +20,25 @@ const txQuery = {
isError
:
false
,
isError
:
false
,
}
as
TxQuery
;
}
as
TxQuery
;
const
addressMetadataQueryParams
=
{
addresses
:
[
txMock
.
base
.
to
?.
hash
as
string
],
chainId
:
config
.
chain
.
id
,
tagsLimit
:
'
20
'
,
};
function
generateAddressMetadataResponse
(
tag
:
AddressMetadataTagApi
)
{
return
{
addresses
:
{
[
txMock
.
base
.
to
?.
hash
?.
toLowerCase
()
as
string
]:
{
tags
:
[
{
...
tag
,
meta
:
JSON
.
stringify
(
tag
.
meta
),
}
],
},
},
}
as
AddressMetadataInfo
;
}
test
(
'
no interpretation +@mobile
'
,
async
({
render
})
=>
{
test
(
'
no interpretation +@mobile
'
,
async
({
render
})
=>
{
const
component
=
await
render
(<
TxSubHeading
hash=
{
hash
}
hasTag=
{
false
}
txQuery=
{
txQuery
}
/>);
const
component
=
await
render
(<
TxSubHeading
hash=
{
hash
}
hasTag=
{
false
}
txQuery=
{
txQuery
}
/>);
await
expect
(
component
).
toHaveScreenshot
();
await
expect
(
component
).
toHaveScreenshot
();
...
@@ -32,6 +55,16 @@ test.describe('blockscout provider', () => {
...
@@ -32,6 +55,16 @@ test.describe('blockscout provider', () => {
await
expect
(
component
).
toHaveScreenshot
();
await
expect
(
component
).
toHaveScreenshot
();
});
});
test
(
'
with interpretation and action button +@mobile +@dark-mode
'
,
async
({
render
,
mockApiResponse
,
mockAssetResponse
,
mockFeatures
})
=>
{
await
mockFeatures
([
[
'
action_button_exp
'
,
true
]
]);
const
metadataResponse
=
generateAddressMetadataResponse
(
protocolTagWithMeta
);
await
mockApiResponse
(
'
address_metadata_info
'
,
metadataResponse
,
{
queryParams
:
addressMetadataQueryParams
});
await
mockAssetResponse
(
protocolTagWithMeta
?.
meta
?.
appLogoURL
as
string
,
'
./playwright/mocks/image_s.jpg
'
);
await
mockApiResponse
(
'
tx_interpretation
'
,
txInterpretation
,
{
pathParams
:
{
hash
}
});
const
component
=
await
render
(<
TxSubHeading
hash=
{
hash
}
hasTag=
{
false
}
txQuery=
{
txQuery
}
/>);
await
expect
(
component
).
toHaveScreenshot
();
});
test
(
'
with interpretation and view all link +@mobile
'
,
async
({
render
,
mockApiResponse
})
=>
{
test
(
'
with interpretation and view all link +@mobile
'
,
async
({
render
,
mockApiResponse
})
=>
{
await
mockApiResponse
(
await
mockApiResponse
(
'
tx_interpretation
'
,
'
tx_interpretation
'
,
...
@@ -42,13 +75,40 @@ test.describe('blockscout provider', () => {
...
@@ -42,13 +75,40 @@ test.describe('blockscout provider', () => {
await
expect
(
component
).
toHaveScreenshot
();
await
expect
(
component
).
toHaveScreenshot
();
});
});
test
(
'
no interpretation, has method called
'
,
async
({
render
,
mockApiResponse
})
=>
{
test
(
'
with interpretation and view all link, and action button (external link) +@mobile
'
,
async
({
render
,
mockApiResponse
,
mockAssetResponse
,
mockFeatures
,
})
=>
{
await
mockFeatures
([
[
'
action_button_exp
'
,
true
]
]);
delete
protocolTagWithMeta
?.
meta
?.
appID
;
const
metadataResponse
=
generateAddressMetadataResponse
(
protocolTagWithMeta
);
await
mockApiResponse
(
'
address_metadata_info
'
,
metadataResponse
,
{
queryParams
:
addressMetadataQueryParams
});
await
mockAssetResponse
(
protocolTagWithMeta
?.
meta
?.
appLogoURL
as
string
,
'
./playwright/mocks/image_s.jpg
'
);
await
mockApiResponse
(
'
tx_interpretation
'
,
{
data
:
{
summaries
:
[
...
txInterpretation
.
data
.
summaries
,
...
txInterpretation
.
data
.
summaries
]
}
},
{
pathParams
:
{
hash
}
},
);
const
component
=
await
render
(<
TxSubHeading
hash=
{
hash
}
hasTag=
{
false
}
txQuery=
{
txQuery
}
/>);
await
expect
(
component
).
toHaveScreenshot
();
});
test
(
'
no interpretation, has method called
'
,
async
({
render
,
mockApiResponse
,
mockFeatures
})
=>
{
// the action button should not render if there is no interpretation
await
mockFeatures
([
[
'
action_button_exp
'
,
true
]
]);
const
metadataResponse
=
generateAddressMetadataResponse
(
protocolTagWithMeta
);
await
mockApiResponse
(
'
address_metadata_info
'
,
metadataResponse
,
{
queryParams
:
addressMetadataQueryParams
});
await
mockApiResponse
(
'
tx_interpretation
'
,
{
data
:
{
summaries
:
[]
}
},
{
pathParams
:
{
hash
}
});
await
mockApiResponse
(
'
tx_interpretation
'
,
{
data
:
{
summaries
:
[]
}
},
{
pathParams
:
{
hash
}
});
const
component
=
await
render
(<
TxSubHeading
hash=
{
hash
}
hasTag=
{
false
}
txQuery=
{
txQuery
}
/>);
const
component
=
await
render
(<
TxSubHeading
hash=
{
hash
}
hasTag=
{
false
}
txQuery=
{
txQuery
}
/>);
await
expect
(
component
).
toHaveScreenshot
();
await
expect
(
component
).
toHaveScreenshot
();
});
});
test
(
'
no interpretation
'
,
async
({
render
,
mockApiResponse
})
=>
{
test
(
'
no interpretation
'
,
async
({
render
,
mockApiResponse
,
mockFeatures
})
=>
{
// the action button should not render if there is no interpretation
await
mockFeatures
([
[
'
action_button_exp
'
,
true
]
]);
const
metadataResponse
=
generateAddressMetadataResponse
(
protocolTagWithMeta
);
await
mockApiResponse
(
'
address_metadata_info
'
,
metadataResponse
,
{
queryParams
:
addressMetadataQueryParams
});
const
txPendingQuery
=
{
const
txPendingQuery
=
{
data
:
txMock
.
pending
,
data
:
txMock
.
pending
,
isPlaceholderData
:
false
,
isPlaceholderData
:
false
,
...
...
ui/tx/__screenshots__/TxSubHeading.pw.tsx_dark-color-mode_blockscout-provider-with-interpretation-and-action-button-mobile-dark-mode-1.png
0 → 100644
View file @
c3a32164
12.8 KB
ui/tx/__screenshots__/TxSubHeading.pw.tsx_default_blockscout-provider-with-interpretation-and-action-button-mobile-dark-mode-1.png
0 → 100644
View file @
c3a32164
12.5 KB
ui/tx/__screenshots__/TxSubHeading.pw.tsx_default_blockscout-provider-with-interpretation-and-vi-ee08a-k-and-action-button-external-link-mobile-1.png
0 → 100644
View file @
c3a32164
13.8 KB
ui/tx/__screenshots__/TxSubHeading.pw.tsx_mobile_blockscout-provider-with-interpretation-and-action-button-mobile-dark-mode-1.png
0 → 100644
View file @
c3a32164
11.9 KB
ui/tx/__screenshots__/TxSubHeading.pw.tsx_mobile_blockscout-provider-with-interpretation-and-vi-ee08a-k-and-action-button-external-link-mobile-1.png
0 → 100644
View file @
c3a32164
13.2 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