Skip to content

Commit

Permalink
[M1_TR-210] Update tags in jobs table, job dtos, and job tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonclchua committed Sep 7, 2023
1 parent ebb36bd commit 6454a9a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 40 deletions.
12 changes: 0 additions & 12 deletions .sun-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ jobs:
- name: Backend Test Job
stage: test-be
image: node:16-alpine
cache:
- key:
files:
- server/yarn.lock
paths:
- server/node_modules
script:
- cd server
- yarn install
Expand All @@ -58,12 +52,6 @@ jobs:
- name: Frontend Test Job
stage: test-fe
image: node:16-alpine
cache:
- key:
files:
- web/yarn.lock
paths:
- web/node_modules
script:
- cd web
- yarn install
Expand Down
15 changes: 8 additions & 7 deletions server/src/api/job/dtos/create-job-dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { $Enums, PaymentMethod, Tag } from "@prisma/client";
import { PaymentMethod, Tag } from "@prisma/client";
import { ApiProperty } from "@nestjs/swagger";
import {
IsIn,
IsArray,
IsEnum,
IsNumber,
IsOptional,
IsString,
Expand All @@ -17,9 +18,9 @@ export class CreateJobDto {
type: string;

@ApiProperty()
@IsString()
@IsIn(Object.values(Tag))
tags: $Enums.Tag;
@IsArray()
@IsEnum(Tag, { each: true })
tags: Tag[]

@ApiProperty()
@IsOptional()
Expand All @@ -28,8 +29,8 @@ export class CreateJobDto {

@ApiProperty()
@IsString()
@IsIn(Object.values(PaymentMethod))
paymentMethod: $Enums.PaymentMethod;
@IsEnum(PaymentMethod)
paymentMethod: PaymentMethod;

@ApiProperty()
@IsNumber()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from "@nestjs/swagger";
import { Tag, $Enums, PaymentMethod } from "@prisma/client";
import { IsString, IsIn, IsOptional } from "class-validator";
import { Tag, PaymentMethod } from "@prisma/client";
import { IsString, IsOptional, IsEnum, IsArray } from "class-validator";

export class CreateJobWithoutCustomerIdAndUserIdDto {
@ApiProperty()
Expand All @@ -12,9 +12,9 @@ export class CreateJobWithoutCustomerIdAndUserIdDto {
type: string;

@ApiProperty()
@IsString()
@IsIn(Object.values(Tag))
tags: $Enums.Tag;
@IsArray()
@IsEnum(Tag, { each: true })
tags: Tag[]

@ApiProperty()
@IsOptional()
Expand All @@ -23,8 +23,8 @@ export class CreateJobWithoutCustomerIdAndUserIdDto {

@ApiProperty()
@IsString()
@IsIn(Object.values(PaymentMethod))
paymentMethod: $Enums.PaymentMethod;
@IsEnum(PaymentMethod)
paymentMethod: PaymentMethod;

@ApiProperty()
@IsOptional()
Expand Down
10 changes: 5 additions & 5 deletions server/src/api/job/job.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('JobController', () => {
job_information: {
title: "string",
type: "string",
tags: $Enums.Tag.TAG_A,
tags: [$Enums.Tag.TAG_A],
remarks: "string",
paymentMethod: $Enums.PaymentMethod.CASH,
},
Expand All @@ -41,7 +41,7 @@ describe('JobController', () => {
id: 1,
title: "string",
type: "string",
tags: $Enums.Tag.TAG_A,
tags: [$Enums.Tag.TAG_A],
remarks: "string",
customerId: 1,
paymentMethod: $Enums.PaymentMethod.CASH,
Expand All @@ -64,7 +64,7 @@ describe('JobController', () => {
id: 1,
title: "Sample title 1",
type: "A",
tags: "TAG_A",
tags: [$Enums.Tag.TAG_A],
remarks: "",
customerId: 1,
paymentMethod: "CARD",
Expand All @@ -73,7 +73,7 @@ describe('JobController', () => {
id: 2,
title: "Sample title 2",
type: "A",
tags: "TAG_A",
tags: [$Enums.Tag.TAG_A],
remarks: "",
customerId: 1,
paymentMethod: "CARD",
Expand All @@ -94,7 +94,7 @@ describe('JobController', () => {
id: 1,
title: "Sample title 1",
type: "A",
tags: "TAG_A",
tags: [$Enums.Tag.TAG_A],
remarks: "",
customerId: 1,
paymentMethod: "CARD",
Expand Down
14 changes: 7 additions & 7 deletions server/src/api/job/job.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('JobController', () => {
job_information: {
title: "string",
type: "string",
tags: $Enums.Tag.TAG_A,
tags: [$Enums.Tag.TAG_A],
remarks: "string",
paymentMethod: $Enums.PaymentMethod.CASH,
},
Expand All @@ -40,7 +40,7 @@ describe('JobController', () => {
id: 1,
title: "string",
type: "string",
tags: $Enums.Tag.TAG_A,
tags: [$Enums.Tag.TAG_A],
remarks: "string",
customerId: 1,
paymentMethod: $Enums.PaymentMethod.CASH,
Expand All @@ -66,7 +66,7 @@ describe('JobController', () => {
id: 1,
title: "Sample title 1",
type: "A",
tags: $Enums.Tag.TAG_A,
tags: [$Enums.Tag.TAG_A],
remarks: "",
customerId: 1,
paymentMethod: $Enums.PaymentMethod.CASH,
Expand All @@ -90,7 +90,7 @@ describe('JobController', () => {
id: 1,
title: "Sample title 1",
type: "A",
tags: $Enums.Tag.TAG_A,
tags: [$Enums.Tag.TAG_A],
remarks: "",
customerId: 1,
paymentMethod: $Enums.PaymentMethod.CASH,
Expand All @@ -101,7 +101,7 @@ describe('JobController', () => {
id: 2,
title: "Sample title 2",
type: "A",
tags: $Enums.Tag.TAG_A,
tags: [$Enums.Tag.TAG_A],
remarks: "",
customerId: 1,
paymentMethod: $Enums.PaymentMethod.CARD,
Expand All @@ -124,7 +124,7 @@ describe('JobController', () => {
const jobInput = {
title: "Sample title 1",
type: "A",
tags: $Enums.Tag.TAG_A,
tags: [$Enums.Tag.TAG_A],
remarks: "",
paymentMethod: $Enums.PaymentMethod.CASH,
customerId: 1,
Expand All @@ -135,7 +135,7 @@ describe('JobController', () => {
id: 1,
title: "Sample title 1",
type: "A",
tags: $Enums.Tag.TAG_A,
tags: [$Enums.Tag.TAG_A],
remarks: "",
paymentMethod: $Enums.PaymentMethod.CASH,
customerId: 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CREATE TABLE "Job" (
"id" SERIAL NOT NULL,
"title" TEXT NOT NULL,
"type" TEXT NOT NULL,
"tags" "Tag" NOT NULL DEFAULT 'TAG_A',
"tags" "Tag"[] DEFAULT ARRAY['TAG_A']::"Tag"[],
"remarks" TEXT NOT NULL,
"customerId" INTEGER NOT NULL,
"paymentMethod" "PaymentMethod" NOT NULL DEFAULT 'CASH',
Expand Down
2 changes: 1 addition & 1 deletion server/src/models/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ model Job {
id Int @id @default(autoincrement())
title String
type String
tags Tag @default(TAG_A)
tags Tag[] @default([TAG_A])
remarks String
customer Customer @relation(fields: [customerId], references: [id])
customerId Int
Expand Down

0 comments on commit 6454a9a

Please sign in to comment.