forked from Code-4-Community/scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 0
finished hook implementation #220
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
7 commits
Select commit
Hold shift + click to select a range
7e8398f
finished hook implementation
ostepan8 fff28fc
pr updates
ostepan8 12f718a
Merge branch 'main' into applications-hooks
ostepan8 e1715e6
resolved comments
ostepan8 2beaeec
merging in main
SamNie2027 69cc7e9
name capitalization and linking
SamNie2027 64962d7
Removing experienceType checks from frontend test
SamNie2027 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
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
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,155 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { describe, it, expect } from 'vitest'; | ||
| import { ChakraProvider, defaultSystem } from '@chakra-ui/react'; | ||
| import ApplicationTable from './ApplicationTable'; | ||
| import type { ApplicationRow } from '@hooks/useApplications'; | ||
|
|
||
| function renderWithChakra(ui: React.ReactElement) { | ||
| return render(<ChakraProvider value={defaultSystem}>{ui}</ChakraProvider>); | ||
| } | ||
|
|
||
| const mockApplications: ApplicationRow[] = [ | ||
| { | ||
| appId: 1, | ||
| name: 'Jane Doe', | ||
| email: 'jane@example.com', | ||
| proposedStartDate: '2026-01-15', | ||
| actualStartDate: '2026-02-01', | ||
| discipline: 'RN', | ||
| applicantType: 'Learner', | ||
| status: 'App submitted', | ||
| }, | ||
| { | ||
| appId: 2, | ||
| name: 'John Smith', | ||
| email: 'john@example.com', | ||
| proposedStartDate: '2026-03-01', | ||
| actualStartDate: '', | ||
| discipline: 'Social Work', | ||
| applicantType: 'Volunteer', | ||
| status: 'Accepted', | ||
| }, | ||
| ]; | ||
|
|
||
| describe('ApplicationTable', () => { | ||
| it('should render all column headers', () => { | ||
| renderWithChakra(<ApplicationTable applications={[]} />); | ||
|
|
||
| const expectedColumns = [ | ||
| 'Name', | ||
| 'Proposed Date', | ||
| 'Actual Start Date', | ||
| 'Discipline', | ||
| 'Applicant Type', | ||
| 'Status', | ||
| ]; | ||
|
|
||
| expectedColumns.forEach((col) => { | ||
| expect(screen.getByText(col)).toBeDefined(); | ||
| }); | ||
| }); | ||
|
|
||
| it('should render application rows with correct data', () => { | ||
| renderWithChakra(<ApplicationTable applications={mockApplications} />); | ||
|
|
||
| expect(screen.getByText('Jane Doe')).toBeDefined(); | ||
| expect(screen.getByText('John Smith')).toBeDefined(); | ||
| expect(screen.getByText('RN')).toBeDefined(); | ||
| expect(screen.getByText('Social Work')).toBeDefined(); | ||
| expect(screen.getByText('Learner')).toBeDefined(); | ||
| expect(screen.getByText('Volunteer')).toBeDefined(); | ||
| expect(screen.getByText('App submitted')).toBeDefined(); | ||
| expect(screen.getByText('Accepted')).toBeDefined(); | ||
| }); | ||
|
|
||
| it('should format dates correctly', () => { | ||
| renderWithChakra(<ApplicationTable applications={mockApplications} />); | ||
|
|
||
| expect(screen.getByText('01/15/2026')).toBeDefined(); | ||
| expect(screen.getByText('02/01/2026')).toBeDefined(); | ||
| expect(screen.getByText('03/01/2026')).toBeDefined(); | ||
| }); | ||
|
|
||
| it('should display em-dash for missing actual start date', () => { | ||
| renderWithChakra(<ApplicationTable applications={mockApplications} />); | ||
|
|
||
| const cells = screen.getAllByRole('cell'); | ||
| const emDashCells = cells.filter((cell) => cell.textContent === '—'); | ||
| expect(emDashCells.length).toBeGreaterThanOrEqual(1); | ||
| }); | ||
|
|
||
| it('should render an empty table body when no applications provided', () => { | ||
| renderWithChakra(<ApplicationTable applications={[]} />); | ||
|
|
||
| const rows = screen.queryAllByRole('row'); | ||
| expect(rows).toHaveLength(1); | ||
| }); | ||
|
|
||
| it('should filter applications by search query on name', () => { | ||
| renderWithChakra( | ||
| <ApplicationTable applications={mockApplications} searchQuery="Jane" />, | ||
| ); | ||
|
|
||
| expect(screen.getByText('Jane Doe')).toBeDefined(); | ||
| expect(screen.queryByText('John Smith')).toBeNull(); | ||
| }); | ||
|
|
||
| it('should filter applications by search query on discipline', () => { | ||
| renderWithChakra( | ||
| <ApplicationTable applications={mockApplications} searchQuery="Social" />, | ||
| ); | ||
|
|
||
| expect(screen.queryByText('Jane Doe')).toBeNull(); | ||
| expect(screen.getByText('John Smith')).toBeDefined(); | ||
| }); | ||
|
|
||
| it('should filter applications by search query on status', () => { | ||
| renderWithChakra( | ||
| <ApplicationTable | ||
| applications={mockApplications} | ||
| searchQuery="accepted" | ||
| />, | ||
| ); | ||
|
|
||
| expect(screen.queryByText('Jane Doe')).toBeNull(); | ||
| expect(screen.getByText('John Smith')).toBeDefined(); | ||
| }); | ||
|
|
||
| it('should filter applications by search query on email', () => { | ||
| renderWithChakra( | ||
| <ApplicationTable applications={mockApplications} searchQuery="jane@" />, | ||
| ); | ||
|
|
||
| expect(screen.getByText('Jane Doe')).toBeDefined(); | ||
| expect(screen.queryByText('John Smith')).toBeNull(); | ||
| }); | ||
|
|
||
| it('should be case-insensitive when filtering', () => { | ||
| renderWithChakra( | ||
| <ApplicationTable applications={mockApplications} searchQuery="JANE" />, | ||
| ); | ||
|
|
||
| expect(screen.getByText('Jane Doe')).toBeDefined(); | ||
| }); | ||
|
|
||
| it('should show all applications when search query is empty', () => { | ||
| renderWithChakra( | ||
| <ApplicationTable applications={mockApplications} searchQuery="" />, | ||
| ); | ||
|
|
||
| expect(screen.getByText('Jane Doe')).toBeDefined(); | ||
| expect(screen.getByText('John Smith')).toBeDefined(); | ||
| }); | ||
|
|
||
| it('should show no application rows when search matches nothing', () => { | ||
| renderWithChakra( | ||
| <ApplicationTable | ||
| applications={mockApplications} | ||
| searchQuery="zzzznonexistent" | ||
| />, | ||
| ); | ||
|
|
||
| const rows = screen.queryAllByRole('row'); | ||
| expect(rows).toHaveLength(1); | ||
| }); | ||
| }); |
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
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.