-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(app): Support "resume from recovery assuming false positive"…
… action (#16601) Closes EXEC-791 See #16556 and the linked ticket for details concerning the reasoning for implementing these changes. When skipping a step in Error Recovery, the FE essentially calls two commands: handleIgnoringErrorKind, which deals with updating the recovery policy, and skipFailedCommand, which does the skipping. By using isAssumeFalsePositiveResumeKind, we can conditionally determine which policy ifMatch criteria to use, and we can determine which error recovery resume kind to dispatch to the server.
- Loading branch information
Showing
10 changed files
with
288 additions
and
11 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
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
80 changes: 80 additions & 0 deletions
80
...api-client/src/runs/__tests__/useResumeFromRecoveryAssumingFalsePositiveMutation.test.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,80 @@ | ||
import { describe, it, expect, beforeEach, vi } from 'vitest' | ||
import { QueryClient, QueryClientProvider } from 'react-query' | ||
import { act, renderHook, waitFor } from '@testing-library/react' | ||
|
||
import { createRunAction } from '@opentrons/api-client' | ||
|
||
import { useHost } from '../../api' | ||
import { useResumeRunFromRecoveryAssumingFalsePositiveMutation } from '..' | ||
|
||
import { RUN_ID_1, mockResumeFromRecoveryAction } from '../__fixtures__' | ||
|
||
import type * as React from 'react' | ||
import type { HostConfig, Response, RunAction } from '@opentrons/api-client' | ||
import type { UseResumeRunFromRecoveryAssumingFalsePositiveMutationOptions } from '../useResumeFromRecoveryAssumingFalsePositiveMutation' | ||
|
||
vi.mock('@opentrons/api-client') | ||
vi.mock('../../api/useHost') | ||
|
||
const HOST_CONFIG: HostConfig = { hostname: 'localhost' } | ||
|
||
describe('useResumeRunFromRecoveryAssumingFalsePositiveMutation hook', () => { | ||
let wrapper: React.FunctionComponent< | ||
{ | ||
children: React.ReactNode | ||
} & UseResumeRunFromRecoveryAssumingFalsePositiveMutationOptions | ||
> | ||
|
||
beforeEach(() => { | ||
const queryClient = new QueryClient() | ||
const clientProvider: React.FunctionComponent< | ||
{ | ||
children: React.ReactNode | ||
} & UseResumeRunFromRecoveryAssumingFalsePositiveMutationOptions | ||
> = ({ children }) => ( | ||
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider> | ||
) | ||
wrapper = clientProvider | ||
}) | ||
|
||
it('should return no data when calling resumeRunFromRecoveryAssumingFalsePositive if the request fails', async () => { | ||
vi.mocked(useHost).mockReturnValue(HOST_CONFIG) | ||
vi.mocked(createRunAction).mockRejectedValue('oh no') | ||
|
||
const { result } = renderHook( | ||
useResumeRunFromRecoveryAssumingFalsePositiveMutation, | ||
{ | ||
wrapper, | ||
} | ||
) | ||
|
||
expect(result.current.data).toBeUndefined() | ||
act(() => | ||
result.current.resumeRunFromRecoveryAssumingFalsePositive(RUN_ID_1) | ||
) | ||
await waitFor(() => { | ||
expect(result.current.data).toBeUndefined() | ||
}) | ||
}) | ||
|
||
it('should create a resumeFromRecoveryAssumingFalsePositive run action when calling the resumeRunFromRecoveryAssumingFalsePositive callback', async () => { | ||
vi.mocked(useHost).mockReturnValue(HOST_CONFIG) | ||
vi.mocked(createRunAction).mockResolvedValue({ | ||
data: mockResumeFromRecoveryAction, | ||
} as Response<RunAction>) | ||
|
||
const { result } = renderHook( | ||
useResumeRunFromRecoveryAssumingFalsePositiveMutation, | ||
{ | ||
wrapper, | ||
} | ||
) | ||
act(() => | ||
result.current.resumeRunFromRecoveryAssumingFalsePositive(RUN_ID_1) | ||
) | ||
|
||
await waitFor(() => { | ||
expect(result.current.data).toEqual(mockResumeFromRecoveryAction) | ||
}) | ||
}) | ||
}) |
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
Oops, something went wrong.