Page MenuHomePhabricator

[Cashtab] Remove faulty unit tests
ClosedPublic

Authored by bytesofman on Jan 5 2024, 21:35.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABCe64d9d251601: [Cashtab] Remove faulty unit tests
Summary

While it would be nice to have automated integration tests like these -- these tests are not actually doing what they say they are doing. That they pass is misleading.

To properly automate integration tests in hooks, we need

  • localforage mock
  • different libraries with access to full component state

Remaining unit tests in useWallet.js are testing functions from the hook.

Test Plan

npm test

Diff Detail

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

Event Timeline

bytesofman published this revision for review.Jan 5 2024, 22:07
bytesofman added inline comments.
cashtab/src/hooks/__tests__/useWallet.test.js
36 ↗(On Diff #43957)

Calling handleUpdateWallet falls back on localforage and finally chronik APIs to populate wallet data. I am not sure why this test is passing, as we expect false to be returned here.

The test does not pass if

  • I console.log activeWallet...which is then printed as false.
  • I delete all the other tests in this file.
  • Jest is updated
60 ↗(On Diff #43957)

walletState is available in result.current, but it is not what we expect to change based on processChronikWsMsg receiving an AddedToMempool msg.

We want to test that the walletRefreshInterval has adjusted, but this is not available in result.current. So, we need to use a different testing approach or library to access this field.

393 ↗(On Diff #43957)

This test "passes" but it is not clear it is doing what we want. The states it is checking are initialized to the values it is checking. So perhaps the msg was not received or the component did not render correctly.

Misleading test.

33 ↗(On Diff #43956)

this test fails if other tests in this file are removed. So, it's hitting some kind of timing condition

emack added a subscriber: emack.

See https://reviews.bitcoinabc.org/D15079#change-FQ7xkm8tTewN for new approach to testing localForage interactions for feedback

This revision is now accepted and ready to land.Jan 6 2024, 00:47
This revision was automatically updated to reflect the committed changes.