Page MenuHomePhabricator

[Cashtab] Better testing for Home.js screen
ClosedPublic

Authored by bytesofman on Jan 18 2024, 20:44.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABCd8982267b961: [Cashtab] Better testing for Home.js screen
Summary

Update integration tests for Home screen

Snapshot tests are using bad mocks and not actually testing anything. Add some useful tests.

Test Plan

npm test

Diff Detail

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

Event Timeline

Fabien added inline comments.
cashtab/src/components/Home/__tests__/Home.test.js
41 ↗(On Diff #44337)

why are you adding new code with a "deprecated" comment ?

bytesofman marked an inline comment as done.

remove deprecated mock methods

cashtab/src/components/Home/__tests__/Home.test.js
41 ↗(On Diff #44337)

copypasta from the above source url. Without this routine, was getting a common error arising from not having the window object outside a web browser.

Removing the deprecated ones everything still works, so, removed.

deprecated comments back in

cashtab/src/components/Home/__tests__/Home.test.js
41 ↗(On Diff #44337)

Removing these lines from SendXec.test.js or SendTokenValidation.test.js causes test to fail. They are likely still being used by antd components so need to be mocked.

Leaving them here so that the link describing where it came from is consistent with the text.

Getting rid of antd would be a big win for Cashtab but that will take some time.

emack requested changes to this revision.Jan 19 2024, 13:16
emack added a subscriber: emack.
emack added inline comments.
cashtab/src/components/Home/__tests__/Home.test.js
158 ↗(On Diff #44342)

Is there a way to verify that <HiddenBalanceCtn> is rendered (instread of 'balance-header-rendered') when cashtabSettings.balanceVisible is false? i.e. the equivalent of render.current.statevar=false in the renderHook approach. I think that deserves its own test case.

This revision now requires changes to proceed.Jan 19 2024, 13:16
bytesofman marked an inline comment as done.
bytesofman added inline comments.
cashtab/src/components/Home/__tests__/Home.test.js
158 ↗(On Diff #44342)

Yes -- I am working on a much better way to handle this. See D15205

Will

  • Combine BalanceHeader with FiatBalanceHeader
  • TBA will prob also combine it with ZeroBalancHeader
  • the shared component is itself tested for this kind of thing
  • the component is improved (Better number formating, use of locale, etc)

Home screen should really just be testing integration stuff on home screen. The way it's written now, the balance rendering stuff is part of this. But those tests should really belong to BalanceHeader.

This revision is now accepted and ready to land.Jan 19 2024, 21:43
bytesofman marked an inline comment as done.

rebase