-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix missing scrim background on LoadingOverlay (#2098)
Background class wasn't applied when LoadingOverlay has error or is loading
- Loading branch information
Showing
2 changed files
with
52 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import LoadingOverlay from './LoadingOverlay'; | ||
|
||
describe('LoadingOverlay', () => { | ||
it('renders loading spinner and no scrim on initial loading', () => { | ||
const { container } = render( | ||
<LoadingOverlay isLoading data-testid="test-overlay" /> | ||
); | ||
expect(screen.getByTestId('test-overlay-spinner')).toBeInTheDocument(); | ||
expect( | ||
container.getElementsByClassName('iris-panel-scrim-background').length | ||
).toBe(0); | ||
}); | ||
|
||
it('renders error message and no scrim when errorMessage is provided on initial loading', () => { | ||
const errorMessage = 'An error occurred'; | ||
const { container } = render( | ||
<LoadingOverlay errorMessage={errorMessage} /> | ||
); | ||
const errorElement = screen.getByText(errorMessage); | ||
expect(errorElement).toBeInTheDocument(); | ||
expect( | ||
container.getElementsByClassName('iris-panel-scrim-background').length | ||
).toBe(0); | ||
}); | ||
|
||
it('renders scrim when loaded and errorMessage is provided', () => { | ||
const { container } = render( | ||
<LoadingOverlay isLoaded errorMessage="ERROR_MESSAGE" /> | ||
); | ||
expect( | ||
container.getElementsByClassName('iris-panel-scrim-background').length | ||
).toBe(1); | ||
}); | ||
|
||
it('renders scrim when isLoaded is true and loading again', () => { | ||
const { container } = render(<LoadingOverlay isLoaded isLoading />); | ||
expect( | ||
container.getElementsByClassName('iris-panel-scrim-background').length | ||
).toBe(1); | ||
}); | ||
}); |
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