Repository navigation
fix(agent-settings): toggles that open by themselves still close #3276
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
4f4411b
fix(agent-settings): toggles that open by themselves still close
lilyshen0722 e9ea844
fix(agent-settings): a forbidden grants reload clears any revoke in f…
lilyshen0722 0a17fd7
fix(agent-settings): each reason to open a panel opens it on its own
lilyshen0722 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { renderHook, act } from '@testing-library/react'; | ||
| import { useOpensOnDemand } from '../hooks/useOpensOnDemand'; | ||
|
|
||
| type Demands = { a: unknown; b?: unknown }; | ||
| const render = (initial: Demands) => renderHook(({ a, b }: Demands) => useOpensOnDemand(a, b), { initialProps: initial }); | ||
|
|
||
| describe('useOpensOnDemand', () => { | ||
| it('starts open when a demand already holds, closed otherwise', () => { | ||
| expect(render({ a: 'error' }).result.current[0]).toBe(true); | ||
| expect(render({ a: null }).result.current[0]).toBe(false); | ||
| }); | ||
|
|
||
| it('stays closed while the demand holds after the reader closes it, and reopens when it rises again', () => { | ||
| const { result, rerender } = render({ a: null }); | ||
| rerender({ a: 'error' }); | ||
| expect(result.current[0]).toBe(true); | ||
| act(() => result.current[1](false)); | ||
| rerender({ a: 'error' }); | ||
| expect(result.current[0]).toBe(false); | ||
| rerender({ a: null }); | ||
| rerender({ a: 'again' }); | ||
| expect(result.current[0]).toBe(true); | ||
| }); | ||
|
|
||
| it('a second demand rising opens the panel even while the first still holds', () => { | ||
| const { result, rerender } = render({ a: 'confirm', b: null }); | ||
| act(() => result.current[1](false)); | ||
| rerender({ a: 'confirm', b: 'key' }); | ||
| expect(result.current[0]).toBe(true); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: Team-Commonly/commonly
Length of output: 18304
Script executed:
Repository: Team-Commonly/commonly
Length of output: 38171
Script executed:
Repository: Team-Commonly/commonly
Length of output: 28143
Script executed:
Repository: Team-Commonly/commonly
Length of output: 10363
Exercise the 403 cleanup with pending revoke state.
The named test does not detect removal of either cleanup assignment.
beforeEachmakes the revoke succeed, sorevokeErroris empty andconfirmGrantIdis cleared before the 403 reload.First make the revoke POST fail and retain both states. Then trigger a reload while the same row remains mounted, return 403, restore a successful response, and trigger the reload again. Changing the
AuthContexttoken is a valid test trigger because it recreatesuseV2Apiand rerunsload. Assert that neither the revoke error nor the confirmation returns. The failed revoke itself does not callload().There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right. The default revoke succeeds, so both states are already clear before the 403 reload, and the test would still pass with either clear removed. The behaviour is correct, but this test doesn't pin it. This PR is already in the merge queue at a gated head, so the stronger test goes in a follow-up: fail the revoke, keep the confirm and the error, reload to a 403 by swapping the auth token, then reload again successfully and assert neither comes back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lilyshen0722 Understood. This is a test-coverage gap, not a confirmed runtime defect.
The follow-up plan targets the missing coverage. The finding remains unresolved because the test is still pending. The retrieved repository rubric requires regression tests in the same change, so deferral does not satisfy that requirement.
Would you like me to open a GitHub issue for the follow-up, linked to this thread?
Learnings used
You are interacting with an AI system.