-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
ref(grouplist): Refactor GroupList to use useApiQuery #105688
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
Conversation
malwilley
commented
Jan 5, 2026
- Fixes a bug I was encountering due to GroupStore
- Gets us a tiny bit closer to removing GroupStore
- GroupList responses are now cached
- Testing components with GroupList is simpler now since you don't need to specify the URL params in the mock
| it('renders custom error when query has boolean logic', async () => { | ||
| const renderErrorMessage = jest.fn(() => <div>custom error</div>); | ||
| const issuesRequest = MockApiClient.addMockResponse({ | ||
| url: `${issuesUrl}?${qs.stringify({...defaultQueryParams, query: 'issue.id:1'})}`, |
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.
Most of the file changes here are simplifying the mocks.
/organizations/org-slug/issues/?query=foo&cursor=bar -> /organizations/org-slug/issues/
| * If you have access to the group data, it is preferred to pass it in as a prop here. | ||
| * Otherwise, the group data will come from the deprecated GroupStore. | ||
| */ | ||
| group?: Group; |
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.
Needed to modify StreamGroup since it was looking directly at the store. This prop will help us get off of GroupStore if we add it to all the existing usages
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.
This is a really good call, I wish there was a way in TS to mark it as 'will-be-required-in-the-future', or 'deprecated-to-omit'
| query: 'error.unhandled:true is:unresolved', | ||
| }), | ||
| }) | ||
| ); |
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.
Test assertion verifies wrong query after clicking "New Issues"
The test clicks on "New Issues" segment but then asserts that the API was called with query: 'error.unhandled:true is:unresolved', which is the IssuesQuery.UNHANDLED value. After clicking "New Issues", the expected query should be 'is:unresolved is:for_review' (IssuesQuery.NEW). Since toHaveBeenCalledWith checks if any call matched, this assertion passes due to the initial render (which uses UNHANDLED by default), not because clicking "New Issues" actually works. The test doesn't verify the intended behavior.
|
note: we talked about how assignee selector would work in person. Worth double checking that assignee isn't putting that into only group store. |
| * If you have access to the group data, it is preferred to pass it in as a prop here. | ||
| * Otherwise, the group data will come from the deprecated GroupStore. | ||
| */ | ||
| group?: Group; |
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.
This is a really good call, I wish there was a way in TS to mark it as 'will-be-required-in-the-future', or 'deprecated-to-omit'
static/app/views/issueDetails/groupRelatedIssues/index.spec.tsx
Outdated
Show resolved
Hide resolved
| }); | ||
|
|
||
| beforeEach(() => { | ||
| // NOTE: This mock is jank. `GroupList` concatenates the query string with the URL. This means we have to mock the full URL including the parameters. There are a few other tests that have to do the same. |
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.
🔥