Page MenuHomePhabricator

[Cashtab] Better testing of useWallet hook
ClosedPublic

Authored by bytesofman on Jan 31 2024, 22:38.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCa53dc3a615ee: [Cashtab] Better testing of useWallet hook
Summary

Add more tests for the useWallet hook.

This diff introduces automated testing of localforage interaction. This will provide a baseline for future refactors of useWallet.js, demonstrating that expected behavior is preserved.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
test-usewallet
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26835
Build 53238: Build Diffcashtab-tests
Build 53237: arc lint + arc unit

Event Timeline

Tail of the build log:

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: qrcode.react@1.0.1
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!   react@"^18.2.0" from the root project
npm ERR!   peer react@">=16.0.0" from @ant-design/cssinjs@1.18.4
npm ERR!   node_modules/@ant-design/cssinjs
npm ERR!     @ant-design/cssinjs@"^1.18.4" from antd@5.13.3
npm ERR!     node_modules/antd
npm ERR!       antd@"^5.13.3" from the root project
npm ERR!   52 more (@ant-design/icons, @ant-design/react-slick, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^15.5.3 || ^16.0.0 || ^17.0.0" from qrcode.react@1.0.1
npm ERR! node_modules/qrcode.react
npm ERR!   qrcode.react@"^1.0.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@17.0.2
npm ERR! node_modules/react
npm ERR!   peer react@"^15.5.3 || ^16.0.0 || ^17.0.0" from qrcode.react@1.0.1
npm ERR!   node_modules/qrcode.react
npm ERR!     qrcode.react@"^1.0.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-01-31T22_39_07_057Z-debug-0.log
Build cashtab-tests failed with exit code 1

Tail of the build log:

/work/cashtab /work/abc-ci-builds/cashtab-tests
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: qrcode.react@1.0.1
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!   react@"^18.2.0" from the root project
npm ERR!   peer react@">=16.0.0" from @ant-design/cssinjs@1.18.4
npm ERR!   node_modules/@ant-design/cssinjs
npm ERR!     @ant-design/cssinjs@"^1.18.4" from antd@5.13.3
npm ERR!     node_modules/antd
npm ERR!       antd@"^5.13.3" from the root project
npm ERR!   52 more (@ant-design/icons, @ant-design/react-slick, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^15.5.3 || ^16.0.0 || ^17.0.0" from qrcode.react@1.0.1
npm ERR! node_modules/qrcode.react
npm ERR!   qrcode.react@"^1.0.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: react@17.0.2
npm ERR! node_modules/react
npm ERR!   peer react@"^15.5.3 || ^16.0.0 || ^17.0.0" from qrcode.react@1.0.1
npm ERR!   node_modules/qrcode.react
npm ERR!     qrcode.react@"^1.0.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /root/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-01-31T22_39_42_205Z-debug-0.log
Build cashtab-tests failed with exit code 1

can only do this after upgrading react, otherwise waitFor is not in the lib

rebase, new tests, better org

mark mocks as generated, remove debug logs

remove debug log, test change of wallet refresh interval

bytesofman published this revision for review.Feb 1 2024, 13:25
bytesofman added inline comments.
cashtab/package.json
140 ↗(On Diff #44852)

lets us use localforage lib in test env. will also let us use pure indexeddb, which we should migrate to.

cashtab/src/hooks/useWallet.js
1512 ↗(On Diff #44852)

need to export this to test that it changes as expected

This revision is now accepted and ready to land.Feb 1 2024, 20:00