Page MenuHomePhabricator

[Cashtab] Expose savedWallets in wallet context
AbandonedPublicDraft

Authored by bytesofman on Feb 10 2024, 23:46.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

The original implementation of this function is bad. Good case study for what can happen when, instead of unit and integration tests, you have console.log statements and long manually testing steps.

Test Plan

npm test

Diff Detail

Repository
rABC Bitcoin ABC
Branch
use-context-savedWallets-config
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 27060
Build 53686: Build Diffcashtab-tests
Build 53685: arc lint + arc unit

Event Timeline

  1. get it to work
  2. split into smaller diffs

Failed tests logs:

====== CashTab Unit Tests: <Configure /> We can add a savedWallet as a contact ======
TestingLibraryElementError: Unable to find an element with the text: Saved wallets. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

Ignored nodes: comments, script, style
<body>
  <div
    class="ant-notification ant-notification-topRight css-dev-only-do-not-override-1rqnfsa ant-notification-stack ant-notification-stack-expanded"
    style="right: 0px; top: 24px;"
  >
    <div
      class="ant-notification-notice-wrapper"
      style="transform: translate3d(0, 0, 0);"
    >
      <div
        class="ant-notification-notice ant-notification-notice-success ant-notification-notice-closable"
      >
        <div
          class="ant-notification-notice-content"
        >
          <div
            class="ant-notification-notice-with-icon"
            role="alert"
          >
            <span
              aria-label="check-circle"
              class="anticon anticon-check-circle ant-notification-notice-icon ant-notification-notice-icon-success"
              role="img"
            >
              <svg
                aria-hidden="true"
                data-icon="check-circle"
                fill="currentColor"
                focusable="false"
                height="1em"
                viewBox="64 64 896 896"
                width="1em"
              >
                <path
                  d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z"
                />
              </svg>
            </span>
            <div
              class="ant-notification-notice-message"
            >
              Success
            </div>
            <div
              class="ant-notification-notice-description"
            >
              ecash:qqxefwshnmppcsjp0fc6w7rnkdsexc7cagdus7ugd0 added to Contact List
            </div>
          </div>
        </div>
        <a
          class="ant-notification-notice-close"
          tabindex="0"
        >
          <span
            class="ant-notification-notice-close-x"
          >
            <span
              aria-label="close"
              class="anticon anticon-close ant-notification-notice-close-icon"
              role="img"
            >
              <svg
                aria-hidden="true"
                data-icon="close"
                fill="currentColor"
                fill-rule="evenodd"
                focusable="false"
                height="1em"
                viewBox="64 64 896 896"
                width="1em"
              >
                <path
                  d="M799.86 166.31c.02 0 .04.02.08.06l57.69 57.7c.04.03.05.05.06.08a.12.12 0 010 .06c0 .03-.02.05-.06.09L569.93 512l287.7 287.7c.04.04.05.06.06.09a.12.12 0 010 .07c0 .02-.02.04-.06.08l-57.7 57.69c-.03.04-.05.05-.07.06a.12.12 0 01-.07 0c-.03 0-.05-.02-.09-.06L512 569.93l-287.7 287.7c-.04.04-.06.05-.09.06a.12.12 0 01-.07 0c-.02 0-.04-.02-.08-.06l-57.69-57.7c-.04-.03-.05-.05-.06-.07a.12.12 0 010-.07c0-.03.02-.05.06-.09L454.07 512l-287.7-287.7c-.04-.04-.05-.06-.06-.09a.12.12 0 010-.07c0-.02.02-.04.06-.08l57.7-57.69c.03-.04.05-.05.07-.06a.12.12 0 01.07 0c.03 0 .05.02.09.06L512 454.07l287.7-287.7c.04-.04.06-.05.09-.06a.12.12 0 01.07 0z"
                />
              </svg>
            </span>
          </span>
        </a>
      </div>
    </div>
  </div>
  <div />
  <div>
    <div
      class="sc-cvbbAY blOKNt"
      data-testid="configure-ctn"
    >
      <div
        class="sc-jnlKLf fbDIoy"
      >
        <h2>
          <span
            aria-label="copy"
            class="anticon anticon-copy sc-bwzfXH gJwWNq"
            role="img"
          >
            <svg
              aria-hidden="true"
              data-icon="copy"
              fill="currentColor"
              focusable="false"
              height="1em"
              viewBox="64 64 896 896"
              width="1em"
            >
              <path
                d="M832 64H296c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h496v688c0 4.4 3.6 8 8 8h56c4.4 0 8-3.6 8-8V96c0-17.7-14.3-32-32-32zM704 192H192c-17.7 0-32 14.3-32 32v530.7c0 8.5 3.4 16.6 9.4 22.6l173.3 173.3c2.2 2.2 4.7 4 7.4 5.5v1.9h4.2c3.5 1.3 7.2 2 11 2H704c17.7 0 32-14.3 32-32V224c0-17.7-14.3-32-32-32zM350 856.2L263.9 770H350v86.2zM664 888H414V746c0-22.1-17.9-40-40-40H232V264h432v624z"
              />
            </svg>
          </span>
           Backup your wallet
        </h2>
        <div
          class="ant-alert ant-alert-warning ant-alert-with-description css-dev-only-do-not-override-1rqnfsa"
          data-show="true"
          role="alert"
          style="margin-bottom: 12px;"
        >
          <span
            aria-label="exclamation-circle"
            class="anticon anticon-exclamation-circle ant-alert-icon"
            role="img"
          >
            <svg
              aria-hidden="true"
              data-icon="exclamation-circle"
              fill="currentColor"
              focusable="false"
              height="1em"
              viewBox="64 64 896 896"
              width="1em"
            >
              <path
   ...
    at Object.getElementError (/work/cashtab/node_modules/@testing-library/dom/dist/config.js:37:19)
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:76:38
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:52:17
    at /work/cashtab/node_modules/@testing-library/dom/dist/query-helpers.js:95:19
    at Object.getByText (/work/cashtab/src/components/Configure/__tests__/Configure.test.js:359:51)

Each failure log is accessible here:
CashTab Unit Tests: <Configure /> We can add a savedWallet as a contact