Repository navigation
Pk/mspca 46 animal availability frontend endpoint #30
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
dburkhart07
merged 17 commits into
main
from
pk/mspca-46-animal-availability-frontend-endpoint
Nov 22, 2026
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d558e32
added animal entity
shreeyaadhikari 574967c
add migration to create animal table
shreeyaadhikari d6f7cbf
added animal service logic w chameloen id existence checks
shreeyaadhikari 13af06a
validate animal exists in post/recommendations
shreeyaadhikari c01e1ec
validate animal exists in post/matches
shreeyaadhikari 4d31981
validate added animals exist in patch/volunteers/id/animal-preference
shreeyaadhikari 2f8c81a
Add animal availability page with filters, animal card, and modal
pujitakalinadhabhotla 3d04de3
Merge main and address review feedback on animal availability
pujitakalinadhabhotla b0280f6
Update animal availability UI to match latest designs
pujitakalinadhabhotla 87e96be
addressed comments
pujitakalinadhabhotla e0b7c84
MSPCA-51 Add navbar to the app layout (#31)
Juwang110 cc07561
address comments
pujitakalinadhabhotla a992d97
merge conflicts
pujitakalinadhabhotla 3313a35
address comments
pujitakalinadhabhotla c2a64e4
address comments
pujitakalinadhabhotla 83cb6ba
address comments
pujitakalinadhabhotla 1efad4c
Merge branch 'main' into pk/mspca-46-animal-availability-frontend-end…
dburkhart07 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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Frontend tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['**'] | ||
| pull_request: | ||
| branches: ['**'] | ||
|
|
||
| jobs: | ||
| frontend-tests: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24.x | ||
| cache: 'yarn' | ||
| - run: yarn install --frozen-lockfile | ||
| - run: npx vitest run --root apps/frontend |
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,46 @@ | ||
| import { Test, TestingModule } from '@nestjs/testing'; | ||
| import { AnimalsController } from './animals.controller'; | ||
| import { AnimalsService } from './animals.service'; | ||
| import { Animal } from './animals.entity'; | ||
|
|
||
| describe('AnimalsController', () => { | ||
| let controller: AnimalsController; | ||
| let service: { findAll: jest.Mock }; | ||
|
|
||
| beforeEach(async () => { | ||
| service = { findAll: jest.fn() }; | ||
|
|
||
| const module: TestingModule = await Test.createTestingModule({ | ||
| controllers: [AnimalsController], | ||
| providers: [{ provide: AnimalsService, useValue: service }], | ||
| }).compile(); | ||
|
|
||
| controller = module.get<AnimalsController>(AnimalsController); | ||
| }); | ||
|
|
||
| it('should be defined', () => { | ||
| expect(controller).toBeDefined(); | ||
| }); | ||
|
|
||
| describe('getAnimals', () => { | ||
| it('returns the animals from the service', async () => { | ||
| const animals = [{ animalId: 1 }, { animalId: 2 }] as Animal[]; | ||
| service.findAll.mockResolvedValue(animals); | ||
|
|
||
| await expect(controller.getAnimals()).resolves.toBe(animals); | ||
| expect(service.findAll).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it('returns an empty array when there are no animals', async () => { | ||
| service.findAll.mockResolvedValue([]); | ||
|
|
||
| await expect(controller.getAnimals()).resolves.toEqual([]); | ||
| }); | ||
|
|
||
| it('propagates service errors', async () => { | ||
| service.findAll.mockRejectedValue(new Error('db down')); | ||
|
|
||
| await expect(controller.getAnimals()).rejects.toThrow('db down'); | ||
| }); | ||
| }); | ||
| }); |
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,25 @@ | ||
| import { Controller, Get, HttpStatus } from '@nestjs/common'; | ||
| import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; | ||
| import { AnimalsService } from './animals.service'; | ||
| import { Animal } from './animals.entity'; | ||
|
|
||
| @ApiTags('Animals') | ||
| @Controller('animals') | ||
| export class AnimalsController { | ||
| constructor(private animalsService: AnimalsService) {} | ||
|
|
||
| @Get() | ||
| @ApiOperation({ | ||
| summary: 'Get all available animals', | ||
| description: | ||
| 'Returns every animal. All animals in the database are currently treated as available.', | ||
| }) | ||
| @ApiResponse({ | ||
| status: HttpStatus.OK, | ||
| description: 'The animals, or an empty array when none are available.', | ||
| type: [Animal], | ||
| }) | ||
| async getAnimals(): Promise<Animal[]> { | ||
| return this.animalsService.findAll(); | ||
| } | ||
| } |
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
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
17 changes: 17 additions & 0 deletions
17
apps/backend/src/migrations/1794784721012-AddMatchAdditionalComments.ts
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,17 @@ | ||
| import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we regenerate this so it sorts last after you merge main? |
||
|
|
||
| export class AddMatchAdditionalComments1794784721012 | ||
| implements MigrationInterface | ||
| { | ||
| public async up(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query( | ||
| `ALTER TABLE "matches" ADD COLUMN "additional_comments" text`, | ||
| ); | ||
| } | ||
|
|
||
| public async down(queryRunner: QueryRunner): Promise<void> { | ||
| await queryRunner.query( | ||
| `ALTER TABLE "matches" DROP COLUMN "additional_comments"`, | ||
| ); | ||
| } | ||
| } | ||
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.