feat(api): add GroupsModule with GET /groups endpoint

Implements TDD-driven GroupsService and GroupsController with full unit test coverage. GET /groups returns all groups ordered by name, selecting id, name, platform, platformId, isActive, and accountId fields.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-28 00:55:13 +05:30
parent e73d39b798
commit 0e92b24bf0
5 changed files with 94 additions and 0 deletions
@@ -0,0 +1,26 @@
import { Test, TestingModule } from '@nestjs/testing';
import { GroupsController } from './groups.controller';
import { GroupsService } from './groups.service';
const mockGroups = [
{ id: 'grp_1', name: 'Alpha', platform: 'whatsapp', platformId: '111@g.us', isActive: true, accountId: 'acc_1' },
];
const mockService = { list: jest.fn().mockResolvedValue(mockGroups) };
describe('GroupsController', () => {
let controller: GroupsController;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [GroupsController],
providers: [{ provide: GroupsService, useValue: mockService }],
}).compile();
controller = module.get<GroupsController>(GroupsController);
});
it('returns groups from service', async () => {
const result = await controller.list();
expect(result).toEqual(mockGroups);
expect(mockService.list).toHaveBeenCalled();
});
});