-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat: 식물 카드 상세 조회 API #33
Changes from all commits
778517e
6ca3e37
b93b261
c6c3918
e034566
ecb8328
3859104
301a075
9716720
8c08c6a
3818ed6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
## 📚 PR 요약 / Linked Issue | ||
해당 PR에서 작업한 내용을 한 줄로 요약해주세요. | ||
|
||
해당 PR에서 작업한 내용을 한 줄로 요약해주세요. | ||
close #{no} | ||
|
||
## 💡 변경 사항 | ||
|
||
디테일한 작업 내역을 적어주세요. | ||
주의할 사항이 있다면 적어주세요. | ||
변경사항 (모듈 설치 등)이 있다면 적어주세요. | ||
|
||
## ✅ PR check list | ||
- [ ] 커밋 컨벤션, 제목 등을 확인했나요? | ||
- [ ] 알맞은 라벨을 달았나요? | ||
- [ ] 셀프 코드리뷰를 작성했나요? | ||
## 📖 Swagger | ||
|
||
API Swagger 를 추가했다면 캡쳐해주세요. | ||
|
||
## ✅ PR check list | ||
|
||
- [ ] 테스트 코드를 작성했나요? (unit/e2e) | ||
- [ ] 커밋 컨벤션, 제목 등을 확인했나요? | ||
- [ ] 알맞은 라벨을 달았나요? | ||
- [ ] 셀프 코드리뷰를 작성했나요? |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ lerna-debug.log* | |
|
||
# env | ||
.env | ||
.env.test | ||
|
||
# OS | ||
.DS_Store | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Set the version of docker compose to use | ||
version: '3.9' | ||
|
||
# The containers that compose the project | ||
services: | ||
db: | ||
image: mysql:8.0 | ||
restart: always | ||
container_name: e2e-test-prisma | ||
ports: | ||
- '3306:3306' | ||
environment: | ||
MYSQL_ROOT_PASSWORD: root | ||
MYSQL_DATABASE: test | ||
volumes: | ||
- /var/lib/mysql | ||
command: | ||
- --character-set-server=utf8mb4 | ||
- --collation-server=utf8mb4_unicode_ci | ||
- --skip-character-set-client-handshake | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,14 @@ | |
"test:watch": "jest --watch", | ||
"test:cov": "jest --coverage", | ||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", | ||
"test:e2e": "jest --config ./test/jest-e2e.json" | ||
"test:e2e": "yarn docker:up && sleep 6.5 && yarn migrate:test && yarn seed:test && dotenv -e .env.test -- jest --config ./test/jest-e2e.json && yarn docker:down", | ||
"migrate:test": "dotenv -e .env.test -- npx prisma migrate deploy", | ||
"seed:test": "dotenv -e .env.test -- npx prisma db seed", | ||
"docker:up": "docker-compose -f docker-compose.test.yml up -d", | ||
"docker:down": "docker-compose -f docker-compose.test.yml down -v" | ||
}, | ||
"prisma": { | ||
"seed": "cross-env NODE_ENV=test ts-node prisma/seed.ts" | ||
Comment on lines
+21
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
참고) |
||
}, | ||
"dependencies": { | ||
"@nestjs/axios": "^2.0.0", | ||
|
@@ -39,6 +46,7 @@ | |
"class-validator": "^0.14.0", | ||
"dayjs": "^1.11.9", | ||
"dotenv": "^16.0.3", | ||
"dotenv-cli": "^7.2.1", | ||
"jest-mock-extended": "^3.0.4", | ||
"nanoid": "3.3.4", | ||
"passport": "^0.6.0", | ||
|
@@ -58,6 +66,7 @@ | |
"@types/supertest": "^2.0.11", | ||
"@typescript-eslint/eslint-plugin": "^5.0.0", | ||
"@typescript-eslint/parser": "^5.0.0", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^8.0.1", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,274 @@ | ||
import { PrismaClient } from '@prisma/client'; | ||
import * as dayjs from 'dayjs'; | ||
import * as utc from 'dayjs/plugin/utc'; | ||
import * as timezone from 'dayjs/plugin/timezone'; | ||
|
||
dayjs.extend(utc); | ||
dayjs.extend(timezone); | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
async function main() { | ||
const user = await prisma.user.create({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 테스트 환경을 위해 만들어진 DB 에 더미데이터 삽입을 위한 seed 파일 앞으로 테스트 로직이 추가 될 때 필요한 더미 데이터가 있다면 seed 파일을 통해 삽입하면 됩니다. |
||
data: { | ||
id: 1, | ||
email: 'ddd', | ||
createdAt: dayjs('2023-07-22 08:15:37.225Z').toDate(), | ||
fcmToken: 'dd', | ||
nickname: 'ddd', | ||
password: 'dd', | ||
phone: 'ddd', | ||
profileImageURL: 'dd', | ||
refreshToken: 'dd', | ||
socialType: 'kakao', | ||
title: 'dd', | ||
updatedAt: dayjs('2023-07-22 08:15:37.225Z').toDate(), | ||
uuid: 'dd', | ||
appleId: null, | ||
appleRefreshToken: null, | ||
kakaoId: 1, | ||
}, | ||
}); | ||
|
||
const plants = await prisma.plant.createMany({ | ||
data: [ | ||
{ | ||
id: 1, | ||
name: '오렌지 자스민', | ||
cycle: 2, | ||
introduction: '붙임성이 좋은\n앙증맞은 오렌지 자스민', | ||
meaning: '당신을 향해', | ||
explanation: | ||
'1~2일에 한 번 물을 주는 것을 추천해요\n물을 좋아하는 자스민이 곧 귀여운 열매를 선물할거에요!', | ||
circleImageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/circleImages/mindlere-circle.png', | ||
gifURL: 'aaa', | ||
}, | ||
{ | ||
id: 2, | ||
name: '로즈마리', | ||
cycle: 4, | ||
introduction: '당신의 하루를 치유하는\n향기로운 로즈마리', | ||
meaning: '기억해 주세요', | ||
explanation: | ||
'3~4일에 한 번 물을 주는 것을 추천해요\n자주 연락하고 많은 시간을 함께하며 추억을 쌓아가요!', | ||
circleImageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/circleImages/rosemari-circle.png', | ||
gifURL: 'aaa', | ||
}, | ||
{ | ||
id: 3, | ||
name: '아메리칸 블루', | ||
cycle: 6, | ||
introduction: '매일매일 꽃이 피는\n푸른 빛의 아메리칸 블루', | ||
meaning: '두 사람의 인연', | ||
explanation: | ||
'일주일에 한 번 물을 주는 것을 추천해요\n종종 안부를 물으면서 오손도손 이야기를 나누어요!', | ||
circleImageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/circleImages/americanblue-circle.png', | ||
gifURL: 'aaa', | ||
}, | ||
{ | ||
id: 4, | ||
name: '민들레', | ||
cycle: 13, | ||
introduction: '감사하는 마음을 가진\n따뜻한 민들레', | ||
meaning: '인연에서의 행복', | ||
explanation: | ||
'보름에 한 번 물을 주는 것을 추천해요\n당신의 연락이 홀씨가 되어 날아가 행복으로 피어날거에요!', | ||
circleImageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/circleImages/mindlere-circle.png', | ||
gifURL: 'ㅁㅁ', | ||
}, | ||
{ | ||
id: 5, | ||
name: '스투키', | ||
cycle: 29, | ||
introduction: '언제나 당신을 지켜주는\n든든한 스투키', | ||
meaning: '너그러움', | ||
explanation: | ||
'한달에 한 번 물을 주는 것을 추천해요\n가끔씩 연락하더라도 오래 만날 수 있길 바라요!', | ||
circleImageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/circleImages/stuki-circle.png', | ||
gifURL: 'ㅁㅁ', | ||
}, | ||
{ | ||
id: 6, | ||
name: '단모환', | ||
cycle: 90, | ||
introduction: '당신의 밤을 지켜주는\n씩씩한 단모환', | ||
meaning: '사랑과 열정', | ||
explanation: | ||
'세 달에 한 번 물을 주는 것을 추천해요\n자주 보지 못해도 분명 당신의 연락을 기다릴거에요!', | ||
circleImageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/circleImages/danmohwan-circle.png', | ||
gifURL: 'ㅁㅁㅁ', | ||
}, | ||
], | ||
skipDuplicates: true, | ||
}); | ||
|
||
const plantLevels = await prisma.plantLevel.createMany({ | ||
data: [ | ||
{ | ||
id: 1, | ||
plantId: 1, | ||
level: 0, | ||
levelName: '어린 나무', | ||
description: '무럭무럭 자랄 준비를 하고 있어요!', | ||
imageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/mindlere-1.png', | ||
}, | ||
{ | ||
id: 2, | ||
plantId: 1, | ||
level: 1, | ||
levelName: '개화', | ||
description: '하얀 꽃이 활짝 피어났어요!', | ||
imageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/mindlere-2.png', | ||
}, | ||
{ | ||
id: 3, | ||
plantId: 1, | ||
level: 2, | ||
levelName: '열매', | ||
description: '꽃이 머물다간 자리에 앙증맞은 열매가 열렸네요!', | ||
imageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/mindlere-complete.png', | ||
}, | ||
{ | ||
id: 4, | ||
plantId: 2, | ||
level: 0, | ||
levelName: '새싹', | ||
description: '새싹이 쏘옥 얼굴을 내밀었어요!', | ||
imageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/rosemari-1.png', | ||
}, | ||
{ | ||
id: 5, | ||
plantId: 2, | ||
level: 1, | ||
levelName: '꽃망울', | ||
description: '꽃망울이 방울방울 맺혔어요!', | ||
imageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/rosemari-2.png', | ||
}, | ||
{ | ||
id: 6, | ||
plantId: 2, | ||
level: 2, | ||
levelName: '개화', | ||
description: '예쁜 꽃이 활짝 피어났어요!', | ||
imageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/rosemari-complete.png', | ||
}, | ||
{ | ||
id: 7, | ||
plantId: 3, | ||
level: 0, | ||
levelName: '새싹', | ||
description: '새싹이 쏘옥 얼굴을 내밀었어요!', | ||
imageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/americanblue-1.png', | ||
}, | ||
{ | ||
id: 8, | ||
plantId: 3, | ||
level: 1, | ||
levelName: '꽃망울', | ||
description: '꽃망울이 방울방울 맺혔어요!', | ||
imageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/americanblue-2.png', | ||
}, | ||
{ | ||
id: 9, | ||
plantId: 3, | ||
level: 2, | ||
levelName: '개화', | ||
description: '예쁜 꽃이 활짝 피어났어요!', | ||
imageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/americanblue-complete.png', | ||
}, | ||
{ | ||
id: 10, | ||
plantId: 4, | ||
level: 0, | ||
levelName: '새싹', | ||
description: '새싹이 쏘옥 얼굴을 내밀었어요!', | ||
imageURL: | ||
'https://cherish-static-dev.s3.ap-northeast-2.amazonaws.com/plantLevel/mindlere-1.png', | ||
}, | ||
], | ||
skipDuplicates: true, | ||
}); | ||
|
||
const userPlant = await prisma.userPlant.create({ | ||
data: { | ||
id: 1, | ||
userId: 1, | ||
nickname: 'test', | ||
instagram: null, | ||
phone: null, | ||
waterCycle: 14, | ||
waterCount: 0, | ||
isNotified: true, | ||
loveGauge: 0, | ||
createdAt: dayjs('2023-07-22 08:16:52.538Z').toDate(), | ||
updatedAt: dayjs('2023-07-22 08:16:52.538Z').toDate(), | ||
waterTime: null, | ||
plantId: 4, | ||
}, | ||
}); | ||
|
||
const water = await prisma.water.createMany({ | ||
data: [ | ||
{ | ||
id: 1, | ||
userPlantId: 1, | ||
review: '리뷰1', | ||
wateringDate: dayjs('2023-07-22 08:55:31.799Z').toDate(), | ||
updatedAt: dayjs('2023-07-22 08:55:31.799Z').toDate(), | ||
}, | ||
{ | ||
id: 3, | ||
userPlantId: 1, | ||
review: '리뷰2', | ||
wateringDate: dayjs('2023-07-22 18:16:53Z').toDate(), | ||
updatedAt: dayjs('2023-07-22 09:16:54.635Z').toDate(), | ||
}, | ||
], | ||
skipDuplicates: true, | ||
}); | ||
|
||
const waterKeword = await prisma.waterKeyword.createMany({ | ||
data: [ | ||
{ | ||
id: 1, | ||
waterId: 4, | ||
keyword: 'keyword1', | ||
createdAt: dayjs('2023-07-22 12:20:11.257Z').toDate(), | ||
updatedAt: dayjs('2023-07-22 12:20:11.257Z').toDate(), | ||
}, | ||
{ | ||
id: 2, | ||
waterId: 4, | ||
keyword: 'keyword2', | ||
createdAt: dayjs('2023-07-22 12:20:11.257Z').toDate(), | ||
updatedAt: dayjs('2023-07-22 12:20:11.257Z').toDate(), | ||
}, | ||
], | ||
skipDuplicates: true, | ||
}); | ||
} | ||
|
||
main() | ||
.then(async () => { | ||
await prisma.$disconnect(); | ||
}) | ||
.catch(async (e) => { | ||
console.error(e); | ||
await prisma.$disconnect(); | ||
process.exit(1); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
import { SIGNIN_DESCRIPTION } from './auth'; | ||
import { PLANT_INFORMATION, PLANT_WATER_LOG } from './plants'; | ||
import { | ||
READ_PLANT_DETAIL, | ||
READ_PLANT_INFORMATION, | ||
READ_PLANT_WATER_LOG, | ||
} from './plants'; | ||
|
||
export const ERROR_DESCRIPTION = { | ||
INTERNAL_SERVER_ERROR: 'Internal Server Error', | ||
}; | ||
|
||
export { SIGNIN_DESCRIPTION, PLANT_INFORMATION, PLANT_WATER_LOG }; | ||
export { | ||
SIGNIN_DESCRIPTION, | ||
READ_PLANT_DETAIL, | ||
READ_PLANT_INFORMATION, | ||
READ_PLANT_WATER_LOG, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e2e 테스트 시 현재 사용중인 DB 에 영향이 가지 않도록 docker-compose 를 사용해 MySQL 로컬 DB 를 띄우고 격리된 환경으로 진행하기 위한 compose file 입니다.