Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various UI and test fixes #528

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chopsticks-config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
endpoint: wss://kusama.rpc.amforc.com
endpoint: wss://rpc.ibp.network/kusama
mock-signature-host: true
block: 22568290
db: ./db.sqlite
Expand Down
1 change: 1 addition & 0 deletions packages/ui/cypress/support/page-objects/landingPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const landingPage = {
cy.get('[data-cy=label-first-multisig-creation', { timeout: 30000 }),
multisigCreationInfoBanner: (timeout = 4000) =>
cy.get('[data-cy=banner-multisig-creation-info]', { timeout }),
creationInfoBannerCloseButton: () => cy.get('[data-cy=button-close-multisig-creation-info]'),

// page specific assertion
shouldHaveNoAccountErrorAndWikiLink() {
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/cypress/tests/address-bar.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ describe('Account address in the address bar', () => {

topMenuItems.desktopMenu().within(() => topMenuItems.networkSelector().click())
topMenuItems.networkSelectorOption('kusama').click()
landingPage
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asnaith this actually made it so that it'd have failed earlier, I tested by removing my fix. It's better than having to wait 2s on purpose.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep makes sense :)

.noMultisigFoundError()
.should('contain.text', 'No multisig found for your accounts or watched accounts on kusama.')
cy.url().should('not.include', 'address=')
})

Expand Down
21 changes: 10 additions & 11 deletions packages/ui/cypress/tests/multisig-creation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { notifications } from '../support/page-objects/notifications'
import { topMenuItems } from '../support/page-objects/topMenuItems'
import { landingPage } from '../support/page-objects/landingPage'
import { waitForTxRequest } from '../utils/waitForTxRequests'
import { waitForMultisigLength } from '../utils/waitForMultisigLength'

const fundedAccount1 = testAccounts['Funded Account 1 Chopsticks Kusama']
const fundedAccount2 = testAccounts['Funded Account 2 Chopsticks Kusama']
Expand All @@ -23,7 +24,7 @@ const typeAndAdd = (address: string) => {
newMultisigPage.addButton().click()
}

const acceptMultisigCreationAndVerifyNotifications = () => {
const acceptMultisigCreationAndVerifyNotifications = (firstMultisig = false) => {
waitForTxRequest()
cy.getTxRequests().then((req) => {
const txRequests = Object.values(req)
Expand All @@ -36,6 +37,8 @@ const acceptMultisigCreationAndVerifyNotifications = () => {
notifications.loadingNotificationIcon().should('be.visible')
notifications.notificationWrapper().should('contain', 'broadcast')

firstMultisig && landingPage.firstMultisigCreationLabel().should('be.visible')

notifications.successNotificationIcon(30000).should('be.visible')
notifications.notificationWrapper().should('contain', 'Tx in block')
})
Expand Down Expand Up @@ -102,9 +105,7 @@ describe('Multisig creation', () => {
newMultisigPage.step3.infoBox().should('contain', '1 batch transaction')
newMultisigPage.step3.errorNotEnoughFunds().should('not.exist')
newMultisigPage.nextButton().should('contain', 'Create').click()
acceptMultisigCreationAndVerifyNotifications()

landingPage.firstMultisigCreationLabel().should('be.visible')
acceptMultisigCreationAndVerifyNotifications(true)

// Landing Page
multisigPage.accountHeader(10000).within(() => {
Expand Down Expand Up @@ -144,14 +145,12 @@ describe('Multisig creation', () => {

// The banner should be there, and disapear within 30s
landingPage.multisigCreationInfoBanner().should('be.visible')
landingPage.creationInfoBannerCloseButton().click()

cy.clock().then((clock) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this wasn't working. Adding the cy.clock before the cy.visit actually breaks everything, somehow, as the api calls don't get fired. All in all removing the clock

// The banner should disapear after 30s, speed it up by 15s
clock.tick(15000)
// The banner should disappear
landingPage.multisigCreationInfoBanner(30000).should('not.exist')
clock.restore()
})
// The banner should disappear
landingPage.multisigCreationInfoBanner().should('not.exist')

waitForMultisigLength(2)

topMenuItems
.desktopMenu()
Expand Down
13 changes: 13 additions & 0 deletions packages/ui/cypress/utils/waitForMultisigLength.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { multisigPage } from '../support/page-objects/multisigPage'
import { topMenuItems } from '../support/page-objects/topMenuItems'

export const waitForMultisigLength = (length: number) =>
cy.waitUntil(() => {
multisigPage.accountHeader().click()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is doing a click outside basically, so that if any dropdown is open, it's close it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, might be worth adding a small comment there about that so we remember why we are doing that.

return topMenuItems
.multiproxySelectorDesktop()
.click()
.then(() => {
return topMenuItems.multiproxySelectorOptionDesktop().then((el) => el.length === length)
})
})
15 changes: 11 additions & 4 deletions packages/ui/src/components/AccountDisplay/AccountDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Tooltip } from '@mui/material'
import { useCallback, useMemo, useState } from 'react'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { styled } from '@mui/material/styles'
import { AccountBadge, IconSizeVariant } from '../../types'
import { getDisplayAddress } from '../../utils'
Expand Down Expand Up @@ -55,7 +55,16 @@ const AccountDisplay = ({
address
})

const handleTooltipClose = useCallback(() => setIsCopyTooltipOpen(false), [])
useEffect(() => {
let timeOut: NodeJS.Timeout

if (isCopyTooltipOpen) {
timeOut = setTimeout(() => setIsCopyTooltipOpen(false), DEFAULT_AUTO_HIDE_DURATION)
}

return () => timeOut && clearTimeout(timeOut)
}, [isCopyTooltipOpen])

const handleCopyAddress = useCallback(() => {
if (!canCopy) return

Expand Down Expand Up @@ -132,11 +141,9 @@ const AccountDisplay = ({
onClick={handleCopyAddress}
>
<Tooltip
onClose={handleTooltipClose}
open={isCopyTooltipOpen}
title={DEFAULT_TITLE}
placement={DEFAULT_PLACEMENT}
leaveDelay={DEFAULT_AUTO_HIDE_DURATION}
>
<AddressWrapperStyled>{getDisplayAddress(encodedAddress)}</AddressWrapperStyled>
</Tooltip>
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/DeepTxAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export const DeepTxAlert = ({ pendingTxCallData }: Props) => {
<InfoTextStyled
container
spacing={0}
data-cy="banner-multisig-creation-info"
data-cy="banner-nested-multisig-tx"
>
<Grid
item
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/components/NewMulisigAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const NewMulisigAlert = ({ className = '', onClose }: Props) => {
Your new multisig is being created. It will be available in ~1min from the dropdown.
</div>
<IconButton
data-cy="button-close-multisig-creation-info"
className="closeButton"
size="small"
aria-label="close"
Expand Down
10 changes: 6 additions & 4 deletions packages/ui/src/components/select/NetworkSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const NetworkSelection = () => {
key={networkName}
value={networkName}
data-cy={`select-network-option-${networkName}`}
isOneLine={displayedNetworks.length === 1}
className={displayedNetworks.length === 1 ? 'oneLine' : undefined}
>
<ImgStyled
alt={`network-logo-${networkName}`}
Expand Down Expand Up @@ -197,13 +197,15 @@ const SelectStyled = styled(SelectMui)`
}
`

const MenuItemStyled = styled(MenuItem)<{ isOneLine: boolean }>`
const MenuItemStyled = styled(MenuItem)`
text-transform: capitalize;
padding: 0.75rem;
max-width: 9.1875rem;
box-sizing: content-box;
// Fix for correct display of the one line networks list in Safari
${({ isOneLine }) => isOneLine && 'column-span: all'}

&.oneLine {
column-span: all;
}
`

const ImgStyled = styled('img')`
Expand Down
6 changes: 3 additions & 3 deletions squid/squid-manifests/large-squid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ deploy:
cmd: ['sqd', 'start-westend']
- name: paseo-processor
cmd: ['sqd', 'start-paseo']
- name: kilt-processor
cmd: ['sqd', 'start-kilt']
# - name: kilt-processor
# cmd: ['sqd', 'start-kilt']
# - name: joystream-processor
# cmd: ['sqd', 'start-joystream']
# - name: watr-processor
Expand All @@ -56,7 +56,7 @@ deploy:
# cmd: ['sqd', 'start-amplitude']
api:
env:
SQD_DEBUG: sqd:graphql-server
# SQD_DEBUG: sqd:graphql-server
cmd:
[
'npx',
Expand Down
Loading