Skip to content

Commit

Permalink
update backend request
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandes-natanael committed Aug 20, 2024
1 parent 3f082fe commit 8bb89cf
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
72 changes: 72 additions & 0 deletions reports/sonar-report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<testExecutions version="1">
<file path="test/trail.service.spec.ts">
<testCase name="TrailService should be defined" duration="12" />
<testCase name="TrailService should throw NotFoundException if journey is not found when creating a trail" duration="7" />
<testCase name="TrailService should throw NotFoundException if trail is not found when adding content" duration="3" />
<testCase name="TrailService should throw NotFoundException if trail is not found when removing content" duration="2" />
<testCase name="TrailService should find a trail by ID" duration="11" />
<testCase name="TrailService should throw NotFoundException if trail is not found when finding by ID" duration="3" />
<testCase name="TrailService should return all trails" duration="3" />
<testCase name="TrailService should update a trail" duration="4" />
<testCase name="TrailService should throw NotFoundException if trail is not found when updating" duration="3" />
<testCase name="TrailService should throw NotFoundException if trail is not found when deleting" duration="2" />
</file>
<file path="test/content.service.spec.ts">
<testCase name="ContentService should be defined" duration="3" />
<testCase name="ContentService createContent should throw NotFoundException if trail does not exist" duration="3" />
<testCase name="ContentService findContentById should return content by id" duration="2" />
<testCase name="ContentService findContentById should throw NotFoundException if content does not exist" duration="2" />
<testCase name="ContentService findAllContents should return all contents" duration="2" />
<testCase name="ContentService updateContent should update content and return the updated content" duration="2" />
<testCase name="ContentService updateContent should throw NotFoundException if content does not exist" duration="2" />
<testCase name="ContentService deleteContent should delete content" duration="1" />
<testCase name="ContentService deleteContent should throw NotFoundException if content does not exist" duration="2" />
</file>
<file path="test/journey.service.spec.ts">
<testCase name="JourneyService should be defined" duration="4" />
<testCase name="JourneyService should throw UnauthorizedException if token is invalid" duration="6" />
<testCase name="JourneyService should throw NotFoundException if journey is not found" duration="2" />
<testCase name="JourneyService should return all journeys" duration="2" />
<testCase name="JourneyService should return journeys by user ID" duration="1" />
<testCase name="JourneyService should update a journey" duration="8" />
<testCase name="JourneyService should delete a journey" duration="2" />
<testCase name="JourneyService should throw NotFoundException if journey is not found when adding a trail" duration="2" />
<testCase name="JourneyService should return user id when token is valid" duration="3" />
<testCase name="JourneyService should return null when token is invalid" duration="2" />
</file>
<file path="test/content.controller.spec.ts">
<testCase name="ContentController should be defined" duration="5" />
<testCase name="ContentController createContent should create content" duration="2" />
<testCase name="ContentController createContent should throw NotFoundException if required fields are missing" duration="6" />
<testCase name="ContentController findContentById should return content by id" duration="3" />
<testCase name="ContentController findContentById should throw NotFoundException if content is not found" duration="4" />
<testCase name="ContentController findAllContents should return all contents" duration="2" />
<testCase name="ContentController updateContent should update content and return the updated content" duration="2" />
<testCase name="ContentController updateContent should throw NotFoundException if content is not found" duration="2" />
<testCase name="ContentController deleteContent should delete content" duration="4" />
<testCase name="ContentController deleteContent should throw NotFoundException if content is not found" duration="2" />
</file>
<file path="test/trail.controller.spec.ts">
<testCase name="TrailController should be defined" duration="3" />
<testCase name="TrailController createTrail should create a trail" duration="2" />
<testCase name="TrailController createTrail should throw NotFoundException if journeyId is not provided" duration="11" />
<testCase name="TrailController getTrailById should return a trail by id" duration="4" />
<testCase name="TrailController getAllTrails should return all trails" duration="2" />
<testCase name="TrailController updateTrail should update a trail" duration="2" />
<testCase name="TrailController addContentToTrail should add content to a trail" duration="2" />
<testCase name="TrailController addContentToTrail should throw NotFoundException if contentId is not provided" duration="2" />
<testCase name="TrailController removeContentFromTrail should remove content from a trail" duration="2" />
<testCase name="TrailController deleteTrail should delete a trail" duration="2" />
</file>
<file path="test/journey.controller.spec.ts">
<testCase name="JourneyController should be defined" duration="12" />
<testCase name="JourneyController create should create a journey" duration="4" />
<testCase name="JourneyController create should throw UnauthorizedException if token is not provided" duration="17" />
<testCase name="JourneyController findAll should return all journeys" duration="6" />
<testCase name="JourneyController findByUser should return journeys by user id" duration="5" />
<testCase name="JourneyController findById should return a journey by id" duration="4" />
<testCase name="JourneyController update should update a journey" duration="4" />
<testCase name="JourneyController delete should delete a journey" duration="3" />
<testCase name="JourneyController addTrailToJourney should add a trail to a journey" duration="5" />
</file>
</testExecutions>
2 changes: 1 addition & 1 deletion src/trail/trail.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class TrailService {
if (!journey) {
throw new NotFoundException(`Journey with ID ${journeyId} not found`);
}
return this.trailModel.find({ _id: { $in: journey.trails } }).exec();
return await this.trailModel.find({ journey: journeyId }).exec();
}
async updateTrail(id: string, updateData: Partial<Trail>): Promise<Trail> {
const trail = await this.trailModel
Expand Down

0 comments on commit 8bb89cf

Please sign in to comment.