Page MenuHomePhabricator

[Cashtab] Validation function for new wallet name length
ClosedPublic

Authored by kieran709 on Aug 8 2022, 15:54.

Details

Summary

Added function + tests in validation.js & validation.test.js that handles checking new wallet name length. Related to T2409.

Test Plan

cd web/cashtab && npm start
navigate to configure screen
ensure there is at least one wallet in saved wallets list
click rename wallet button
enter a wallet name longer than 24 characters
observe that the error message for a wallet name that is too long will appear when max character limit is exceeded
backspace the wallet name until there are 0 characters left in the input
observe that the error message displays when the wallet name is 0 characters long
enter a valid wallet name to the input
observe that the wallet name successfully updates on Ok.

Diff Detail

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

Event Timeline

bytesofman added inline comments.
web/cashtab/src/utils/validation.js
397 ↗(On Diff #34605)

This can follow the barebones model of other functions in validation.js that simply return

e.g.

export const isValidNewWalletNameLength = newWalletName => {
return (
typeof newWalletName === 'string' && newWalletName.length > 0 && newWalletName.length <= currency.localStorageMaxCharacters && newWalletName.length !== '' 
)
}

Test the above approach

This revision now requires changes to proceed.Aug 10 2022, 18:06

Responding to review feedback

bytesofman added inline comments.
web/cashtab/src/components/Configure/Configure.js
152 ↗(On Diff #34605)

Why is this showing removed?

Rebase to latest master

This revision now requires changes to proceed.Aug 11 2022, 20:08

Rebased + added test comment

bytesofman added inline comments.
web/cashtab/src/utils/__tests__/validation.test.js
699 ↗(On Diff #34622)

add a unit test where newWalletName is an array that meets all conditoins except for typeof newWalletName === 'string'

so, an array with length > 0 and length < currency.localStorageMaxCharacters

This revision now requires changes to proceed.Aug 11 2022, 21:45

Added new validation test per review feedback.

This revision is now accepted and ready to land.Aug 15 2022, 23:09