Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: recovery loading + trigger #2850

Merged
merged 5 commits into from
Nov 23, 2023
Merged

Conversation

iamacook
Copy link
Member

What it solves

Refetching recovery logic after interaction with the module.

How this PR fixes it

The data loading has been refactored into a provider that exposes a refetch function that is passed to the relevant transaction dispatchers for direct module interaction and called after transaction success.

For Safe transactions, the to address is dispatched alongside the TxEvent.PROCESSED event and, providing it matches a recovery module, it refetches the recovery data.

Note: this does not work for relayed transactions as we do not readily have the to address available in the logic flow, which may require a larger refactor. This has been marked with a comment for now to revisit.

How to test it

Observe data refetching when editing a recovery module, as well as skipping a recovery attempt.

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

@iamacook iamacook self-assigned this Nov 22, 2023
Copy link

github-actions bot commented Nov 22, 2023

Branch preview

✅ Deploy successful!

https://refactor_recovery_loading--walletweb.review-wallet-web.5afe.dev

Copy link

github-actions bot commented Nov 22, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

Copy link

github-actions bot commented Nov 22, 2023

Coverage report

❌ An unexpected error occurred. For more details, check console

Error: The process '/usr/local/bin/yarn' failed with exit code 1
St.
Category Percentage Covered / Total
🟡 Statements
75.29% (-0.02% 🔻)
10761/14293
🔴 Branches
50.01% (-0.03% 🔻)
2183/4365
🔴 Functions
57.84% (-0.07% 🔻)
1609/2782
🟡 Lines
76.75% (-0.04% 🔻)
9757/12712
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / selectors.ts
100% 100% 100% 100%
🟢
... / index.tsx
93.55% 80% 83.33% 93.33%
🟢
... / useRecoveryState.ts
100% 100% 100% 100%
🟢
... / useDelayModifiers.ts
100% 100% 100% 100%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢 src/store/index.ts
98.04% (-0.04% 🔻)
100% 100% 100%
🔴
... / dispatch.ts
44.51% (-1.98% 🔻)
55% (-6.11% 🔻)
25% (-4.63% 🔻)
43.23% (-2.04% 🔻)
🟢
... / recovery-state.ts
95% (-3.25% 🔻)
83.33%
85.71% (-14.29% 🔻)
96.36% (-1.75% 🔻)
🟢
... / index.tsx
90% (-1.67% 🔻)
100%
80% (-6.67% 🔻)
91.53% (-1.69% 🔻)
🔴
... / useRecoveryQueue.ts
36.36% (-13.64% 🔻)
0% 0%
36.36% (-13.64% 🔻)
🟢
... / index.tsx
90%
66.67% (-4.76% 🔻)
71.43% (-3.57% 🔻)
89.66% (+0.37% 🔼)

Test suite run failed

Failed tests: 5/1219. Failed suites: 2/174.
  ● RecoveryModal › component › should render the in-progress modal when there is a queue for guardians

    expect(received).toBeTruthy()

    Received: null

      76 |
      77 |       expect(queryByText('Test')).toBeTruthy()
    > 78 |       expect(queryByText('Account recovery in progress')).toBeTruthy()
         |                                                           ^
      79 |     })
      80 |
      81 |     it('should render the in-progress modal when there is a queue for owners', () => {

      at Object.toBeTruthy (src/components/recovery/RecoveryModal/index.test.tsx:78:59)

  ● RecoveryModal › component › should render the in-progress modal when there is a queue for owners

    expect(received).toBeTruthy()

    Received: null

      90 |
      91 |       expect(queryByText('Test')).toBeTruthy()
    > 92 |       expect(queryByText('Account recovery in progress')).toBeTruthy()
         |                                                           ^
      93 |     })
      94 |
      95 |     it('should render the proposal modal when there is no queue for guardians', () => {

      at Object.toBeTruthy (src/components/recovery/RecoveryModal/index.test.tsx:92:59)

  ● RecoveryModal › component › should close the modal when the user navigates away

    expect(received).toBeTruthy()

    Received: null

      143 |
      144 |       expect(queryByText('Test')).toBeTruthy()
    > 145 |       expect(queryByText('Account recovery in progress')).toBeTruthy()
          |                                                           ^
      146 |
      147 |       // Trigger the route change
      148 |       mockUseRouter.events.on.mock.calls[0][1]()

      at Object.toBeTruthy (src/components/recovery/RecoveryModal/index.test.tsx:145:59)


  ● RecoveryHeader › should render the in-progress widget if there is a queue for guardians

    expect(received).toBeTruthy()

    Received: null

      29 |     )
      30 |
    > 31 |     expect(queryByText('Account recovery in progress')).toBeTruthy()
         |                                                         ^
      32 |   })
      33 |
      34 |   it('should render the in-progress widget if there is a queue for owners', () => {

      at Object.toBeTruthy (src/components/dashboard/RecoveryHeader/index.test.tsx:31:57)

  ● RecoveryHeader › should render the in-progress widget if there is a queue for owners

    expect(received).toBeTruthy()

    Received: null

      42 |     )
      43 |
    > 44 |     expect(queryByText('Account recovery in progress')).toBeTruthy()
         |                                                         ^
      45 |   })
      46 |
      47 |   it('should render the proposal widget when there is no queue for guardians', () => {

      at Object.toBeTruthy (src/components/dashboard/RecoveryHeader/index.test.tsx:44:57)

Report generated by 🧪jest coverage report action from fbccae4

Copy link
Member

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
Only two suggestions:

  • Rename the context to just RecoveryContext
  • Add a helper hook to wrap useContext(RecoveryLoaderContext).state

@iamacook
Copy link
Member Author

Looks good. Only two suggestions:

* Rename the context to just RecoveryContext

* Add a helper hook to wrap `useContext(RecoveryLoaderContext).state`

I've included both adjustments in fbccae4.

@iamacook iamacook merged commit 2a3ad26 into recovery-epic Nov 23, 2023
5 of 12 checks passed
@iamacook iamacook deleted the refactor-recovery-loading branch November 23, 2023 10:44
@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants