diff --git a/src/db/migrations/1685132702026-default.ts b/src/db/migrations/1685132702026-default.ts index 905f17f..3cf547e 100644 --- a/src/db/migrations/1685132702026-default.ts +++ b/src/db/migrations/1685132702026-default.ts @@ -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" ( diff --git a/src/domain/entities/serviceOrderEnum/status.ts b/src/domain/entities/serviceOrderEnum/status.ts index 17461fe..11f8021 100644 --- a/src/domain/entities/serviceOrderEnum/status.ts +++ b/src/domain/entities/serviceOrderEnum/status.ts @@ -3,5 +3,6 @@ export enum Status { MAINTENANCE = 'Em manuntenção', WARRANTY = 'Garantia', CONCLUDED = 'Concluido', + FINISHED = 'Finalizado', CANCELED = 'Cancelado' } diff --git a/src/useCases/update-order-service/update-order-service.ts b/src/useCases/update-order-service/update-order-service.ts index 60b2bbf..f0f4082 100644 --- a/src/useCases/update-order-service/update-order-service.ts +++ b/src/useCases/update-order-service/update-order-service.ts @@ -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, { @@ -106,6 +106,9 @@ export class UpdateOrderServiceUseCase case 'CONCLUDED': { return OSStatus.CONCLUDED } + case 'FINISHED': { + return OSStatus.FINISHED + } case 'CANCELED': { return OSStatus.CANCELED } diff --git a/tests/update-order-service.spec.ts b/tests/update-order-service.spec.ts index 29890f6..b6b3064 100644 --- a/tests/update-order-service.spec.ts +++ b/tests/update-order-service.spec.ts @@ -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', @@ -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(