improve test coverage

This commit is contained in:
Alex Holliday committed 2025-11-24 22:49:55 +00:00
1 parent d5f1032bdf
commit 1e26fb1e3b
15 files changed
+388 -71

No files matched your search

+13 -2
View File
@@ -1,11 +1,14 @@
import { Request, Response, NextFunction } from "express";
import InviteService from "@/services/business/InviteService.js";
import ApiError from "@/utils/ApiError.js";
import { EmailService, InviteService } from "@/services/index.js";
import { config } from "@/config/index.js";
class InviteController {
private emailService: EmailService;
private inviteService: InviteService;
constructor(inviteService: InviteService) {
constructor(inviteService: InviteService, emailService: EmailService) {
this.inviteService = inviteService;
this.emailService = emailService;
}
create = async (req: Request, res: Response, next: NextFunction) => {
@@ -36,6 +39,14 @@ class InviteController {
teamId,
teamRoleId
);
try {
this.emailService.sendGeneric(email, "You're invited!", {
text: `You have been invited to join Checkmate. Use this link to accept the invite: ${config.ORIGIN}/register/${invite}`,
});
} catch (error) {
console.error("Failed to send invite email:", error);
}
res.status(201).json({ message: "OK", data: invite });
} catch (error: any) {
next(error);
+3 -5
View File
@@ -49,11 +49,9 @@ class RecoveryController implements IRecoveryController {
const recoveryToken = await this.recoveryService.create(user._id);
// Don't wait for email to be sent
this.emailService
.sendGeneric(
user.email,
"Password Recovery",
`Your recovery link is: ${config.ORIGIN}/recovery/${recoveryToken}`
)
.sendGeneric(user.email, "Password Recovery", {
text: `Your recovery link is: ${config.ORIGIN}/recovery/${recoveryToken}`,
})
.catch((error) => {
logger.error(error);
});
@@ -143,12 +143,14 @@ class TeamMemberController implements ITeamMemberController {
}
const teamMemberId = req.params.id;
if (!req.params.id) {
if (!teamMemberId) {
throw new ApiError("No team member ID", 400);
}
const deleted = await this.teamMemberService.delete(orgId, req.params.id);
console.log(teamMemberId);
const deleted = await this.teamMemberService.delete(orgId, teamMemberId);
invalidateCachesForUser(teamMemberId);
if (!deleted) {
throw new ApiError("Failed to delete team member", 500);
}