Page MenuHomePhabricator

[marlin] Add mnemonic end to end tests
ClosedPublic

Authored by Fabien on Thu, Apr 9, 08:40.

Details

Reviewers
bytesofman
Group Reviewers
Restricted Project
Commits
rABCafd3aa29befb: [marlin] Add mnemonic end to end tests
Summary

Check the mnemonic hide/show and update features.

Test Plan
pnpm run test:e2e

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Thu, Apr 9, 08:40
bytesofman requested changes to this revision.Thu, Apr 9, 12:08
bytesofman added a subscriber: bytesofman.
bytesofman added inline comments.
apps/marlin-wallet/web/cypress/e2e/mnemonic.cy.ts
5 ↗(On Diff #58950)

cashtab does not use the bip39 dependency as all the logic needed is available in ecash-lib

however you do need to include the english wordlist somewhere here to lose the dep; not necessarily related to this diff but opportunity to lose a critical external dep

53 ↗(On Diff #58950)

not sure what we gain by testing this; of course we expect the app to never have an invalid mnemonic

would make more sense to test this kind of behavior on import, e.g. we correctly throw or show correct validation error if user attempts to import an invalid mnemonic

150 ↗(On Diff #58950)

it's usually a bad sign if arbitrary timeouts are in like this, especially one for 60s. If this is failing without the timeout there could be some other issue, but more likely the expectation should simply be cleaned up somehow.

cypress has async expectors (I think this is one).

It's possible there is some need for longer timeouts for CI processing, but this should be handled at he CI config level, not hard coded timeouts on individual checks

163 ↗(On Diff #58950)

again here, not sure testing isValidMnemonic at this stage is useful or relevant to app performance. We shouldn't really be using isValidMnemonic in the test file at all.

A test that would make sense would be

  • user enters a 12 word phrase that is not a valid mnemonic
  • user sees validation error and import button is disabled (or user attempts to import and sees expected modal, whatever the expected behavior is)
  • user corrects mnemonic and imports successfully

current use of this function is not adding value to the test

This revision now requires changes to proceed.Thu, Apr 9, 12:08
apps/marlin-wallet/web/cypress/e2e/mnemonic.cy.ts
5 ↗(On Diff #58950)

Good point, I should update marlin to remove the dependency. This will be another diff tho as it's unrelated

53 ↗(On Diff #58950)

it's more about checking the settings is properly showing the mnemonic. Since we don't know what it's supposed to be (it's random), checking it's valid (so 12 words from the list) is a good enough approximation. The import is tested in another case a bit below and this time all the words are also checked as well as the corresponding address.

150 ↗(On Diff #58950)

This timeout might not be needed as it's the default anyway, but yes I need an async expector here because the wallet refreshes so there might be a small delay before the address is updated

163 ↗(On Diff #58950)

I agree here, the point is to test the words are the expected ones, not that the mnemonic is valid.
Also it's lacking an invalid mnemonic test, I will add one

Remove the unnecessary timeout and mnemonic validation.
I kept the mnemonic validation as a way to check a mnemonic is visible.
Added a couple more tests for 1. invalid mnemonic and 2. words autocompletion

This revision is now accepted and ready to land.Thu, Apr 9, 14:51
This revision was automatically updated to reflect the committed changes.