-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- controller delete by id - use case delete by id - test delete by id - front action delete
- Loading branch information
1 parent
609ff13
commit 975f837
Showing
5 changed files
with
75 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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
34 changes: 34 additions & 0 deletions
34
...t/kotlin/fr/gouv/gmampa/rapportnav/domain/use_cases/mission/action/DeleteNavActionTest.kt
This file contains 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,34 @@ | ||
package fr.gouv.gmampa.rapportnav.domain.use_cases.mission.action | ||
|
||
import fr.gouv.dgampa.rapportnav.domain.repositories.mission.action.INavMissionActionRepository | ||
import fr.gouv.dgampa.rapportnav.domain.use_cases.mission.action.v2.DeleteNavAction | ||
import org.assertj.core.api.Assertions.assertThatNoException | ||
import org.junit.jupiter.api.Test | ||
import org.mockito.Mockito.`when` | ||
import org.mockito.kotlin.anyOrNull | ||
import org.mockito.kotlin.doNothing | ||
import org.mockito.kotlin.doReturn | ||
import org.springframework.boot.test.context.SpringBootTest | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import org.springframework.test.context.ContextConfiguration | ||
import java.util.* | ||
|
||
|
||
@SpringBootTest(classes = [DeleteNavAction::class]) | ||
@ContextConfiguration(classes = [DeleteNavAction::class]) | ||
class DeleteNavActionTest { | ||
@MockBean | ||
private lateinit var missionActionRepository: INavMissionActionRepository | ||
|
||
@Test | ||
fun `test execute delete nav action`() { | ||
val actionId = UUID.randomUUID() | ||
doNothing().`when`(missionActionRepository).deleteById(actionId) | ||
|
||
val deleteNavAction = DeleteNavAction( | ||
missionActionRepository = missionActionRepository | ||
) | ||
deleteNavAction.execute(actionId) | ||
assertThatNoException() | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
frontend/src/v2/features/common/services/use-delete-mission-action.tsx
This file contains 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,20 @@ | ||
import { useMutation, UseMutationResult, useQueryClient } from '@tanstack/react-query' | ||
|
||
import axios from '../../../../query-client/axios' | ||
|
||
const useDeleteActionMutation = (missionId: number): UseMutationResult<void, Error, string, unknown> => { | ||
const queryClient = useQueryClient() | ||
|
||
const deleteAction = (actionId: string): Promise<void> => | ||
axios.delete(`missions/${missionId}/actions/${actionId}`).then(response => response.data) | ||
|
||
const mutation = useMutation({ | ||
mutationFn: deleteAction, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: ['actions'] }) | ||
} | ||
}) | ||
return mutation | ||
} | ||
|
||
export default useDeleteActionMutation |
16 changes: 13 additions & 3 deletions
16
frontend/src/v2/features/mission-action/components/elements/mission-action-header-action.tsx
This file contains 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