-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat(sprints): created unit tests for the sprints' service and controller methods #224
Conversation
…ce methods created a centralized object containing factory functions for basic entities, form-related entities, DTOs, and complex relationships to help with improving maintainability, readability, and consistency.
Mock data is added to facilitate the testing of the sprints service. This includes mock data for various entities such as Voyage, Sprint, TeamMeeting, Form, etc. Helper functions are also provided to create test modules, setup ability checks, and setup Prisma mocks. This will allow for more comprehensive and reliable unit tests, ensuring that the sprints service functions as expected.
…ions to separate file The mock data and helper functions used in the sprints.service.spec.ts file were extracted to a separate file named mock-data.ts. This change was made to improve the readability and maintainability of the test file. Now, the test file is cleaner and easier to navigate, and the mock data and helper functions can be reused in other test files if needed.
…ontroller The test coverage was successfully only when directly instantiating the controller for testing
…s to clean up code Unused imports were removed from both mock-data.ts and sprints.service.spec.ts files. This was done to improve code readability and maintainability by removing clutter. It also helps to reduce the potential for errors and confusion in the future.
The Agenda model from Prisma client is imported to be used in the sprints service tests. This is necessary for testing functionalities that involve the Agenda model.
…d sprints.service.spec.ts The VoyageResponse import in mock-data.ts and the TestingModule import in sprints.service.spec.ts were removed as they were not being used, which helps to keep the codebase clean and efficient. The MockFormResponseMeetingWithRelations type was also removed from mock-data.ts as it was not being used. In sprints.service.spec.ts, the index parameter was removed from the map function as it was not being used, which simplifies the code and improves readability.
…sponseMeetingWithRelations type and simplify addCheckinFormResponse test The FormResponseMeetingWithRelations type was removed as it was no longer being used in the codebase, which helps to reduce clutter and improve maintainability. The addCheckinFormResponse test in sprints.service.spec.ts was simplified by removing unnecessary mock data, making the test more focused and easier to understand.
…ture The test file for the sprints controller has been significantly refactored to improve the structure and increase the test coverage. The changes include: - Importing necessary modules and dependencies for testing. - Mocking the SprintsService and its methods. - Setting up the testing module and initializing the SprintsController and SprintsService before each test. - Clearing all mocks after each test. - Adding comprehensive test cases for each method in the SprintsController, including success scenarios and various error scenarios. - Checking the structure of the response data in some tests to ensure the correct data is returned. These changes provide a more robust and comprehensive testing suite for the sprints controller, ensuring that it functions as expected in various scenarios.
…rom 'domain' The 'create' import from 'domain' was not being used in the sprints.controller.spec.ts file. This removal helps to keep the codebase clean and free of unnecessary dependencies.
…for error logging The change was made to ensure that errors are logged to the error console, which is a more appropriate place for them. This will help in better error tracking and debugging.
…reased test coverage.
…lity fix(sprints.service.ts): change console.error to console.log for better error tracking The indentation in sprints.service.spec.ts was adjusted to improve code readability and maintain consistency across the codebase. In sprints.service.ts, the console.error was changed to console.log to provide better error tracking and debugging. This change will make it easier to identify and fix issues in the future.
The changelog has been updated to include the addition of unit tests for sprints. This is important to keep the changelog up-to-date with all the changes and improvements made to the project, providing a clear history of the project's evolution.
… improve code readability feat(sprints.service.spec.ts): add consoleSpy to handle database errors during response group creation The unnecessary blank lines were removed to improve code readability and maintain a clean codebase. A consoleSpy was added to handle database errors during response group creation. This will help in debugging and error tracking, making the application more robust and reliable.
…ing operators in mockUpdatedMeetingDto The null coalescing operators were removed from the mockUpdatedMeetingDto object in the sprints.controller.spec.ts file. These operators were unnecessary because the values being coalesced were hardcoded and would never be null. This change simplifies the code and improves readability.
All tests passed and worked. I'm not requesting any changes but have a few questions/comments
|
Yes, My idea for |
In this case, should we move it under some sort of shared folder instead of under /sprint module? I will also add some low priority tasks to update old tests to use this, more importantly all new tests should use the shared mock data |
I'll move the file to the shared folder and let you know when its ready. |
…rectory The mock-data.ts file was moved from the sprints directory to the global/mocks directory. This change was made to improve the organization of the codebase. The mock-data.ts file contains mock data that can be used across multiple tests, not just those in the sprints directory. By moving it to the global/mocks directory, it is now more accessible for use in tests throughout the application.
The mock-data used in sprints.controller.spec.ts and sprints.service.spec.ts was moved to the global mocks directory. This change was made to improve the organization of the codebase, making it easier to locate and reuse mock data across different modules.
I have moved the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, re ran all the tests with new changes, all passed
Description
Added comprehensive unit tests for
sprints.controller
andsprints.service
following the testing guidelines. Also created centralized mock data system for improved test maintainability.Issue link
Fixes # (86azu6kx1)
Type of change
How Has This Been Tested?
Checklist: