Implement new tests, add new endpoints for category and commitment creations and add copilot instructions - #17
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR updates the Prisma dependency to the latest version (6.17.1) and refactors the category workflow with comprehensive test coverage. The changes include migrating from deprecated $queryRawTyped to the current $queryRaw API, updating currency handling from dollars to reais (Brazilian Real), and implementing proper money formatting for API responses.
Key Changes:
- Updated Prisma from 6.4.1 to 6.17.1
- Refactored currency handling from dollars to reais throughout the codebase
- Replaced deprecated
$queryRawTypedwithPrisma.sqltemplate literals - Added comprehensive E2E and unit tests for category functionality
Reviewed Changes
Copilot reviewed 22 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| package.json | Updated @prisma/client and prisma to version 6.17.1, moved Jest config to separate file |
| jest.config.ts | Extracted Jest configuration from package.json into TypeScript config file |
| src/queries/category.queries.ts | Created centralized SQL query functions using Prisma.sql template literals |
| src/common/utils/bigint-transform.ts | Refactored dollar-to-cent conversion to reais, implemented BRL number formatting |
| src/categories/entities/category.entity.ts | Added BigInt normalization logic and safe null handling in calculations |
| src/categories/categories.service.ts | Migrated to new query API, renamed currency conversion functions, added logging |
| src/categories/dto/*.dto.ts | Updated DTO validation rules and documentation examples for reais currency format |
| test/categories/categories.e2e-spec.ts | Added comprehensive E2E test suite covering all category endpoints and edge cases |
| test/setup.ts | Created shared test database setup with automatic table truncation |
| src/categories/entities/category.entity.spec.ts | Removed outdated unit tests (to be replaced) |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…ilitate the manipulation and increase precision
…tity, also change the prisma schema to match new entity
Comment on lines
+7
to
+9
| roots: ['<rootDir>/src', '<rootDir>/test'], | ||
| testRegex: '.*\\.spec\\.ts$', | ||
| transform: { |
Comment on lines
+27
to
+39
| ...DEFAULT_CATEGORY_DATA, | ||
| userId: prismaUser.id, | ||
| }, | ||
| }); |
Comment on lines
+1
to
+13
| import { PrismaClient } from '@prisma/client'; | ||
|
|
||
| const DEFAULT_CATEGORY_NAME = 'Sem categoria'; | ||
|
|
||
| const DEFAULT_CATEGORY_DATA = { | ||
| name: DEFAULT_CATEGORY_NAME, | ||
| description: 'Categoria padrão para transações sem categorias', | ||
| color: null, | ||
| icon: null, | ||
| budgetAmount: 0, | ||
| isActive: true, | ||
| isDefault: true, | ||
| } as const; |
Comment on lines
+82
to
+86
| @ApiResponse({ | ||
| status: 403, | ||
| description: 'Unauthorized', | ||
| type: ExceptionResponseDto, | ||
| }) |
Comment on lines
52
to
+54
| }) | ||
| @IsOptional() | ||
| @IsNumber() | ||
| budgetAmount?: number; | ||
| budgetAmount: number; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces several major improvements and additions to the codebase, focusing on backend data model evolution, improved frontend integration guidance, and developer experience enhancements. The most significant changes include the introduction of a recurring commitments feature (with schema and migration updates), the addition of a comprehensive frontend integration guide, and improvements to testing configuration and seeding logic.
Backend Data Model & Migrations
Commitmentmodel with fields for amount, type, description, frequency, and relations toUserandCategory, including the supportingCommitmentFrequencyenum. Updated the Prisma schema and added corresponding migration SQL to create thecommitmentstable and enum. (prisma/schema.prisma,prisma/migrations/20260627235521_add_commitment_model/migration.sql)Categorymodel with anisDefaultboolean field and updated the default category description to Portuguese. Added migration scripts to update the schema and existing data accordingly. (prisma/schema.prisma,prisma/migrations/20260627181258_add_is_default_to_category/migration.sql,prisma/migrations/20260628_update_default_category_description/migration.sql)Frontend Integration & Developer Guidance
docs/frontend-integration-guide.mdfile detailing how the frontend should handle money fields (cents-only writes), nullable visual fields for categories, error handling, and recommended patterns for data transformation and validation.Testing & Developer Experience
package.jsonto a dedicatedjest.config.tsfile, improving maintainability and TypeScript support. Adjustedpackage.jsonto remove the old Jest config and updated Prisma and related dependencies to the latest versions. (jest.config.ts,package.json)README.mdwith clearer instructions and examples for running all tests, category-specific tests, and individual test files.Database Seeding
prisma/seed.tsscript to ensure every user has a default category ("Sem categoria"), with proper field values and logging. Updated thepackage.jsonto use this seed script.Other Notable Changes
.github/instructions/gilfoyle-code-review.instructions.md).CommitmentsModulein the NestJS application module. (src/app.module.ts)src/categories/categories.controller.spec.ts)prisma/sql/getCategoriesSummary.sql,prisma/sql/getUserCategories.sql)These changes collectively modernize the backend data model, clarify frontend integration, improve developer tooling, and support new recurring financial features.