Page MenuHomePhabricator

[Cashtab] Upgrade to React 18
ClosedPublic

Authored by bytesofman on Jan 31 2024, 00:44.

Details

Reviewers
emack
Group Reviewers
Restricted Project
Commits
rABCf2a2d1b39abb: [Cashtab] Upgrade to React 18
Summary

Upgrade to React 18. This allows us to better maintain the dependency tree and take advantage of the latest testing libraries.

Bump jest timeout as, althought tests passed in first CI here, were flaky locally.

Add waitFor on flaky local test (available method in upgraded library).

The react hooks testing library is now part of @testing-library/react. Must use this version with React 18. So, the legacy dependency is removed, and @testing-library/react is upgraded.

Test Plan

npm test
npm run build

Diff Detail

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

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/icons@4.8.1
npm ERR!   node_modules/@ant-design/icons
npm ERR!     @ant-design/icons@"^4.3.0" from the root project
npm ERR!     @ant-design/icons@"^4.8.1" from antd@4.24.15
npm ERR!     node_modules/antd
npm ERR!       antd@"^4.9.3" from the root project
npm ERR!   48 more (@ant-design/react-slick, @rc-component/portal, ...)
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-31T00_45_57_805Z-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/icons@4.8.1
npm ERR!   node_modules/@ant-design/icons
npm ERR!     @ant-design/icons@"^4.3.0" from the root project
npm ERR!     @ant-design/icons@"^4.8.1" from antd@4.24.15
npm ERR!     node_modules/antd
npm ERR!       antd@"^4.9.3" from the root project
npm ERR!   48 more (@ant-design/react-slick, @rc-component/portal, ...)
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-31T00_46_02_182Z-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/icons@4.8.1
npm ERR!   node_modules/@ant-design/icons
npm ERR!     @ant-design/icons@"^4.3.0" from the root project
npm ERR!     @ant-design/icons@"^4.8.1" from antd@4.24.15
npm ERR!     node_modules/antd
npm ERR!       antd@"^4.9.3" from the root project
npm ERR!   48 more (@ant-design/react-slick, @rc-component/portal, ...)
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-31T00_51_45_826Z-debug-0.log
Build cashtab-tests failed with exit code 1

rebase, upgrade qrcode.react, remove react-test-renderer

Failed tests logs:

====== CashTab Unit Tests: <App /> Navigation menu routes to expected components ======
Error: expect(received).toBeInTheDocument()

received value must be an HTMLElement or an SVGElement.
Received has value: null
    at __EXTERNAL_MATCHER_TRAP__ (/work/cashtab/node_modules/expect/build/index.js:325:30)
    at Object.throwingMatcher [as toBeInTheDocument] (/work/cashtab/node_modules/expect/build/index.js:326:15)
    at Object.toBeInTheDocument (/work/cashtab/src/components/__tests__/App.test.js:148:55)

Each failure log is accessible here:
CashTab Unit Tests: <App /> Navigation menu routes to expected components

Tail of the build log:

  GoogleAnalytics.js             |   30.76 |    26.66 |      10 |      32 | 12-42,59-69,94                                                                                                                                                                                                                                                                                                                                                                   
  aliasUtils.js                  |     100 |    71.42 |     100 |     100 | 31-33                                                                                                                                                                                                                                                                                                                                                                            
  cashMethods.js                 |   94.82 |    89.59 |     100 |   94.68 | 81-83,204,229,261-262,352,388,433,503,541,598,708,728,737,760                                                                                                                                                                                                                                                                                                                    
  coininfo.js                    |       0 |        0 |       0 |       0 | 4-72                                                                                                                                                                                                                                                                                                                                                                             
  context.js                     |      60 |      100 |       0 |      60 | 8-9                                                                                                                                                                                                                                                                                                                                                                              
  debounce.js                    |       0 |        0 |       0 |       0 | 4-8                                                                                                                                                                                                                                                                                                                                                                              
  ecashCoinInfo.js               |       0 |      100 |     100 |       0 | 10-113                                                                                                                                                                                                                                                                                                                                                                           
  formatting.js                  |   77.77 |    83.33 |     100 |   77.77 | 15,25,43,53,68-70,109-111                                                                                                                                                                                                                                                                                                                                                        
  retry.js                       |       0 |        0 |       0 |       0 | 1-8                                                                                                                                                                                                                                                                                                                                                                              
  tokenMethods.js                |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                  
  transactions.js                |   44.92 |    41.66 |   66.66 |   44.92 | 79-83,90,92,94,99,111-179,188,206-248                                                                                                                                                                                                                                                                                                                                            
 src/utils/icons                 |    2.52 |        0 |       0 |    2.72 |                                                                                                                                                                                                                                                                                                                                                                                  
  cropImage.js                   |    2.27 |        0 |       0 |    2.43 | 2-78                                                                                                                                                                                                                                                                                                                                                                             
  resizeImage.js                 |    2.77 |        0 |       0 |    3.03 | 2-51                                                                                                                                                                                                                                                                                                                                                                             
  roundImage.js                  |    2.56 |        0 |       0 |    2.77 | 2-57                                                                                                                                                                                                                                                                                                                                                                             
 src/validation                  |   95.63 |     96.9 |     100 |    95.9 |                                                                                                                                                                                                                                                                                                                                                                                  
  index.js                       |   95.63 |     96.9 |     100 |    95.9 | 51-53,115-116,252,311,358,371,654-655                                                                                                                                                                                                                                                                                                                                            
 src/validation/fixtures         |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                  
  mocks.js                       |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                  
  vectors.js                     |       0 |        0 |       0 |       0 |                                                                                                                                                                                                                                                                                                                                                                                  
 src/wallet                      |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                  
  index.js                       |     100 |      100 |     100 |     100 |                                                                                                                                                                                                                                                                                                                                                                                  
 src/wallet/fixtures             |       0 |        0 |       0 |       0 |                                                                                                                                                                                                                                                                                                                                                                                  
  vectors.js                     |       0 |        0 |       0 |       0 |                                                                                                                                                                                                                                                                                                                                                                                  
---------------------------------|---------|----------|---------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

##teamcity[blockOpened name='Code Coverage Summary']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='2340']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='4684']
##teamcity[buildStatisticValue key='CodeCoverageAbsRCovered' value='1060']
##teamcity[buildStatisticValue key='CodeCoverageAbsRTotal' value='2221']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='460']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='1034']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='2300']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='4583']
##teamcity[blockClosed name='Code Coverage Summary']

Summary of all failing tests
FAIL src/hooks/__tests__/useWallet.test.js
  ● Test suite failed to run

    Cannot find module '@testing-library/react-hooks' from 'src/hooks/__tests__/useWallet.test.js'

      1 | import useWallet from '../useWallet';
    > 2 | import { renderHook, act } from '@testing-library/react-hooks';
        | ^
      3 | import mockLegacyWallets from '../__mocks__/mockLegacyWallets';
      4 | import { cashtabSettings as cashtabDefaultConfig } from 'config/cashtabSettings';
      5 | import aliasSettings from 'config/alias';

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.require (src/hooks/__tests__/useWallet.test.js:2:1)


Test Suites: 1 failed, 23 passed, 24 total
Tests:       540 passed, 540 total
Snapshots:   0 total
Time:        23.701 s
Ran all test suites.
Build cashtab-tests failed with exit code 1

bump timeout and add waitfor, reduce test flakiness when run locally

bytesofman edited the test plan for this revision. (Show Details)
bytesofman published this revision for review.Feb 1 2024, 04:52
bytesofman added inline comments.
cashtab/package.json
48 ↗(On Diff #44833)

previous was default, 5000 = 5s

cashtab/src/components/Alias/Alias.js
113 ↗(On Diff #44756)
  • delete async from useEffect block
  • Move the async logic to a different function, handleAliasWalletChange, and call that from the useEffect block
cashtab/src/index.js
2 ↗(On Diff #44833)
10 ↗(On Diff #44756)
This revision is now accepted and ready to land.Feb 1 2024, 06:51
This revision was automatically updated to reflect the committed changes.