4 Commits

Author SHA1 Message Date
Mathis HERRIOT
46ffdd809c chore: bump version to 1.8.1
All checks were successful
CI/CD Pipeline / Valider backend (push) Successful in 1m36s
CI/CD Pipeline / Valider frontend (push) Successful in 1m41s
CI/CD Pipeline / Valider documentation (push) Successful in 1m45s
CI/CD Pipeline / Déploiement en Production (push) Successful in 5m30s
2026-01-29 15:11:01 +01:00
Mathis HERRIOT
2dcd277347 test: rename variables and format multiline assertions in messages service spec
- Renamed `repository` and `eventsGateway` to `_repository` and `_eventsGateway` to follow conventions for unused test variables.
- Reformatted multiline assertions for better readability.
2026-01-29 15:10:56 +01:00
Mathis HERRIOT
9486803aeb test: rename variables and format multiline assertion in events gateway spec
- Renamed `jwtService` to `_jwtService` to align with conventions for unused test variables.
- Adjusted multiline assertion formatting for improved readability.
2026-01-29 15:10:43 +01:00
Mathis HERRIOT
1e0bb03182 test: format multiline assertion in comments service spec
- Adjusted `remove` test to improve readability of multiline assertion.
2026-01-29 15:10:22 +01:00
6 changed files with 37 additions and 18 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@memegoat/backend", "name": "@memegoat/backend",
"version": "1.8.0", "version": "1.8.1",
"description": "", "description": "",
"author": "", "author": "",
"private": true, "private": true,

View File

@@ -76,7 +76,9 @@ describe("CommentsService", () => {
it("should throw ForbiddenException if not owner and not admin", async () => { it("should throw ForbiddenException if not owner and not admin", async () => {
mockCommentsRepository.findOne.mockResolvedValue({ userId: "u1" }); mockCommentsRepository.findOne.mockResolvedValue({ userId: "u1" });
await expect(service.remove("other", "c1")).rejects.toThrow(ForbiddenException); await expect(service.remove("other", "c1")).rejects.toThrow(
ForbiddenException,
);
}); });
}); });
}); });

View File

@@ -6,8 +6,8 @@ import { MessagesRepository } from "./repositories/messages.repository";
describe("MessagesService", () => { describe("MessagesService", () => {
let service: MessagesService; let service: MessagesService;
let repository: MessagesRepository; let _repository: MessagesRepository;
let eventsGateway: EventsGateway; let _eventsGateway: EventsGateway;
const mockMessagesRepository = { const mockMessagesRepository = {
findConversationBetweenUsers: jest.fn(), findConversationBetweenUsers: jest.fn(),
@@ -33,28 +33,39 @@ describe("MessagesService", () => {
}).compile(); }).compile();
service = module.get<MessagesService>(MessagesService); service = module.get<MessagesService>(MessagesService);
repository = module.get<MessagesRepository>(MessagesRepository); _repository = module.get<MessagesRepository>(MessagesRepository);
eventsGateway = module.get<EventsGateway>(EventsGateway); _eventsGateway = module.get<EventsGateway>(EventsGateway);
}); });
describe("sendMessage", () => { describe("sendMessage", () => {
it("should send message to existing conversation", async () => { it("should send message to existing conversation", async () => {
const senderId = "s1"; const senderId = "s1";
const dto = { recipientId: "r1", text: "hello" }; const dto = { recipientId: "r1", text: "hello" };
mockMessagesRepository.findConversationBetweenUsers.mockResolvedValue({ id: "conv1" }); mockMessagesRepository.findConversationBetweenUsers.mockResolvedValue({
mockMessagesRepository.createMessage.mockResolvedValue({ id: "m1", text: "hello" }); id: "conv1",
});
mockMessagesRepository.createMessage.mockResolvedValue({
id: "m1",
text: "hello",
});
const result = await service.sendMessage(senderId, dto); const result = await service.sendMessage(senderId, dto);
expect(result.id).toBe("m1"); expect(result.id).toBe("m1");
expect(mockEventsGateway.sendToUser).toHaveBeenCalledWith("r1", "new_message", expect.anything()); expect(mockEventsGateway.sendToUser).toHaveBeenCalledWith(
"r1",
"new_message",
expect.anything(),
);
}); });
it("should create new conversation if not exists", async () => { it("should create new conversation if not exists", async () => {
const senderId = "s1"; const senderId = "s1";
const dto = { recipientId: "r1", text: "hello" }; const dto = { recipientId: "r1", text: "hello" };
mockMessagesRepository.findConversationBetweenUsers.mockResolvedValue(null); mockMessagesRepository.findConversationBetweenUsers.mockResolvedValue(null);
mockMessagesRepository.createConversation.mockResolvedValue({ id: "new_conv" }); mockMessagesRepository.createConversation.mockResolvedValue({
id: "new_conv",
});
mockMessagesRepository.createMessage.mockResolvedValue({ id: "m1" }); mockMessagesRepository.createMessage.mockResolvedValue({ id: "m1" });
await service.sendMessage(senderId, dto); await service.sendMessage(senderId, dto);
@@ -67,7 +78,9 @@ describe("MessagesService", () => {
describe("getMessages", () => { describe("getMessages", () => {
it("should return messages if user is participant", async () => { it("should return messages if user is participant", async () => {
mockMessagesRepository.isParticipant.mockResolvedValue(true); mockMessagesRepository.isParticipant.mockResolvedValue(true);
mockMessagesRepository.findMessagesByConversationId.mockResolvedValue([{ id: "m1" }]); mockMessagesRepository.findMessagesByConversationId.mockResolvedValue([
{ id: "m1" },
]);
const result = await service.getMessages("u1", "conv1"); const result = await service.getMessages("u1", "conv1");
expect(result).toHaveLength(1); expect(result).toHaveLength(1);
@@ -75,7 +88,9 @@ describe("MessagesService", () => {
it("should throw ForbiddenException if user is not participant", async () => { it("should throw ForbiddenException if user is not participant", async () => {
mockMessagesRepository.isParticipant.mockResolvedValue(false); mockMessagesRepository.isParticipant.mockResolvedValue(false);
await expect(service.getMessages("u1", "conv1")).rejects.toThrow(ForbiddenException); await expect(service.getMessages("u1", "conv1")).rejects.toThrow(
ForbiddenException,
);
}); });
}); });
}); });

View File

@@ -1,12 +1,11 @@
import { ConfigService } from "@nestjs/config"; import { ConfigService } from "@nestjs/config";
import { Test, TestingModule } from "@nestjs/testing"; import { Test, TestingModule } from "@nestjs/testing";
import { Server } from "socket.io";
import { JwtService } from "../crypto/services/jwt.service"; import { JwtService } from "../crypto/services/jwt.service";
import { EventsGateway } from "./events.gateway"; import { EventsGateway } from "./events.gateway";
describe("EventsGateway", () => { describe("EventsGateway", () => {
let gateway: EventsGateway; let gateway: EventsGateway;
let jwtService: JwtService; let _jwtService: JwtService;
const mockJwtService = { const mockJwtService = {
verifyJwt: jest.fn(), verifyJwt: jest.fn(),
@@ -26,7 +25,7 @@ describe("EventsGateway", () => {
}).compile(); }).compile();
gateway = module.get<EventsGateway>(EventsGateway); gateway = module.get<EventsGateway>(EventsGateway);
jwtService = module.get<JwtService>(JwtService); _jwtService = module.get<JwtService>(JwtService);
gateway.server = { gateway.server = {
to: jest.fn().mockReturnThis(), to: jest.fn().mockReturnThis(),
emit: jest.fn(), emit: jest.fn(),
@@ -46,7 +45,10 @@ describe("EventsGateway", () => {
gateway.sendToUser(userId, event, data); gateway.sendToUser(userId, event, data);
expect(gateway.server.to).toHaveBeenCalledWith(`user:${userId}`); expect(gateway.server.to).toHaveBeenCalledWith(`user:${userId}`);
expect(gateway.server.to(`user:${userId}`).emit).toHaveBeenCalledWith(event, data); expect(gateway.server.to(`user:${userId}`).emit).toHaveBeenCalledWith(
event,
data,
);
}); });
}); });
}); });

View File

@@ -1,6 +1,6 @@
{ {
"name": "@memegoat/frontend", "name": "@memegoat/frontend",
"version": "1.8.0", "version": "1.8.1",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@memegoat/source", "name": "@memegoat/source",
"version": "1.8.0", "version": "1.8.1",
"description": "", "description": "",
"scripts": { "scripts": {
"version:get": "cmake -P version.cmake GET", "version:get": "cmake -P version.cmake GET",