-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show correct error message for not found workflows (#768)
Move the error boundary to be above the Layout.js to catch status badge errors Map 400 errors that happens on misconfiguring archival to 404 Ignore emitting 404 responses as Errors Create an error component for workflows page
- Loading branch information
1 parent
5205d7a
commit 2930dfc
Showing
6 changed files
with
132 additions
and
28 deletions.
There are no files selected for viewing
14 changes: 0 additions & 14 deletions
14
...app/(Home)/(Workflow)/domains/[domain]/[cluster]/workflows/[workflowId]/[runId]/error.tsx
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
src/app/(Home)/(Workflow)/domains/[domain]/[cluster]/workflows/[workflowId]/error.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,4 @@ | ||
'use client'; | ||
import WorkflowPageError from '@/views/workflow-page/workflow-page-error/workflow-page-error'; | ||
|
||
export default WorkflowPageError; |
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
49 changes: 49 additions & 0 deletions
49
src/views/workflow-page/workflow-page-error/__tests__/domain-page-error.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,49 @@ | ||
import React from 'react'; | ||
|
||
import { render, screen } from '@/test-utils/rtl'; | ||
|
||
import { RequestError } from '@/utils/request/request-error'; | ||
|
||
import WorkflowPageError from '../workflow-page-error'; | ||
|
||
jest.mock('next/navigation', () => ({ | ||
...jest.requireActual('next/navigation'), | ||
useParams: () => ({ | ||
domain: 'test-domain', | ||
cluster: 'test-cluster', | ||
}), | ||
})); | ||
|
||
jest.mock('@/components/error-panel/error-panel', () => | ||
jest.fn(({ message }: { message: string }) => <div>{message}</div>) | ||
); | ||
|
||
describe(WorkflowPageError.name, () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('renders error page correctly', () => { | ||
render( | ||
<WorkflowPageError | ||
error={new Error('something bad happened')} | ||
reset={() => {}} | ||
/> | ||
); | ||
expect(screen.getByText('Failed to load workflow')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders "not found" error page correctly', () => { | ||
render( | ||
<WorkflowPageError | ||
error={new RequestError('Could not find workflow', 404)} | ||
reset={() => {}} | ||
/> | ||
); | ||
expect( | ||
screen.getByText( | ||
'Workflow was not found, it may have passed retention period' | ||
) | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
43 changes: 43 additions & 0 deletions
43
src/views/workflow-page/workflow-page-error/workflow-page-error.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,43 @@ | ||
'use client'; | ||
import { useParams } from 'next/navigation'; | ||
|
||
import ErrorPanel from '@/components/error-panel/error-panel'; | ||
import { RequestError } from '@/utils/request/request-error'; | ||
|
||
import { type Props } from './workflow-page-error.types'; | ||
|
||
export default function WorkflowPageError({ error, reset }: Props) { | ||
const { domain, cluster } = useParams(); | ||
|
||
if (error instanceof RequestError && error.status === 404) { | ||
return ( | ||
<ErrorPanel | ||
error={error} | ||
message={`Workflow was not found, it may have passed retention period`} | ||
actions={[ | ||
{ | ||
kind: 'link-internal', | ||
label: 'Go to domain page', | ||
link: `/domains/${domain}/${cluster}`, | ||
}, | ||
]} | ||
reset={reset} | ||
omitLogging={true} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<ErrorPanel | ||
error={error} | ||
message="Failed to load workflow" | ||
actions={[ | ||
{ | ||
kind: 'retry', | ||
label: 'Retry', | ||
}, | ||
]} | ||
reset={reset} | ||
/> | ||
); | ||
} |
4 changes: 4 additions & 0 deletions
4
src/views/workflow-page/workflow-page-error/workflow-page-error.types.ts
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,4 @@ | ||
export type Props = { | ||
error: Error; | ||
reset: () => void; | ||
}; |