Repository navigation
Query Hooks Improvements #5681
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
+4,404
−2,086
Merged
Query Hooks Improvements #5681
Changes from 35 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
d9c10a3
Change: Split targets query hooks into two modules
bjoernricks b9c267e
Change: Split users query hooks into two modules
bjoernricks c4a60c1
Change: Add Ticket clone and delete success messages to query hooks
bjoernricks 559cca4
test: Update Group and Role query hook tests
bjoernricks 60da0ac
Change: Add User clone and delete success messages to query hooks
bjoernricks 8254800
Add query hooks for Target
bjoernricks 2784fcd
Change: Allow to pass a response or the data directly to goToDetails
bjoernricks 0359edc
Change: Use new target query hooks in TargetComponent
bjoernricks b274ff6
Change deletePortRange command to just delete the port range
bjoernricks db2e122
Add query hooks for port list handling
bjoernricks dee5670
Change: Adapt PortListComponent to use new port list query hooks
bjoernricks e0e2d8b
Add first query hooks for credentials
bjoernricks 0383de3
Change: Use new port list and credential query hooks
bjoernricks 211cdfb
test: Improve organization of query hook tests for users
bjoernricks 1b41955
Update and fix TargetDetailsPage test
bjoernricks 76e4085
Change: Split query hooks for agent groups into two modules
bjoernricks 5bb8726
Change: Use useCloneMutation for all useClone* mutations
bjoernricks a3a116a
Change: Use useCreateMutation for all useCreate* mutations
bjoernricks fae6fe6
Change: Make input type of useDeleteMutation generic
bjoernricks 4ddaffa
Change: Make inheritorId for deleting a user optional
bjoernricks acc7bbf
Change: Improve types for generic query hooks which have a success me…
bjoernricks 573c5fd
Change: Update and improve existing query hooks
bjoernricks b80ca2a
Adapt components to query hook changes
bjoernricks 483be75
Change: Split tag query hooks into two modules
bjoernricks da6d9ff
Change: Split agent query hooks into two modules
bjoernricks 1fb4be5
Change: Split audit query hooks into two modules
bjoernricks 3d8bfc5
Change: Split credential store query hooks into two modules
bjoernricks b7eb6f0
Change: Split oci image target query hooks into two modules
bjoernricks 83481a7
Change: Split policy query hooks into two modules
bjoernricks 140beb4
Change: Split web application target query hooks into two modules
bjoernricks 999e6e8
Change WebAppliactionTargetCommand to return void from save method
bjoernricks f07bef8
Add type for CredentialStoreCommand verify params
bjoernricks dbca7e9
Improve credential store test expectations
bjoernricks d95c145
Change: Unify params and return values of single entity query hooks
bjoernricks fba6bb6
Change: Update importing a port list
bjoernricks 0525f98
Update public/locales/gsa-it.json
bjoernricks 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
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
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
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,97 @@ | ||
| /* SPDX-FileCopyrightText: 2026 Greenbone AG | ||
| * | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| import {describe, expect, test, testing} from '@gsa/testing'; | ||
| import {fireEvent, rendererWith, screen, waitFor} from 'web/testing'; | ||
| import {createSession} from 'gmp/testing'; | ||
| import { | ||
| useDeleteAgent, | ||
| useDownloadAgentSupportBundle, | ||
| useModifyAgent, | ||
| } from 'web/hooks/use-query/agent'; | ||
|
|
||
| const createGmp = () => ({ | ||
| session: createSession({token: 'test-token'}), | ||
| settings: {}, | ||
| agent: { | ||
| save: testing.fn().mockResolvedValue(undefined), | ||
| delete: testing.fn().mockResolvedValue(undefined), | ||
| downloadSupportBundle: testing | ||
| .fn() | ||
| .mockResolvedValue({data: new ArrayBuffer(0)}), | ||
| }, | ||
| }); | ||
|
|
||
| describe('useModifyAgent', () => { | ||
| test('should save an agent', async () => { | ||
| const gmp = createGmp(); | ||
| const {render} = rendererWith({gmp, router: true}); | ||
| const input = {agentsIds: ['agent-1'], authorized: true}; | ||
| const TestComponent = () => { | ||
| const mutation = useModifyAgent(); | ||
| return <button onClick={() => mutation.mutate(input)}>Save</button>; | ||
| }; | ||
|
|
||
| render(<TestComponent />); | ||
| fireEvent.click(screen.getByRole('button', {name: 'Save'})); | ||
| await waitFor(() => { | ||
| expect(gmp.agent.save.mock.calls[0][0]).toEqual(input); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('useDeleteAgent', () => { | ||
| test('should delete an agent', async () => { | ||
| const gmp = createGmp(); | ||
| const {render} = rendererWith({gmp, router: true}); | ||
| const TestComponent = () => { | ||
| const mutation = useDeleteAgent({}); | ||
| return ( | ||
| <button | ||
| onClick={() => | ||
| mutation.mutate({ | ||
| id: 'agent-1', | ||
| name: 'Deleted Agent', | ||
| }) | ||
| } | ||
| > | ||
| Delete | ||
| </button> | ||
| ); | ||
| }; | ||
|
|
||
| render(<TestComponent />); | ||
| fireEvent.click(screen.getByRole('button', {name: 'Delete'})); | ||
| await waitFor(() => { | ||
| expect(gmp.agent.delete).toHaveBeenCalledWith({id: 'agent-1'}); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('useDownloadAgentSupportBundle', () => { | ||
| test('should download an agent support bundle', async () => { | ||
| const gmp = createGmp(); | ||
| const {render} = rendererWith({gmp, router: true}); | ||
| const TestComponent = () => { | ||
| const mutation = useDownloadAgentSupportBundle(); | ||
| return ( | ||
| <button | ||
| onClick={() => mutation.mutate({id: 'agent-1', encryption: false})} | ||
| > | ||
| Download | ||
| </button> | ||
| ); | ||
| }; | ||
|
|
||
| render(<TestComponent />); | ||
| fireEvent.click(screen.getByRole('button', {name: 'Download'})); | ||
| await waitFor(() => { | ||
| expect(gmp.agent.downloadSupportBundle).toHaveBeenCalledWith( | ||
| 'agent-1', | ||
| false, | ||
| ); | ||
| }); | ||
| }); | ||
| }); |
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.