-
-
Notifications
You must be signed in to change notification settings - Fork 615
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 5 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
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,103 @@ | ||
| import { render, screen } from '@/test-utils'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { Routes, Route, useLocation } from 'react-router'; | ||
| import { AppSidebar } from '../Navigation/Sidebar/AppSidebar'; | ||
| import { SidebarProvider } from '@/components/ui/sidebar'; | ||
| import { ROUTES } from '@/constants/routes'; | ||
|
|
||
| // Display current routes | ||
| const LocationDisplay = () => { | ||
| const location = useLocation(); | ||
| return <div data-testid="location-display">{location.pathname}</div>; | ||
| }; | ||
|
|
||
| // Sidebar + routes display | ||
| const SidebarWithRoutes = () => ( | ||
| <SidebarProvider> | ||
| <AppSidebar /> | ||
| <main> | ||
| <LocationDisplay /> | ||
| <Routes> | ||
| <Route path={ROUTES.HOME} element={<div>Home Page</div>} /> | ||
| <Route path={ROUTES.SETTINGS} element={<div>Settings Page</div>} /> | ||
| <Route path={ROUTES.AI} element={<div>AI Tagging Page</div>} /> | ||
| <Route path={ROUTES.FAVOURITES} element={<div>Favourites Page</div>} /> | ||
| <Route path={ROUTES.VIDEOS} element={<div>Videos Page</div>} /> | ||
| <Route path={ROUTES.ALBUMS} element={<div>Albums Page</div>} /> | ||
| <Route path={ROUTES.MEMORIES} element={<div>Memories Page</div>} /> | ||
| </Routes> | ||
| </main> | ||
| </SidebarProvider> | ||
| ); | ||
|
|
||
| describe('Sidebar', () => { | ||
| describe('Structure Tests', () => { | ||
| test('renders all main navigation links', () => { | ||
| render( | ||
| <SidebarProvider> | ||
| <AppSidebar /> | ||
| </SidebarProvider>, | ||
| ); | ||
|
|
||
| // Verify key navigation items exist | ||
| expect(screen.getByText('Home')).toBeInTheDocument(); | ||
| expect(screen.getByText('AI Tagging')).toBeInTheDocument(); | ||
| expect(screen.getByText('Favourites')).toBeInTheDocument(); | ||
| expect(screen.getByText('Videos')).toBeInTheDocument(); | ||
| expect(screen.getByText('Albums')).toBeInTheDocument(); | ||
| expect(screen.getByText('Memories')).toBeInTheDocument(); | ||
| expect(screen.getByText('Settings')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Navigation Interaction Tests', () => { | ||
| const navigationCases = [ | ||
| { | ||
| linkText: 'Home', | ||
| route: ROUTES.HOME, | ||
| pageText: 'Home Page', | ||
| startRoute: ROUTES.SETTINGS, | ||
| }, | ||
| { linkText: 'AI Tagging', route: ROUTES.AI, pageText: 'AI Tagging Page' }, | ||
| { | ||
| linkText: 'Favourites', | ||
| route: ROUTES.FAVOURITES, | ||
| pageText: 'Favourites Page', | ||
| }, | ||
| { linkText: 'Videos', route: ROUTES.VIDEOS, pageText: 'Videos Page' }, | ||
| { linkText: 'Albums', route: ROUTES.ALBUMS, pageText: 'Albums Page' }, | ||
| { | ||
| linkText: 'Memories', | ||
| route: ROUTES.MEMORIES, | ||
| pageText: 'Memories Page', | ||
| }, | ||
| { | ||
| linkText: 'Settings', | ||
| route: ROUTES.SETTINGS, | ||
| pageText: 'Settings Page', | ||
| }, | ||
| ]; | ||
|
|
||
| test.each(navigationCases)( | ||
| 'clicking $linkText link navigates to /$route', | ||
| async ({ linkText, route, pageText, startRoute = ROUTES.HOME }) => { | ||
| const user = userEvent.setup(); | ||
| render(<SidebarWithRoutes />, { initialRoutes: [`/${startRoute}`] }); | ||
|
|
||
| // verify start location | ||
| expect(screen.getByTestId('location-display')).toHaveTextContent( | ||
| `/${startRoute}`, | ||
| ); | ||
|
|
||
| // click nav link | ||
| await user.click(screen.getByText(linkText)); | ||
|
|
||
| // verify navigation | ||
| expect(screen.getByTestId('location-display')).toHaveTextContent( | ||
| `/${route}`, | ||
| ); | ||
| expect(screen.getByText(pageText)).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,60 @@ | ||
| import { render, screen, waitFor } from '@/test-utils'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { ThemeSelector } from '../ThemeToggle'; | ||
|
|
||
| describe('ThemeSelector', () => { | ||
| describe('Structure Tests', () => { | ||
| test('renders theme toggle button', () => { | ||
| render(<ThemeSelector />); | ||
|
|
||
| // button should be accessible | ||
| const button = screen.getByRole('button', { name: /themes/i }); | ||
| expect(button).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Interaction Tests', () => { | ||
| test('clicking toggle button opens theme dropdown', async () => { | ||
| const user = userEvent.setup(); | ||
| render(<ThemeSelector />); | ||
|
|
||
| const button = screen.getByRole('button', { name: /themes/i }); | ||
| await user.click(button); // open dropdown | ||
|
|
||
| // verify dropdown options are visible | ||
| await screen.findByText('Light'); | ||
| expect(screen.getByText('Dark')).toBeInTheDocument(); | ||
| expect(screen.getByText('System')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| const themeSelectionCases = [ | ||
| { theme: 'Light', expectedClass: 'light', hiddenOption: 'Dark' }, | ||
| { theme: 'Dark', expectedClass: 'dark', hiddenOption: 'Light' }, | ||
| { theme: 'System', expectedClass: 'light', hiddenOption: 'Dark' }, // system resolves to light (matchMedia mock returns false) | ||
| ]; | ||
|
|
||
| test.each(themeSelectionCases)( | ||
| 'selecting $theme theme applies class and closes dropdown', | ||
| async ({ theme, expectedClass, hiddenOption }) => { | ||
| const user = userEvent.setup(); | ||
| render(<ThemeSelector />); | ||
|
|
||
| const button = screen.getByRole('button', { name: /themes/i }); | ||
| await user.click(button); // open dropdown | ||
|
|
||
| const themeOption = screen.getByText(theme); | ||
| await user.click(themeOption); // select theme | ||
|
|
||
| // verify theme class is applied to document | ||
| await waitFor(() => | ||
| expect(document.documentElement).toHaveClass(expectedClass), | ||
| ); | ||
|
|
||
| // verify dropdown closed | ||
| await waitFor(() => | ||
| expect(screen.queryByText(hiddenOption)).not.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,31 @@ | ||
| import { render, screen } from '@/test-utils'; | ||
| import { Home } from '../Home/Home'; | ||
| import Settings from '../SettingsPage/Settings'; | ||
|
|
||
| describe('Page Sanity Tests', () => { | ||
| describe('Home Page', () => { | ||
| test('renders home page structure', async () => { | ||
| render(<Home />); | ||
| expect( | ||
| await screen.findByText( | ||
| /Image Gallery|No Images to Display|Loading images/i, | ||
| ), | ||
| ).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Settings Page', () => { | ||
| test('renders settings page sections', () => { | ||
| render(<Settings />); | ||
|
|
||
| expect(screen.getByText('Folder Management')).toBeInTheDocument(); | ||
| expect(screen.getByText('User Preferences')).toBeInTheDocument(); | ||
| expect(screen.getByText('Application Controls')).toBeInTheDocument(); | ||
|
|
||
| expect( | ||
| screen.getByRole('button', { name: /Check for Updates/i }), | ||
| ).toBeInTheDocument(); | ||
| expect(screen.getByText('GPU Acceleration')).toBeInTheDocument(); | ||
| }); // Settings is expected to render synchronously. | ||
| }); | ||
| }); |
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.