-
Notifications
You must be signed in to change notification settings - Fork 55
[AXON-1303, AXON-1363] Improve the UI for the Jira work item and the Create Jira issue page #1313
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
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f9630b3
AXON-1363: adding the necessary buttons to the banner
sspanchenko 0ffd9e0
AXON-1363: do not display the issue creation page content if there is…
sspanchenko 5478f95
AXON-1363: fix types
sspanchenko 2dbc040
AXON-1363: use variable in render
sspanchenko 3f8d55f
AXON-1363: do not show content if error banner is present on Jira page
sspanchenko 9bc1838
AXON-1363: show content in all cases
sspanchenko 940e6fb
AXON-1363: refactoring
sspanchenko 7abb6c6
Merge branch 'main' into AXON-1363-improve-the-ui-create-jira-issue
sspanchenko f726cf3
Merge branch 'main' into AXON-1363-improve-the-ui-create-jira-issue
sspanchenko 1858c33
Merge branch 'main' into AXON-1363-improve-the-ui-create-jira-issue
sspanchenko 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,226 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import React from 'react'; | ||
| import { disableConsole } from 'testsutil'; | ||
|
|
||
| import ErrorBanner from './ErrorBanner'; | ||
|
|
||
| describe('ErrorBanner', () => { | ||
| const mockOnDismissError = jest.fn(); | ||
| const mockOnRetry = jest.fn(); | ||
| const mockOnSignIn = jest.fn(); | ||
|
|
||
| beforeAll(() => { | ||
| disableConsole('warn', 'error'); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| describe('Retry button for retryable errors', () => { | ||
| it('shows Retry button for timeout errors', () => { | ||
| const { container } = render( | ||
| <ErrorBanner | ||
| errorDetails="Request timeout" | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| onSignIn={mockOnSignIn} | ||
| />, | ||
| ); | ||
|
|
||
| expect(container.textContent).toContain('Retry'); | ||
| expect(container.textContent).not.toContain('Sign In'); | ||
| }); | ||
|
|
||
| it('shows Retry button for network errors', () => { | ||
| const { container } = render( | ||
| <ErrorBanner | ||
| errorDetails="Network connection failed" | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| onSignIn={mockOnSignIn} | ||
| />, | ||
| ); | ||
|
|
||
| expect(container.textContent).toContain('Retry'); | ||
| expect(container.textContent).not.toContain('Sign In'); | ||
| }); | ||
|
|
||
| it('shows Retry button for 500 errors', () => { | ||
| const { container } = render( | ||
| <ErrorBanner | ||
| errorDetails="500 Internal Server Error" | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| onSignIn={mockOnSignIn} | ||
| />, | ||
| ); | ||
|
|
||
| expect(container.textContent).toContain('Retry'); | ||
| expect(container.textContent).not.toContain('Sign In'); | ||
| }); | ||
|
|
||
| it('calls onRetry when Retry button is clicked', async () => { | ||
| const user = userEvent.setup(); | ||
| render( | ||
| <ErrorBanner | ||
| errorDetails="Request timeout" | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| onSignIn={mockOnSignIn} | ||
| />, | ||
| ); | ||
|
|
||
| await user.click(screen.getByText('Retry')); | ||
| expect(mockOnRetry).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Sign In button for auth errors', () => { | ||
| it('shows Sign In button for 401 errors', () => { | ||
| const { container } = render( | ||
| <ErrorBanner | ||
| errorDetails="401 Unauthorized" | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| onSignIn={mockOnSignIn} | ||
| />, | ||
| ); | ||
|
|
||
| expect(container.textContent).toContain('Sign In'); | ||
| expect(container.textContent).not.toContain('Retry'); | ||
| }); | ||
|
|
||
| it('shows Sign In button for 403 errors', () => { | ||
| const { container } = render( | ||
| <ErrorBanner | ||
| errorDetails="403 Forbidden" | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| onSignIn={mockOnSignIn} | ||
| />, | ||
| ); | ||
|
|
||
| expect(container.textContent).toContain('Sign In'); | ||
| expect(container.textContent).not.toContain('Retry'); | ||
| }); | ||
|
|
||
| it('shows Sign In button for "sign in" message', () => { | ||
| const { container } = render( | ||
| <ErrorBanner | ||
| errorDetails="Unable to connect to Jira. Please sign in again to continue." | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| onSignIn={mockOnSignIn} | ||
| />, | ||
| ); | ||
|
|
||
| expect(container.textContent).toContain('Sign In'); | ||
| expect(container.textContent).not.toContain('Retry'); | ||
| }); | ||
|
|
||
| it('shows Sign In button for session expired errors', () => { | ||
| const { container } = render( | ||
| <ErrorBanner | ||
| errorDetails="Your session has expired. Please sign in again to continue." | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| onSignIn={mockOnSignIn} | ||
| />, | ||
| ); | ||
|
|
||
| expect(container.textContent).toContain('Sign In'); | ||
| expect(container.textContent).not.toContain('Retry'); | ||
| }); | ||
|
|
||
| it('shows Sign In button for permission errors', () => { | ||
| const { container } = render( | ||
| <ErrorBanner | ||
| errorDetails="You don't have permission to perform this action" | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| onSignIn={mockOnSignIn} | ||
| />, | ||
| ); | ||
|
|
||
| expect(container.textContent).toContain('Sign In'); | ||
| expect(container.textContent).not.toContain('Retry'); | ||
| }); | ||
|
|
||
| it('calls onSignIn when Sign In button is clicked', async () => { | ||
| const user = userEvent.setup(); | ||
| render( | ||
| <ErrorBanner | ||
| errorDetails="401 Unauthorized" | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| onSignIn={mockOnSignIn} | ||
| />, | ||
| ); | ||
|
|
||
| await user.click(screen.getByText('Sign In')); | ||
| expect(mockOnSignIn).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
|
|
||
| describe('No buttons when callbacks not provided', () => { | ||
| it('shows no buttons when onRetry not provided for retryable error', () => { | ||
| const { container } = render( | ||
| <ErrorBanner | ||
| errorDetails="Request timeout" | ||
| onDismissError={mockOnDismissError} | ||
| onSignIn={mockOnSignIn} | ||
| />, | ||
| ); | ||
|
|
||
| expect(container.textContent).not.toContain('Retry'); | ||
| }); | ||
|
|
||
| it('shows no buttons when onSignIn not provided for auth error', () => { | ||
| const { container } = render( | ||
| <ErrorBanner | ||
| errorDetails="401 Unauthorized" | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| />, | ||
| ); | ||
|
|
||
| expect(container.textContent).not.toContain('Sign In'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Error message display', () => { | ||
| it('displays simple string error', () => { | ||
| const { container } = render( | ||
| <ErrorBanner | ||
| errorDetails="Simple error message" | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| />, | ||
| ); | ||
|
|
||
| expect(container.textContent).toContain('Simple error message'); | ||
| }); | ||
|
|
||
| it('displays error with title', () => { | ||
| const { container } = render( | ||
| <ErrorBanner | ||
| errorDetails={{ title: 'Custom Error Title', message: 'Error details' }} | ||
| onDismissError={mockOnDismissError} | ||
| onRetry={mockOnRetry} | ||
| />, | ||
| ); | ||
|
|
||
| expect(container.textContent).toContain('Custom Error Title'); | ||
| }); | ||
|
|
||
| it('displays default title when not provided', () => { | ||
| const { container } = render( | ||
| <ErrorBanner errorDetails="Some error" onDismissError={mockOnDismissError} onRetry={mockOnRetry} />, | ||
| ); | ||
|
|
||
| expect(container.textContent).toContain('Something went wrong'); | ||
| }); | ||
| }); | ||
| }); | ||
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.