Skip to content

Commit

Permalink
Merge pull request #38 from fga-eps-mds/148-fix-novo-status-os
Browse files Browse the repository at this point in the history
#148 FIX: Adiciona novo status de OS
  • Loading branch information
JPedroCh authored Jul 4, 2023
2 parents 30f6105 + 1aacace commit 9f5cc21
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/db/migrations/1685132702026-default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class default1674611694082 implements MigrationInterface {
`CREATE TABLE "unit" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying NOT NULL, "localization" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_4252c4be609041e559f0c80f58a" PRIMARY KEY ("id"))`
)
await queryRunner.query(
`CREATE TYPE "public"."order_service_type_enum" AS ENUM('MAINTENANCE', 'WARRANTY', 'CONCLUDED', 'CANCELED')`
`CREATE TYPE "public"."order_service_type_enum" AS ENUM('MAINTENANCE', 'WARRANTY', 'CONCLUDED', 'FINISHED','CANCELED')`
)
await queryRunner.query(
`CREATE TABLE "order_service" (
Expand Down
1 change: 1 addition & 0 deletions src/domain/entities/serviceOrderEnum/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ export enum Status {
MAINTENANCE = 'Em manuntenção',
WARRANTY = 'Garantia',
CONCLUDED = 'Concluido',
FINISHED = 'Finalizado',
CANCELED = 'Cancelado'
}
5 changes: 4 additions & 1 deletion src/useCases/update-order-service/update-order-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class UpdateOrderServiceUseCase
})

if (
this.handleOSStatus(data.status) === OSStatus.CONCLUDED ||
this.handleOSStatus(data.status) === OSStatus.FINISHED ||
this.handleOSStatus(data.status) === OSStatus.CANCELED
) {
await this.updateEquipmentRepository.updateEquipment(equipment.id, {
Expand Down Expand Up @@ -106,6 +106,9 @@ export class UpdateOrderServiceUseCase
case 'CONCLUDED': {
return OSStatus.CONCLUDED
}
case 'FINISHED': {
return OSStatus.FINISHED
}
case 'CANCELED': {
return OSStatus.CANCELED
}
Expand Down
18 changes: 16 additions & 2 deletions tests/update-order-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ describe('Test update order use case', () => {
status: 'CONCLUDED' as OSStatus
}

const dataFinished: UpdateOrderServiceUseCaseData = {
id: 2,
equipmentId: 'equipment_id',
description: 'any_description',
seiProcess: '123456789',
senderPhone: '61992809831',
senderDocument: '12345678910',
technicianId: '123456',
technicianName: 'Pessoa',
withdrawalName: 'Recebedor',
withdrawalDocument: '98765432198',
status: 'FINISHED' as OSStatus
}

const dataCanceled: UpdateOrderServiceUseCaseData = {
id: 2,
equipmentId: 'equipment_id',
Expand Down Expand Up @@ -188,8 +202,8 @@ describe('Test update order use case', () => {
})
})

test('should call updateEquipmentRepository if order service status was updated to concluded', async () => {
const result = await updateOrderServiceUseCase.execute(dataConcluded)
test('should call updateEquipmentRepository if order service status was updated to finished', async () => {
const result = await updateOrderServiceUseCase.execute(dataFinished)

expect(updateEquipmentRepository.updateEquipment).toBeCalledTimes(1)
expect(updateEquipmentRepository.updateEquipment).toBeCalledWith(
Expand Down

0 comments on commit 9f5cc21

Please sign in to comment.