diff --git a/BE/package-lock.json b/BE/package-lock.json index 71895d3..23c7f7e 100644 --- a/BE/package-lock.json +++ b/BE/package-lock.json @@ -10,6 +10,7 @@ "license": "UNLICENSED", "dependencies": { "@liaoliaots/nestjs-redis": "^9.0.5", + "@nestjs/axios": "^3.0.1", "@nestjs/common": "^10.0.0", "@nestjs/config": "^3.1.1", "@nestjs/core": "^10.0.0", @@ -20,6 +21,7 @@ "@types/dotenv": "^8.2.0", "@types/passport-jwt": "^3.0.13", "aws-sdk": "^2.1499.0", + "axios": "^1.6.2", "bcryptjs": "^2.4.3", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", @@ -864,7 +866,7 @@ "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, + "devOptional": true, "dependencies": { "@jridgewell/trace-mapping": "0.3.9" }, @@ -876,7 +878,7 @@ "version": "0.3.9", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, + "devOptional": true, "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -1518,7 +1520,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.1.tgz", "integrity": "sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==", - "dev": true, + "devOptional": true, "engines": { "node": ">=6.0.0" } @@ -1546,7 +1548,7 @@ "version": "1.4.15", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", - "dev": true + "devOptional": true }, "node_modules/@jridgewell/trace-mapping": { "version": "0.3.20", @@ -1587,6 +1589,17 @@ "node": ">=8" } }, + "node_modules/@nestjs/axios": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.1.tgz", + "integrity": "sha512-VlOZhAGDmOoFdsmewn8AyClAdGpKXQQaY1+3PGB+g6ceurGIdTxZgRX3VXc1T6Zs60PedWjg3A82TDOB05mrzQ==", + "peerDependencies": { + "@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0", + "axios": "^1.3.1", + "reflect-metadata": "^0.1.12", + "rxjs": "^6.0.0 || ^7.0.0" + } + }, "node_modules/@nestjs/cli": { "version": "10.2.1", "resolved": "https://registry.npmjs.org/@nestjs/cli/-/cli-10.2.1.tgz", @@ -1930,25 +1943,25 @@ "version": "1.0.9", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", - "dev": true + "devOptional": true }, "node_modules/@tsconfig/node12": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true + "devOptional": true }, "node_modules/@tsconfig/node14": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true + "devOptional": true }, "node_modules/@tsconfig/node16": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true + "devOptional": true }, "node_modules/@types/babel__core": { "version": "7.20.4", @@ -2622,7 +2635,7 @@ "version": "8.11.2", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", - "dev": true, + "devOptional": true, "bin": { "acorn": "bin/acorn" }, @@ -2652,7 +2665,7 @@ "version": "8.3.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.0.tgz", "integrity": "sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==", - "dev": true, + "devOptional": true, "engines": { "node": ">=0.4.0" } @@ -2783,7 +2796,7 @@ "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true + "devOptional": true }, "node_modules/argparse": { "version": "2.0.1", @@ -2820,8 +2833,7 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/available-typed-arrays": { "version": "1.0.5", @@ -2885,6 +2897,16 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/axios": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", + "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/babel-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", @@ -3618,7 +3640,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -3794,7 +3815,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true + "devOptional": true }, "node_modules/cross-env": { "version": "7.0.3", @@ -4079,7 +4100,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dev": true, "engines": { "node": ">=0.4.0" } @@ -4132,7 +4152,7 @@ "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, + "devOptional": true, "engines": { "node": ">=0.3.1" } @@ -4924,6 +4944,25 @@ "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", "dev": true }, + "node_modules/follow-redirects": { + "version": "1.15.3", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, "node_modules/for-each": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", @@ -4980,7 +5019,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dev": true, "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -6841,7 +6879,7 @@ "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true + "devOptional": true }, "node_modules/makeerror": { "version": "1.0.12", @@ -7704,6 +7742,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -9031,7 +9074,7 @@ "version": "10.9.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", "integrity": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", - "dev": true, + "devOptional": true, "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -9345,7 +9388,7 @@ "version": "5.2.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", - "dev": true, + "devOptional": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -9486,7 +9529,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true + "devOptional": true }, "node_modules/v8-to-istanbul": { "version": "9.1.3", @@ -9878,7 +9921,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "dev": true, + "devOptional": true, "engines": { "node": ">=6" } diff --git a/BE/package.json b/BE/package.json index 2ae9291..b2ad291 100644 --- a/BE/package.json +++ b/BE/package.json @@ -22,6 +22,7 @@ }, "dependencies": { "@liaoliaots/nestjs-redis": "^9.0.5", + "@nestjs/axios": "^3.0.1", "@nestjs/common": "^10.0.0", "@nestjs/config": "^3.1.1", "@nestjs/core": "^10.0.0", @@ -32,6 +33,7 @@ "@types/dotenv": "^8.2.0", "@types/passport-jwt": "^3.0.13", "aws-sdk": "^2.1499.0", + "axios": "^1.6.2", "bcryptjs": "^2.4.3", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", diff --git a/BE/src/diaries/diaries.module.ts b/BE/src/diaries/diaries.module.ts index 934418c..1a450d3 100644 --- a/BE/src/diaries/diaries.module.ts +++ b/BE/src/diaries/diaries.module.ts @@ -9,6 +9,7 @@ import { TagsModule } from "src/tags/tags.module"; import { ShapesModule } from "src/shapes/shapes.module"; import { ShapesRepository } from "src/shapes/shapes.repository"; import { TagsRepository } from "src/tags/tags.repository"; +import { HttpModule } from "@nestjs/axios"; @Module({ imports: [ @@ -16,6 +17,7 @@ import { TagsRepository } from "src/tags/tags.repository"; AuthModule, TagsModule, ShapesModule, + HttpModule, ], controllers: [DiariesController], providers: [ diff --git a/BE/src/diaries/diaries.repository.ts b/BE/src/diaries/diaries.repository.ts index 2c459f8..63ed811 100644 --- a/BE/src/diaries/diaries.repository.ts +++ b/BE/src/diaries/diaries.repository.ts @@ -10,6 +10,7 @@ import { Shape } from "src/shapes/shapes.entity"; import { NotFoundException } from "@nestjs/common"; import { Tag } from "src/tags/tags.entity"; import { ReadDiaryDto } from "./dto/diaries.read.dto"; +import { SentimentDto } from "./dto/diaries.sentiment.dto"; export class DiariesRepository { async createDiary( @@ -18,15 +19,16 @@ export class DiariesRepository { tags: Tag[], user: User, shape: Shape, + sentimentResult: SentimentDto, ): Promise { const { title, point, date } = createDiaryDto; const content = encodedContent; // 미구현 기능을 대체하기 위한 임시 값 - const positiveRatio = 0.0; - const negativeRatio = 100.0; - const neutralRatio = 0.0; - const sentiment = sentimentStatus.NEUTRAL; + const positiveRatio = sentimentResult.positiveRatio; + const negativeRatio = sentimentResult.negativeRatio; + const neutralRatio = sentimentResult.neutralRatio; + const sentiment = sentimentStatus[sentimentResult.sentiment]; const newDiary = Diary.create({ title, @@ -64,18 +66,18 @@ export class DiariesRepository { tags: Tag[], user: User, shape: Shape, + sentimentResult: SentimentDto, ): Promise { const { uuid, title, point, date } = updateDiaryDto; const content = encryptedContent; - // 미구현 기능을 대체하기 위한 임시 값 - const positiveRatio = 0.0; - const negativeRatio = 100.0; - const neutralRatio = 0.0; - const sentiment = sentimentStatus.NEUTRAL; - const diary = await this.getDiaryByUuid(uuid); + const positiveRatio = sentimentResult.positiveRatio; + const negativeRatio = sentimentResult.negativeRatio; + const neutralRatio = sentimentResult.neutralRatio; + const sentiment = sentimentStatus[sentimentResult.sentiment.toUpperCase()]; + Object.assign(diary, { title, content, diff --git a/BE/src/diaries/diaries.service.ts b/BE/src/diaries/diaries.service.ts index 1be9d39..f66f0a7 100644 --- a/BE/src/diaries/diaries.service.ts +++ b/BE/src/diaries/diaries.service.ts @@ -1,4 +1,4 @@ -import { Injectable, NotFoundException } from "@nestjs/common"; +import { Injectable } from "@nestjs/common"; import { DiariesRepository } from "./diaries.repository"; import { Diary } from "./diaries.entity"; import { @@ -6,12 +6,16 @@ import { DeleteDiaryDto, UpdateDiaryDto, } from "./dto/diaries.dto"; +import { SentimentDto } from "./dto/diaries.sentiment.dto"; import { TagsRepository } from "src/tags/tags.repository"; import { Tag } from "src/tags/tags.entity"; import { ReadDiaryDto } from "./dto/diaries.read.dto"; import { User } from "src/auth/users.entity"; import { createCipheriv, createDecipheriv } from "crypto"; import { ShapesRepository } from "src/shapes/shapes.repository"; +import { HttpService } from "@nestjs/axios"; +import { lastValueFrom } from "rxjs"; +import { sentimentStatus } from "src/utils/enum"; @Injectable() export class DiariesService { @@ -19,6 +23,7 @@ export class DiariesService { private diariesRepository: DiariesRepository, private tagsRepository: TagsRepository, private shapesRepository: ShapesRepository, + private httpService: HttpService, ) {} async writeDiary(createDiaryDto: CreateDiaryDto, user: User): Promise { @@ -26,6 +31,7 @@ export class DiariesService { const shape = await this.shapesRepository.getShapeByUuid(shapeUuid); const encryptedContent = this.getEncryptedContent(content); const tagEntities = await this.getTags(tags); + const sentimentResult = await this.getSentiment(content); const diary = await this.diariesRepository.createDiary( createDiaryDto, @@ -33,6 +39,7 @@ export class DiariesService { tagEntities, user, shape, + sentimentResult, ); return diary; @@ -79,6 +86,7 @@ export class DiariesService { const shape = await this.shapesRepository.getShapeByUuid(shapeUuid); const encryptedContent = this.getEncryptedContent(content); const tagEntities = await this.getTags(tags); + const sentimentResult = await this.getSentiment(content); return this.diariesRepository.updateDiary( updateDiaryDto, @@ -86,6 +94,7 @@ export class DiariesService { tagEntities, user, shape, + sentimentResult, ); } @@ -129,4 +138,90 @@ export class DiariesService { }), ); } + + async getSentimentByContent(content: string): Promise { + const headersData = { + "X-NCP-APIGW-API-KEY-ID": process.env.NCP_API_KEY, + "X-NCP-APIGW-API-KEY": process.env.NCP_API_SECRET, + "Content-Type": "application/json", + }; + + const BodyData = { + content: content, + }; + + const sentimentResponse = lastValueFrom( + await this.httpService.post( + "https://naveropenapi.apigw.ntruss.com/sentiment-analysis/v1/analyze", + BodyData, + { headers: headersData }, + ), + ); + + const positiveRatio = (await sentimentResponse).data.document.confidence + .positive; + const neutralRatio = (await sentimentResponse).data.document.confidence + .neutral; + const negativeRatio = (await sentimentResponse).data.document.confidence + .negative; + const sentiment = (await sentimentResponse).data.document.sentiment; + + const result: SentimentDto = { + positiveRatio, + neutralRatio, + negativeRatio, + sentiment, + }; + return result; + } + + async getSentiment(content: string): Promise { + let currentContent; + let sentimentResult; + let sentimentTotal: SentimentDto = { + positiveRatio: 0, + negativeRatio: 0, + neutralRatio: 0, + sentiment: sentimentStatus.NEUTRAL, + }; + + if (content.length === 0) { + sentimentTotal.neutralRatio = 100; + return sentimentTotal; + } + + if (content.length <= 1000) { + return await this.getSentimentByContent(content); + } + + for (let i = 0; i < content.length / 1000; i++) { + currentContent = content.slice(i * 1000, (i + 1) * 1000); + sentimentResult = await this.getSentimentByContent(currentContent); + + sentimentTotal.positiveRatio += + (await sentimentResult).positiveRatio * (currentContent.length / 1000); + sentimentTotal.negativeRatio += + (await sentimentResult).negativeRatio * (currentContent.length / 1000); + sentimentTotal.neutralRatio += + (await sentimentResult).neutralRatio * (currentContent.length / 1000); + } + + sentimentTotal.positiveRatio = + sentimentTotal.positiveRatio / (content.length / 1000); + sentimentTotal.negativeRatio = + sentimentTotal.negativeRatio / (content.length / 1000); + sentimentTotal.neutralRatio = + sentimentTotal.neutralRatio / (content.length / 1000); + + sentimentTotal.sentiment = + sentimentTotal.positiveRatio >= sentimentTotal.negativeRatio + ? sentimentTotal.positiveRatio > sentimentTotal.neutralRatio + ? sentimentStatus.POSITIVE + : sentimentStatus.NEUTRAL + : sentimentTotal.negativeRatio > sentimentTotal.neutralRatio + ? sentimentStatus.NEGATIVE + : sentimentStatus.NEUTRAL; + + return sentimentTotal; + } } diff --git a/BE/src/diaries/dto/diaries.sentiment.dto.ts b/BE/src/diaries/dto/diaries.sentiment.dto.ts new file mode 100644 index 0000000..37aceeb --- /dev/null +++ b/BE/src/diaries/dto/diaries.sentiment.dto.ts @@ -0,0 +1,8 @@ +import { sentimentStatus } from "src/utils/enum"; + +export class SentimentDto { + positiveRatio: number; + neutralRatio: number; + negativeRatio: number; + sentiment: sentimentStatus; +} diff --git a/BE/test/int/diaries.read.int-spec.ts b/BE/test/int/diaries.read.int-spec.ts index f6ba513..95e6f7b 100644 --- a/BE/test/int/diaries.read.int-spec.ts +++ b/BE/test/int/diaries.read.int-spec.ts @@ -99,7 +99,10 @@ describe("[일기 조회] /diaries/:uuid GET 통합 테스트", () => { tags: expect.arrayContaining(["tagTest", "tagTest2"]), }; - expect(postResponse.body).toEqual(expectedResponse); + expect(postResponse.body.title).toEqual(expectedResponse.title); + expect(postResponse.body.content).toEqual(expectedResponse.content); + expect(postResponse.body.date).toEqual(expectedResponse.date); + expect(postResponse.body.coordinate).toEqual(expectedResponse.coordinate); }); it("액세스 토큰 없이 요청 시 401 Unauthorized 응답", async () => { diff --git a/BE/test/int/diaries.update.int-spec.ts b/BE/test/int/diaries.update.int-spec.ts index 64ba9a7..e0963cf 100644 --- a/BE/test/int/diaries.update.int-spec.ts +++ b/BE/test/int/diaries.update.int-spec.ts @@ -113,7 +113,9 @@ describe("[일기 수정] /diaries PUT 통합 테스트", () => { .set("Authorization", `Bearer ${accessToken}`) .expect(200); - expect(postResponse.body).toEqual(expectedResponse); + expect(postResponse.body.title).toEqual(expectedResponse.title); + expect(postResponse.body.content).toEqual(expectedResponse.content); + expect(postResponse.body.date).toEqual(expectedResponse.date); }); it("액세스 토큰 없이 요청 시 401 Unauthorized 응답", async () => {