Skip to content
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

refactor: change votes module types for constants #1426

Merged
merged 20 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d220545
refactor: change type for constants on team module
CatiaAntunes96 Apr 14, 2023
53af6a4
fix: fix imports of team constants on tests
CatiaAntunes96 Apr 14, 2023
0690329
refactor: change type for constants on team module
CatiaAntunes96 Apr 14, 2023
0dc8771
Merge branch 'main'
CatiaAntunes96 Apr 19, 2023
3fdb349
feat: remove CODEOWNERS file
CatiaAntunes96 Apr 19, 2023
7ff9a81
Merge branch 'main' into refactor/change-teamUser-module-types-for-co…
CatiaAntunes96 Apr 19, 2023
d65910f
refactor: extract types from interfaces
CatiaAntunes96 Apr 19, 2023
d47a65f
refactor: change TYPES to constants(services)
CatiaAntunes96 Apr 19, 2023
75e061e
refactor: change TYPES to CONSTANTS(useCases)
CatiaAntunes96 Apr 19, 2023
f83c0bc
refactor: change TYPES from CONSTANTS subscribers
CatiaAntunes96 Apr 19, 2023
a64f381
Merge branch 'main'
CatiaAntunes96 Apr 19, 2023
9906b04
refactor: change Document to Entity
CatiaAntunes96 Apr 19, 2023
e9ba35b
refactor: change TYPES for CONSTANTS (boardUser)
CatiaAntunes96 Apr 20, 2023
cadbfa3
Merge branch 'main'
CatiaAntunes96 Apr 20, 2023
0a98951
refactor: change filename to constants
CatiaAntunes96 Apr 20, 2023
b1d4046
refactor: change TYPES for CONSTANTS (cards)
CatiaAntunes96 Apr 20, 2023
c8bab15
Merge branch 'main'
CatiaAntunes96 Apr 20, 2023
e9bc588
refactor: change filename to constants
CatiaAntunes96 Apr 20, 2023
61f8d76
refactor: change TYPES for CONSTANTS (votes)
CatiaAntunes96 Apr 20, 2023
9dbbc7b
Merge branch 'main'
CatiaAntunes96 Apr 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing';
import * as CommunicationsType from 'src/modules/communication/interfaces/types';
import * as Votes from 'src/modules/votes/interfaces/types';
import { BoardRepositoryInterface } from '../repositories/board.repository.interface';
import { CommunicationServiceInterface } from 'src/modules/communication/interfaces/slack-communication.service.interface';
import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock';
Expand Down Expand Up @@ -30,6 +29,7 @@ import {
GET_BOARD_USER_SERVICE,
UPDATE_BOARD_USER_SERVICE
} from 'src/modules/boardUsers/constants';
import { DELETE_VOTE_SERVICE } from 'src/modules/votes/constants';

const regularBoard = BoardFactory.create({ isSubBoard: false, dividedBoards: [] });
const userId = faker.datatype.uuid();
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('UpdateBoardUseCase', () => {
useValue: createMock<CommunicationServiceInterface>()
},
{
provide: Votes.TYPES.services.DeleteVoteService,
provide: DELETE_VOTE_SERVICE,
useValue: createMock<DeleteVoteServiceInterface>()
},
{
Expand All @@ -132,7 +132,7 @@ describe('UpdateBoardUseCase', () => {
boardRepositoryMock = module.get(BOARD_REPOSITORY);
updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE);
getBoardUserServiceMock = module.get(GET_BOARD_USER_SERVICE);
deleteVoteServiceMock = module.get(Votes.TYPES.services.DeleteVoteService);
deleteVoteServiceMock = module.get(DELETE_VOTE_SERVICE);
slackCommunicationServiceMock = module.get(
CommunicationsType.TYPES.services.SlackCommunicationService
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { CommunicationServiceInterface } from 'src/modules/communication/interfa
import * as CommunicationsType from 'src/modules/communication/interfaces/types';
import User from 'src/modules/users/entities/user.schema';
import { DeleteVoteServiceInterface } from 'src/modules/votes/interfaces/services/delete.vote.service.interface';
import * as Votes from 'src/modules/votes/interfaces/types';
import { UpdateBoardDto } from '../dto/update-board.dto';
import Board from '../entities/board.schema';
import { ResponsibleType } from '../interfaces/responsible.interface';
Expand All @@ -23,6 +22,7 @@ import {
GET_BOARD_USER_SERVICE,
UPDATE_BOARD_USER_SERVICE
} from 'src/modules/boardUsers/constants';
import { DELETE_VOTE_SERVICE } from 'src/modules/votes/constants';

@Injectable()
export class UpdateBoardUseCase implements UseCase<UpdateBoardDto, Board> {
Expand All @@ -33,7 +33,7 @@ export class UpdateBoardUseCase implements UseCase<UpdateBoardDto, Board> {
private readonly getBoardUserService: GetBoardUserServiceInterface,
@Inject(UPDATE_BOARD_USER_SERVICE)
private readonly updateBoardUserService: UpdateBoardUserServiceInterface,
@Inject(Votes.TYPES.services.DeleteVoteService)
@Inject(DELETE_VOTE_SERVICE)
private readonly deleteVoteService: DeleteVoteServiceInterface,
@Inject(CommunicationsType.TYPES.services.SlackCommunicationService)
private readonly slackCommunicationService: CommunicationServiceInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import { BadRequestException, Logger, NotFoundException } from '@nestjs/common';
import { Test, TestingModule } from '@nestjs/testing';
import { BoardFactory } from 'src/libs/test-utils/mocks/factories/board-factory.mock';
import SocketGateway from 'src/modules/socket/gateway/socket.gateway';
import { updateColumnService } from '../columns.providers';
import * as Columns from '../interfaces/types';
import * as Votes from 'src/modules/votes/interfaces/types';
import { ColumnRepository } from '../repositories/column.repository';
import GetBoardService from 'src/modules/boards/services/get.board.service';
import UpdateColumnService from './update.column.service';
import DeleteVoteService from 'src/modules/votes/services/delete.vote.service';
import { DeleteVoteServiceInterface } from 'src/modules/votes/interfaces/services/delete.vote.service.interface';
import { GET_BOARD_SERVICE } from 'src/modules/boards/constants';
import { DELETE_VOTE_SERVICE } from 'src/modules/votes/constants';

const fakeBoards = BoardFactory.createMany(2);

Expand All @@ -29,7 +28,7 @@ describe('UpdateColumnService', () => {
const module: TestingModule = await Test.createTestingModule({
imports: [EventEmitterModule.forRoot()],
providers: [
updateColumnService,
UpdateColumnService,
{
provide: Columns.TYPES.repositories.ColumnRepository,
useValue: createMock<ColumnRepository>()
Expand All @@ -39,7 +38,7 @@ describe('UpdateColumnService', () => {
useValue: createMock<SocketGateway>()
},
{
provide: Votes.TYPES.services.DeleteVoteService,
provide: DELETE_VOTE_SERVICE,
useValue: createMock<DeleteVoteServiceInterface>()
},
{
Expand All @@ -49,8 +48,8 @@ describe('UpdateColumnService', () => {
]
}).compile();

columnService = module.get(Columns.TYPES.services.UpdateColumnService);
deleteVoteService = module.get(Votes.TYPES.services.DeleteVoteService);
columnService = module.get(UpdateColumnService);
deleteVoteService = module.get(DELETE_VOTE_SERVICE);
repositoryColumn = module.get(Columns.TYPES.repositories.ColumnRepository);
socketService = module.get(SocketGateway);
getBoardServiceImpl = module.get(GET_BOARD_SERVICE);
Expand Down
4 changes: 2 additions & 2 deletions backend/src/modules/columns/services/update.column.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BadRequestException, Inject, Injectable, NotFoundException } from '@nestjs/common';
import { COLUMN_NOT_FOUND, UPDATE_FAILED } from 'src/libs/exceptions/messages';
import * as Votes from 'src/modules/votes/interfaces/types';
import * as Columns from '../interfaces/types';
import { UpdateColumnServiceInterface } from '../interfaces/services/update.column.service.interface';
import { UpdateColumnDto } from '../dto/update-column.dto';
Expand All @@ -10,6 +9,7 @@ import { ColumnRepositoryInterface } from '../repositories/column.repository.int
import { GetBoardServiceInterface } from 'src/modules/boards/interfaces/services/get.board.service.interface';
import { DeleteVoteServiceInterface } from 'src/modules/votes/interfaces/services/delete.vote.service.interface';
import { GET_BOARD_SERVICE } from 'src/modules/boards/constants';
import { DELETE_VOTE_SERVICE } from 'src/modules/votes/constants';

@Injectable()
export default class UpdateColumnService implements UpdateColumnServiceInterface {
Expand All @@ -19,7 +19,7 @@ export default class UpdateColumnService implements UpdateColumnServiceInterface
private readonly socketService: SocketGateway,
@Inject(GET_BOARD_SERVICE)
private readonly getBoardService: GetBoardServiceInterface,
@Inject(Votes.TYPES.services.DeleteVoteService)
@Inject(DELETE_VOTE_SERVICE)
private readonly deleteVoteService: DeleteVoteServiceInterface
) {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing';
import { TYPES } from '../interfaces/types';
import { CREATE_VOTE_SERVICE, DELETE_VOTE_SERVICE, VOTE_REPOSITORY } from '../constants';
import { DeepMocked, createMock } from '@golevelup/ts-jest';
import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface';
import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface';
Expand Down Expand Up @@ -43,15 +43,15 @@ describe('CardGroupVoteUseCase', () => {
providers: [
CardGroupVoteUseCase,
{
provide: TYPES.repositories.VoteRepository,
provide: VOTE_REPOSITORY,
useValue: createMock<VoteRepositoryInterface>()
},
{
provide: TYPES.services.DeleteVoteService,
provide: DELETE_VOTE_SERVICE,
useValue: createMock<DeleteVoteServiceInterface>()
},
{
provide: TYPES.services.CreateVoteService,
provide: CREATE_VOTE_SERVICE,
useValue: createMock<CreateVoteServiceInterface>()
},
{
Expand All @@ -62,9 +62,9 @@ describe('CardGroupVoteUseCase', () => {
}).compile();

useCase = module.get(CardGroupVoteUseCase);
voteRepositoryMock = module.get(TYPES.repositories.VoteRepository);
createVoteServiceMock = module.get(TYPES.services.CreateVoteService);
deleteVoteServiceMock = module.get(TYPES.services.DeleteVoteService);
voteRepositoryMock = module.get(VOTE_REPOSITORY);
createVoteServiceMock = module.get(CREATE_VOTE_SERVICE);
deleteVoteServiceMock = module.get(DELETE_VOTE_SERVICE);
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Inject, Injectable, Logger } from '@nestjs/common';
import { TYPES } from '../interfaces/types';
import { CREATE_VOTE_SERVICE, DELETE_VOTE_SERVICE, VOTE_REPOSITORY } from '../constants';
import { UseCase } from 'src/libs/interfaces/use-case.interface';
import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface';
import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface';
Expand All @@ -20,13 +20,13 @@ import { UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants';
export class CardGroupVoteUseCase implements UseCase<CardGroupVoteUseCaseDto, void> {
private logger: Logger = new Logger('CreateVoteService');
constructor(
@Inject(TYPES.services.CreateVoteService)
@Inject(CREATE_VOTE_SERVICE)
private readonly createVoteService: CreateVoteServiceInterface,
@Inject(TYPES.repositories.VoteRepository)
@Inject(VOTE_REPOSITORY)
private readonly voteRepository: VoteRepositoryInterface,
@Inject(UPDATE_BOARD_USER_SERVICE)
private readonly updateBoardUserService: UpdateBoardUserServiceInterface,
@Inject(TYPES.services.DeleteVoteService)
@Inject(DELETE_VOTE_SERVICE)
private readonly deleteVoteService: DeleteVoteServiceInterface
) {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing';
import { TYPES } from '../interfaces/types';
import { CREATE_VOTE_SERVICE, DELETE_VOTE_SERVICE, VOTE_REPOSITORY } from '../constants';
import { DeepMocked, createMock } from '@golevelup/ts-jest';
import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface';
import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface';
Expand Down Expand Up @@ -44,15 +44,15 @@ describe('CardItemVoteUseCase', () => {
providers: [
CardItemVoteUseCase,
{
provide: TYPES.repositories.VoteRepository,
provide: VOTE_REPOSITORY,
useValue: createMock<VoteRepositoryInterface>()
},
{
provide: TYPES.services.DeleteVoteService,
provide: DELETE_VOTE_SERVICE,
useValue: createMock<DeleteVoteServiceInterface>()
},
{
provide: TYPES.services.CreateVoteService,
provide: CREATE_VOTE_SERVICE,
useValue: createMock<CreateVoteServiceInterface>()
},
{
Expand All @@ -63,9 +63,9 @@ describe('CardItemVoteUseCase', () => {
}).compile();

useCase = module.get(CardItemVoteUseCase);
voteRepositoryMock = module.get(TYPES.repositories.VoteRepository);
createVoteServiceMock = module.get(TYPES.services.CreateVoteService);
deleteVoteServiceMock = module.get(TYPES.services.DeleteVoteService);
voteRepositoryMock = module.get(VOTE_REPOSITORY);
createVoteServiceMock = module.get(CREATE_VOTE_SERVICE);
deleteVoteServiceMock = module.get(DELETE_VOTE_SERVICE);
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Inject, Injectable, Logger } from '@nestjs/common';
import { TYPES } from '../interfaces/types';
import { CREATE_VOTE_SERVICE, DELETE_VOTE_SERVICE, VOTE_REPOSITORY } from '../constants';
import { UseCase } from 'src/libs/interfaces/use-case.interface';
import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface';
import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface';
Expand All @@ -17,11 +17,11 @@ import { UPDATE_BOARD_USER_SERVICE } from 'src/modules/boardUsers/constants';
export class CardItemVoteUseCase implements UseCase<CardItemVoteUseCaseDto, void> {
private logger: Logger = new Logger('CreateVoteService');
constructor(
@Inject(TYPES.services.CreateVoteService)
@Inject(CREATE_VOTE_SERVICE)
private readonly createVoteService: CreateVoteServiceInterface,
@Inject(TYPES.services.DeleteVoteService)
@Inject(DELETE_VOTE_SERVICE)
private readonly deleteVoteService: DeleteVoteServiceInterface,
@Inject(TYPES.repositories.VoteRepository)
@Inject(VOTE_REPOSITORY)
private readonly voteRepository: VoteRepositoryInterface,
@Inject(UPDATE_BOARD_USER_SERVICE)
private readonly updateBoardUserService: UpdateBoardUserServiceInterface
Expand Down
15 changes: 15 additions & 0 deletions backend/src/modules/votes/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* SERVICES */

export const CREATE_VOTE_SERVICE = 'CreateVoteService';

export const DELETE_VOTE_SERVICE = 'DeleteVoteService';

/* USE CASES */

export const CARD_ITEM_VOTE_USE_CASE = 'CardItemVoteUseCase';

export const CARD_GROUP_VOTE_USE_CASE = 'CardGroupVoteUseCase';

/* REPOSITORY */

export const VOTE_REPOSITORY = 'VoteRepository';
6 changes: 3 additions & 3 deletions backend/src/modules/votes/controller/votes.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { UnauthorizedResponse } from 'src/libs/swagger/errors/unauthorized.swagg
import BoardDto from 'src/modules/boards/dto/board.dto';
import SocketGateway from 'src/modules/socket/gateway/socket.gateway';
import VoteDto from '../dto/vote.dto';
import { TYPES } from '../interfaces/types';
import { CARD_GROUP_VOTE_USE_CASE, CARD_ITEM_VOTE_USE_CASE } from '../constants';
import { UseCase } from 'src/libs/interfaces/use-case.interface';
import CardItemVoteUseCaseDto from '../dto/useCase/card-item-vote.use-case.dto';
import CardGroupVoteUseCaseDto from '../dto/useCase/card-group-vote.use-case.dto';
Expand All @@ -32,9 +32,9 @@ import CardGroupVoteUseCaseDto from '../dto/useCase/card-group-vote.use-case.dto
@Controller('boards')
export default class VotesController {
constructor(
@Inject(TYPES.applications.CardItemVoteUseCase)
@Inject(CARD_ITEM_VOTE_USE_CASE)
private readonly cardItemVoteUseCase: UseCase<CardItemVoteUseCaseDto, void>,
@Inject(TYPES.applications.CardGroupVoteUseCase)
@Inject(CARD_GROUP_VOTE_USE_CASE)
private readonly cardGroupVoteUseCase: UseCase<CardGroupVoteUseCaseDto, void>,
private readonly socketService: SocketGateway
) {}
Expand Down
13 changes: 0 additions & 13 deletions backend/src/modules/votes/interfaces/types.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing';
import { TYPES } from '../interfaces/types';
import { VOTE_REPOSITORY } from '../constants';
import { DeepMocked, createMock } from '@golevelup/ts-jest';
import CreateVoteService from './create.vote.service';
import { CreateVoteServiceInterface } from '../interfaces/services/create.vote.service.interface';
Expand Down Expand Up @@ -38,7 +38,7 @@ describe('CreateVoteService', () => {
providers: [
CreateVoteService,
{
provide: TYPES.repositories.VoteRepository,
provide: VOTE_REPOSITORY,
useValue: createMock<VoteRepositoryInterface>()
},
{
Expand All @@ -55,8 +55,8 @@ describe('CreateVoteService', () => {
}
]
}).compile();
voteService = module.get<CreateVoteServiceInterface>(CreateVoteService);
voteRepositoryMock = module.get(TYPES.repositories.VoteRepository);
voteService = module.get(CreateVoteService);
voteRepositoryMock = module.get(VOTE_REPOSITORY);
getBoardUserServiceMock = module.get(GET_BOARD_USER_SERVICE);
getBoardServiceMock = module.get(GET_BOARD_SERVICE);
updateBoardUserServiceMock = module.get(UPDATE_BOARD_USER_SERVICE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing';
import { TYPES } from '../interfaces/types';
import { VOTE_REPOSITORY } from '../constants';
import { DeepMocked, createMock } from '@golevelup/ts-jest';
import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface';
import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface';
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('DeleteVoteService', () => {
providers: [
DeleteVoteService,
{
provide: TYPES.repositories.VoteRepository,
provide: VOTE_REPOSITORY,
useValue: createMock<VoteRepositoryInterface>()
},
{
Expand All @@ -69,7 +69,7 @@ describe('DeleteVoteService', () => {
]
}).compile();
voteService = module.get(DeleteVoteService);
voteRepositoryMock = module.get(TYPES.repositories.VoteRepository);
voteRepositoryMock = module.get(VOTE_REPOSITORY);
getBoardServiceMock = module.get(GET_BOARD_SERVICE);
getBoardUserServiceMock = module.get(GET_BOARD_USER_SERVICE);
getCardServiceMock = module.get(GET_CARD_SERVICE);
Expand Down
4 changes: 2 additions & 2 deletions backend/src/modules/votes/services/delete.vote.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DELETE_VOTE_FAILED, UPDATE_FAILED } from 'src/libs/exceptions/messages'
import isEmpty from 'src/libs/utils/isEmpty';
import { GetCardServiceInterface } from 'src/modules/cards/interfaces/services/get.card.service.interface';
import { DeleteVoteServiceInterface } from '../interfaces/services/delete.vote.service.interface';
import { TYPES } from '../interfaces/types';
import { VOTE_REPOSITORY } from '../constants';
import { VoteRepositoryInterface } from '../interfaces/repositories/vote.repository.interface';
import { UpdateBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/update.board.user.service.interface';
import { GetBoardUserServiceInterface } from 'src/modules/boardUsers/interfaces/services/get.board.user.service.interface';
Expand All @@ -26,7 +26,7 @@ import { GET_CARD_SERVICE } from 'src/modules/cards/constants';
@Injectable()
export default class DeleteVoteService implements DeleteVoteServiceInterface {
constructor(
@Inject(TYPES.repositories.VoteRepository)
@Inject(VOTE_REPOSITORY)
private readonly voteRepository: VoteRepositoryInterface,
@Inject(GET_BOARD_USER_SERVICE)
private readonly getBoardUserService: GetBoardUserServiceInterface,
Expand Down
Loading