Page MenuHomePhabricator

[Cashtab] Helper method for initializing integration tests
ClosedPublic

Authored by bytesofman on Feb 12 2024, 20:53.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABCd0fafffdf90d: [Cashtab] Helper method for initializing integration tests
Summary

Cashtab has added automated integration testing over the past few weeks. This implementation has involved some iterative discoveries and best practices.

Now that it is up and working, it's time to optimize and standardize the tests, so that it is easier to add new cases (and we do not end up accidentally testing different implementations of tests instead of test cases).

Add a helper function that initializes a mock-chronik-client instance with the data required to sync a cashtab wallet to the eCash chain.

Implement in AppIntegrations.test.js (for now, will be extended throughout the app in later diffs)

Test Plan

npm test

Diff Detail

Event Timeline

Tail of the build log:

    > 15 |     }
         |      ^
      16 |
      17 |     async teardown() {
      18 |         await super.teardown();

      at new CustomEnvironment (config/jest/custom-environment.js:15:35)

FAIL src/components/Common/__tests__/QRCode.test.js
  ● Test suite failed to run

    ReferenceError: structuredClone is not defined

      13 |         this.global.Uint8Array = Uint8Array;
      14 |         this.global.ArrayBuffer = ArrayBuffer;
    > 15 |     }
         |      ^
      16 |
      17 |     async teardown() {
      18 |         await super.teardown();

      at new CustomEnvironment (config/jest/custom-environment.js:15:35)

FAIL src/components/Common/__tests__/ScanQRCode.test.js
  ● Test suite failed to run

    ReferenceError: structuredClone is not defined

      13 |         this.global.Uint8Array = Uint8Array;
      14 |         this.global.ArrayBuffer = ArrayBuffer;
    > 15 |     }
         |      ^
      16 |
      17 |     async teardown() {
      18 |         await super.teardown();

      at new CustomEnvironment (config/jest/custom-environment.js:15:35)

FAIL src/utils/__tests__/aliasUtils.test.js
  ● Test suite failed to run

    ReferenceError: structuredClone is not defined

      13 |         this.global.Uint8Array = Uint8Array;
      14 |         this.global.ArrayBuffer = ArrayBuffer;
    > 15 |     }
         |      ^
      16 |
      17 |     async teardown() {
      18 |         await super.teardown();

      at new CustomEnvironment (config/jest/custom-environment.js:15:35)


Test Suites: 30 failed, 30 total
Tests:       0 total
Snapshots:   0 total
Time:        5.419 s
Ran all test suites.
Build cashtab-tests failed with exit code 1

Tail of the build log:

    > 15 |     }
         |      ^
      16 |
      17 |     async teardown() {
      18 |         await super.teardown();

      at new CustomEnvironment (config/jest/custom-environment.js:15:35)

FAIL src/components/Etokens/__tests__/CreateTokenForm.test.js
  ● Test suite failed to run

    ReferenceError: structuredClone is not defined

      13 |         this.global.Uint8Array = Uint8Array;
      14 |         this.global.ArrayBuffer = ArrayBuffer;
    > 15 |     }
         |      ^
      16 |
      17 |     async teardown() {
      18 |         await super.teardown();

      at new CustomEnvironment (config/jest/custom-environment.js:15:35)

FAIL src/slpv1/__tests__/index.test.js
  ● Test suite failed to run

    ReferenceError: structuredClone is not defined

      13 |         this.global.Uint8Array = Uint8Array;
      14 |         this.global.ArrayBuffer = ArrayBuffer;
    > 15 |     }
         |      ^
      16 |
      17 |     async teardown() {
      18 |         await super.teardown();

      at new CustomEnvironment (config/jest/custom-environment.js:15:35)

FAIL src/components/Common/__tests__/ScanQRCode.test.js
  ● Test suite failed to run

    ReferenceError: structuredClone is not defined

      13 |         this.global.Uint8Array = Uint8Array;
      14 |         this.global.ArrayBuffer = ArrayBuffer;
    > 15 |     }
         |      ^
      16 |
      17 |     async teardown() {
      18 |         await super.teardown();

      at new CustomEnvironment (config/jest/custom-environment.js:15:35)


Test Suites: 30 failed, 30 total
Tests:       0 total
Snapshots:   0 total
Time:        5.516 s
Ran all test suites.
Build cashtab-tests failed with exit code 1
The build failed due to an unexpected infrastructure outage. The administrators have been notified to investigate. Sorry for the inconvenience.
bytesofman added inline comments.
cashtab/config/jest/custom-environment.js
8 ↗(On Diff #45166)

Started hitting this error when trying to test initializeCashtabStateForTests

https://github.com/jsdom/jsdom/issues/3363

So, update our custom test environment to handle this case. Change filename -- we were using a custom env before, but just to patch one other issue.

This revision is now accepted and ready to land.Feb 15 2024, 13:16