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

Additional watched account tests #396

Merged
merged 18 commits into from
Oct 12, 2023

Conversation

asnaith
Copy link
Member

@asnaith asnaith commented Oct 11, 2023

related to #378

New tests for

  • Adding custom names to watched multisigs / watched pures
  • Checking the correct badge is displayed for pures / multisigs
  • Checking new transaction button does not appear for watched accounts
  • Checking the subscan link is present on the options menu

Also removed some unnecessary double quotes in the locators on the page objects

@asnaith asnaith requested a review from Tbaut October 11, 2023 02:40
@asnaith asnaith changed the title Asnaith/additional watched accounts tests Additional watched account tests Oct 11, 2023
multisigPage.editNamesMenuOption().click()
editNamesModal.body().should('be.visible')
editNamesModal.inputEditPureName().type(`{selectall}{del}${`Edited Name Test`}`)
cy.wait(500)
Copy link
Member Author

Choose a reason for hiding this comment

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

This is another annoying situation where this 500ms wait is needed before clicking the save button, without it the test will fail because the name in the header never updates. With this slight wait, it works every time.

I understand we never want to never use waits but this is another instance where I couldn't go further without one. Open to suggestions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's see what we can do here. It's weird that the input are so sensitive. Maybe we can wait until the text is visible in the input or something. I'll check.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to spend time on this, sorry that I didn't get to it today, will check asap and report back.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I learned something pretty 🤯 today with cy.clock and cy.tick. The reason you had to wait, is because of the way we handle the storage of names. We don't store names on press, we debounce it. Without de-bouncing this field, it appeared unresponsive (I remember adding this). There's a debounce of 300ms here

const debouncedNameChange = useMemo(() => debounce(onNameChange, 300), [onNameChange])

Now thanks to cy.clock and tick we can bend time.. and make things happen quicker 🤷
https://docs.cypress.io/api/commands/tick

Copy link
Collaborator

Choose a reason for hiding this comment

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

@Lykhoyda I'll try to use this in the connect function instead of waitUntil. Because it is actually retrying stuff every 200ms, so it's not really elegant

Copy link
Member Author

Choose a reason for hiding this comment

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

I learned something pretty 🤯 today with cy.clock and cy.tick. The reason you had to wait, is because of the way we handle the storage of names. We don't store names on press, we debounce it. Without de-bouncing this field, it appeared unresponsive (I remember adding this).

@Tbaut This is great! The explanation totally makes sense. Thank you for working this out, this is something I would have never considered but now we can look out for it in other scenarios! 🙏

(cc @juans-chainsafe - there's some good info in the comment above, we can look out for this in other frontend projects when encountering those scenarios where we think we need a cy.wait).

topMenuItems.homeButton().click()
multisigPage.optionsMenuButton().click()
multisigPage.subscanMenuOption().should('be.visible')
})
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a very basic test atm, do we want to try and remove the target on the link so that the tab loads in the same window and then check that the subscan URL contains the correct address....or is that too much?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I imagine that you meant to write this for the subscan test. I agree that it'd be better to actually test that the link is for the right address at least. I didn't research it but I guess it's possible. Removing the target sounds like hack though 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated: @Tbaut Juan has a nice solution for checking external links on another FE project. The same technique works well for us

Copy link
Collaborator

@Tbaut Tbaut Oct 12, 2023

Choose a reason for hiding this comment

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

yup that's great, I figured there must have been some ways to stub this but didn't check 👍

@asnaith
Copy link
Member Author

asnaith commented Oct 11, 2023

@Tbaut @Lykhoyda I left some comments on specific things here, wanted to seek opinions before going further with more tests.

@asnaith asnaith requested a review from Lykhoyda October 11, 2023 03:09
packages/ui/cypress/tests/watched-accounts.cy.ts Outdated Show resolved Hide resolved
packages/ui/cypress/tests/watched-accounts.cy.ts Outdated Show resolved Hide resolved
multisigPage.editNamesMenuOption().click()
editNamesModal.body().should('be.visible')
editNamesModal.inputEditPureName().type(`{selectall}{del}${`Edited Name Test`}`)
cy.wait(500)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's see what we can do here. It's weird that the input are so sensitive. Maybe we can wait until the text is visible in the input or something. I'll check.

topMenuItems.homeButton().click()
multisigPage.optionsMenuButton().click()
multisigPage.subscanMenuOption().should('be.visible')
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

I imagine that you meant to write this for the subscan test. I agree that it'd be better to actually test that the link is for the right address at least. I didn't research it but I guess it's possible. Removing the target sounds like hack though 🤷

packages/ui/src/components/Header/Header.tsx Show resolved Hide resolved
packages/ui/src/components/IdenticonBadge.tsx Outdated Show resolved Hide resolved
Copy link
Collaborator

@Tbaut Tbaut left a comment

Choose a reason for hiding this comment

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

Wow that's amazing, and that's already a lot covered!

@asnaith asnaith merged commit 29908c9 into main Oct 12, 2023
4 checks passed
@asnaith asnaith deleted the asnaith/additional-watched-accounts-tests branch October 12, 2023 21:45
@Tbaut
Copy link
Collaborator

Tbaut commented Oct 18, 2023

@asnaith you didn't share with us the mnemonic of this accounts. Any way you can do it, or didn't you use a new account for this?

@asnaith
Copy link
Member Author

asnaith commented Oct 18, 2023

@asnaith you didn't share with us the mnemonic of this accounts. Any way you can do it, or didn't you use a new account for this?

@Tbaut Yeah I had the signatories in this file
https://github.com/ChainSafe/Multix/blob/main/packages/ui/cypress/fixtures/watchAccounts/watchSignatories.ts

but your question made me check...and when I did I realized one of the mnemonics needed updating as it was incorrect, now all is correct in this pr: #409

@asnaith asnaith restored the asnaith/additional-watched-accounts-tests branch October 20, 2023 00:03
@Tbaut Tbaut deleted the asnaith/additional-watched-accounts-tests branch September 23, 2024 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants