-
-
Notifications
You must be signed in to change notification settings - Fork 617
CI/CD: Refresh Frontend Test Suites #1056
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
Open
rohan-pandeyy
wants to merge
6
commits into
AOSSIE-Org:main
Choose a base branch
from
rohan-pandeyy:ci-cd/frontend-test-suites
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1bdf7d0
feat(test): implement frontend sanity tests and update infrastructure
rohan-pandeyy 793bdba
expand sanity tests with sidebar navigation interactions
rohan-pandeyy b6c84d3
Update: assertions to reference ROUTES constants + minor nitpicks
rohan-pandeyy dbecc0e
Add theme toggle (component) test
rohan-pandeyy 38b1f33
Add SettingsPage unit tests + prior test optimizations
rohan-pandeyy 96bede0
Add unit tests for components and utils
rohan-pandeyy 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
69 changes: 69 additions & 0 deletions
69
frontend/src/components/__tests__/DeleteImageDialog.test.tsx
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,69 @@ | ||
| import { render, screen } from '@/test-utils'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import DeleteImagesDialog from '../FolderPicker/DeleteImageDialog'; | ||
|
|
||
| describe('DeleteImagesDialog', () => { | ||
| const mockSetIsOpen = jest.fn(); | ||
| const mockExecuteDeleteImages = jest.fn(); | ||
|
|
||
| const defaultProps = { | ||
| isOpen: true, | ||
| setIsOpen: mockSetIsOpen, | ||
| executeDeleteImages: mockExecuteDeleteImages, | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| }); | ||
|
|
||
| describe('Rendering', () => { | ||
| test('renders confirmation text when open', () => { | ||
| render(<DeleteImagesDialog {...defaultProps} />); | ||
|
|
||
| expect( | ||
| screen.getByText( | ||
| 'Do you also want to delete these images from Device ?', | ||
| ), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('does not render content when closed', () => { | ||
| render(<DeleteImagesDialog {...defaultProps} isOpen={false} />); | ||
|
|
||
| expect( | ||
| screen.queryByText( | ||
| 'Do you also want to delete these images from Device ?', | ||
| ), | ||
| ).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders Yes and No buttons', () => { | ||
| render(<DeleteImagesDialog {...defaultProps} />); | ||
|
|
||
| expect(screen.getByRole('button', { name: /yes/i })).toBeInTheDocument(); | ||
| expect(screen.getByRole('button', { name: /no/i })).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Interactions', () => { | ||
| test('clicking Yes calls executeDeleteImages(true) and closes dialog', async () => { | ||
| const user = userEvent.setup(); | ||
| render(<DeleteImagesDialog {...defaultProps} />); | ||
|
|
||
| await user.click(screen.getByRole('button', { name: /yes/i })); | ||
|
|
||
| expect(mockExecuteDeleteImages).toHaveBeenCalledWith(true); | ||
| expect(mockSetIsOpen).toHaveBeenCalledWith(false); | ||
| }); | ||
|
|
||
| test('clicking No calls executeDeleteImages(false) and closes dialog', async () => { | ||
| const user = userEvent.setup(); | ||
| render(<DeleteImagesDialog {...defaultProps} />); | ||
|
|
||
| await user.click(screen.getByRole('button', { name: /no/i })); | ||
|
|
||
| expect(mockExecuteDeleteImages).toHaveBeenCalledWith(false); | ||
| expect(mockSetIsOpen).toHaveBeenCalledWith(false); | ||
| }); | ||
| }); | ||
| }); |
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,45 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { EmptyGalleryState } from '../EmptyStates/EmptyGalleryState'; | ||
| import { EmptyAITaggingState } from '../EmptyStates/EmptyAITaggingState'; | ||
|
|
||
| describe('EmptyGalleryState', () => { | ||
| test('renders heading', () => { | ||
| render(<EmptyGalleryState />); | ||
|
|
||
| expect( | ||
| screen.getByRole('heading', { name: /no images to display/i }), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders gallery instructions', () => { | ||
| render(<EmptyGalleryState />); | ||
|
|
||
| expect( | ||
| screen.getByText(/go to settings to add folders/i), | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByText(/supports png, jpg, jpeg image formats/i), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('EmptyAITaggingState', () => { | ||
| test('renders heading', () => { | ||
| render(<EmptyAITaggingState />); | ||
|
|
||
| expect( | ||
| screen.getByRole('heading', { name: /no ai tagged images/i }), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders AI tagging instructions', () => { | ||
| render(<EmptyAITaggingState />); | ||
|
|
||
| expect( | ||
| screen.getByText(/ai will automatically detect objects and people/i), | ||
| ).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByText(/supports png, jpg, jpeg image formats/i), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); |
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,35 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { GlobalLoader } from '../Loader/GlobalLoader'; | ||
|
|
||
| describe('GlobalLoader', () => { | ||
| test('renders loading message when loading is true', () => { | ||
| render(<GlobalLoader loading={true} message="Loading images..." />); | ||
|
|
||
| expect(screen.getByText('Loading images...')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('renders empty container when loading is false', () => { | ||
| const { container } = render( | ||
| <GlobalLoader loading={false} message="Loading images..." />, | ||
| ); | ||
|
|
||
| expect(screen.queryByText('Loading images...')).not.toBeInTheDocument(); | ||
| // renders an empty div | ||
| expect(container.firstChild).toBeEmptyDOMElement(); | ||
| }); | ||
|
|
||
| const loadingMessages = [ | ||
| { message: 'Checking for updates...' }, | ||
| { message: 'Starting global face reclustering...' }, | ||
| { message: 'Adding folder...' }, | ||
| ]; | ||
|
|
||
| test.each(loadingMessages)( | ||
| 'displays "$message" correctly', | ||
| ({ message }) => { | ||
| render(<GlobalLoader loading={true} message={message} />); | ||
|
|
||
| expect(screen.getByText(message)).toBeInTheDocument(); | ||
| }, | ||
| ); | ||
| }); |
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.