-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: Use AccountGroup metadata for sorting in core permission helpers #29295
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
base: main
Are you sure you want to change the base?
Changes from 40 commits
d8ad969
c9a6288
70593ba
5d5cb42
79e82bb
604df80
d5e87f4
0368835
7df2bce
e2185d9
ec887ba
33bc472
45a0781
6795aff
afdd175
397d716
8fe874a
079a44f
b8c5e46
3c05cfd
9edb66d
724e71e
3203940
09e60f9
45f624c
6c8aed9
fd17a8d
65154d1
e7728c2
f0b2327
5166b38
65c7973
b7c67b3
bbffdf9
4055330
9f702c1
8ba0fcf
97c4b45
a9161a0
2341564
93431ee
a4df7df
fd55c79
ab23364
91f00b1
94f075e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1725,12 +1725,10 @@ describe('BackgroundBridge', () => { | |
|
|
||
| describe('handleSessionChangedFromSelectedAccountGroupChanges', () => { | ||
| beforeEach(() => { | ||
| jest.useFakeTimers(); | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| jest.useRealTimers(); | ||
| PermissionController.getCaveat.mockReset(); | ||
| }); | ||
|
|
||
|
|
@@ -1744,7 +1742,6 @@ describe('BackgroundBridge', () => { | |
| }); | ||
|
|
||
| bridge.handleSessionChangedFromSelectedAccountGroupChanges(); | ||
| jest.advanceTimersByTime(1000); | ||
|
|
||
| expect(bridge.multichainEngine.emit).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
@@ -1757,12 +1754,11 @@ describe('BackgroundBridge', () => { | |
| PermissionController.getCaveat.mockReturnValue(undefined); | ||
|
|
||
| bridge.handleSessionChangedFromSelectedAccountGroupChanges(); | ||
| jest.advanceTimersByTime(1000); | ||
|
|
||
| expect(bridge.multichainEngine.emit).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('calls notifyCaipAuthorizationChange with the refetched caveat value', () => { | ||
| it('calls notifyCaipAuthorizationChange with the caveat value', () => { | ||
| const url = 'https://www.mock.io'; | ||
| const bridge = setupBackgroundBridge(url); | ||
| const notifySpy = jest.spyOn(bridge, 'notifyCaipAuthorizationChange'); | ||
|
|
@@ -1802,9 +1798,7 @@ describe('BackgroundBridge', () => { | |
|
|
||
| jest.advanceTimersByTime(1000); | ||
|
|
||
| // The caveat is fetched once synchronously and once again inside the | ||
| // setTimeout so that the latest value is used when notifying. | ||
| expect(PermissionController.getCaveat).toHaveBeenCalledTimes(2); | ||
| expect(PermissionController.getCaveat).toHaveBeenCalledOnce(); | ||
| expect(notifySpy).toHaveBeenCalledWith(mockRefetchedCaveatValue); | ||
| expect(notifySpy).not.toHaveBeenCalledWith(mockInitialCaveatValue); | ||
| }); | ||
|
|
@@ -1825,18 +1819,30 @@ describe('BackgroundBridge', () => { | |
| sessionProperties: {}, | ||
| }; | ||
| PermissionController.getCaveat.mockClear(); | ||
| PermissionController.getCaveat | ||
| .mockReturnValueOnce({ | ||
| type: Caip25CaveatType, | ||
| value: mockCaveatValue, | ||
| }) | ||
| .mockReturnValueOnce(undefined); | ||
| PermissionController.getCaveat.mockReturnValueOnce({ | ||
| type: Caip25CaveatType, | ||
| value: mockCaveatValue, | ||
| }); | ||
|
|
||
| bridge.handleSessionChangedFromSelectedAccountGroupChanges(); | ||
|
|
||
| jest.advanceTimersByTime(1000); | ||
| expect(PermissionController.getCaveat).toHaveBeenCalledTimes(1); | ||
| expect(notifySpy).toHaveBeenCalledWith(mockCaveatValue); | ||
| }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test name contradicts its actual assertionMedium Severity The test is named "does not call notifyCaipAuthorizationChange if the caveat is revoked before the setTimeout fires" but line 1830 asserts Reviewed by Cursor Bugbot for commit 2341564. Configure here. |
||
|
|
||
| it('rethrows unexpected errors from getCaveat', () => { | ||
| const url = 'https:www.mock.io'; | ||
| const bridge = setupBackgroundBridge(url); | ||
| const notifySpy = jest.spyOn(bridge, 'notifyCaipAuthorizationChange'); | ||
|
|
||
| const unexpectedError = new Error('unexpected'); | ||
| PermissionController.getCaveat.mockImplementation(() => { | ||
| throw unexpectedError; | ||
| }); | ||
|
|
||
| expect(PermissionController.getCaveat).toHaveBeenCalledTimes(2); | ||
| expect(() => | ||
| bridge.handleSessionChangedFromSelectedAccountGroupChanges(), | ||
| ).toThrow(unexpectedError); | ||
| expect(notifySpy).not.toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.