Skip to content

Implement new tests, add new endpoints for category and commitment creations and add copilot instructions - #17

Merged
ryanjorgeac merged 25 commits into
mainfrom
implement-tests
Jun 28, 2026
Merged

Implement new tests, add new endpoints for category and commitment creations and add copilot instructions#17
ryanjorgeac merged 25 commits into
mainfrom
implement-tests

Conversation

@ryanjorgeac

@ryanjorgeac ryanjorgeac commented Oct 16, 2025

Copy link
Copy Markdown
Owner

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

  • Added a new Commitment model with fields for amount, type, description, frequency, and relations to User and Category, including the supporting CommitmentFrequency enum. Updated the Prisma schema and added corresponding migration SQL to create the commitments table and enum. (prisma/schema.prisma, prisma/migrations/20260627235521_add_commitment_model/migration.sql)
  • Extended the Category model with an isDefault boolean 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

  • Added a new docs/frontend-integration-guide.md file 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

  • Migrated Jest configuration from package.json to a dedicated jest.config.ts file, improving maintainability and TypeScript support. Adjusted package.json to remove the old Jest config and updated Prisma and related dependencies to the latest versions. (jest.config.ts, package.json)
  • Updated the README.md with clearer instructions and examples for running all tests, category-specific tests, and individual test files.

Database Seeding

  • Introduced a new prisma/seed.ts script to ensure every user has a default category ("Sem categoria"), with proper field values and logging. Updated the package.json to use this seed script.

Other Notable Changes

  • Added Gilfoyle-style code review instructions for reviewers, emphasizing a sardonic and technically superior review style. (.github/instructions/gilfoyle-code-review.instructions.md).
  • Registered the new CommitmentsModule in the NestJS application module. (src/app.module.ts)
  • Began adding bulk create DTOs and test mocks for categories (partial, in progress). (src/categories/categories.controller.spec.ts)
  • Removed unused or outdated SQL files related to category and transaction summaries. (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.

@ryanjorgeac
ryanjorgeac requested a review from Copilot October 16, 2025 00:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 $queryRawTyped with Prisma.sql template 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.

Comment thread src/transactions/transactions.service.ts Outdated
@ryanjorgeac ryanjorgeac changed the title Update Category workflow, refactor and create tests and update @prisma to latest version Implement new tests, add new endpoints for category and commitment creations and add copilot instructions Jun 28, 2026
@ryanjorgeac
ryanjorgeac requested a review from Copilot June 28, 2026 15:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 55 out of 57 changed files in this pull request and generated 9 comments.

Comment thread test/users/users.entity.spec.ts Outdated
Comment thread test/users/users.entity.spec.ts Outdated
Comment thread test/setup.ts Outdated
Comment thread src/common/utils/bigint-transform.ts
Comment thread jest.config.ts Outdated
Comment on lines +7 to +9
roots: ['<rootDir>/src', '<rootDir>/test'],
testRegex: '.*\\.spec\\.ts$',
transform: {
Comment thread src/users/users.service.ts Outdated
Comment on lines +27 to +39
...DEFAULT_CATEGORY_DATA,
userId: prismaUser.id,
},
});
Comment thread prisma/seed.ts Outdated
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;
ryanjorgeac and others added 4 commits June 28, 2026 14:53
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>
@ryanjorgeac
ryanjorgeac merged commit 2b46eee into main Jun 28, 2026
1 check passed
@ryanjorgeac
ryanjorgeac deleted the implement-tests branch June 28, 2026 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants