Skip to content

Commit a9f9906

Browse files
authored
Merge pull request #355 from TTORANG/dev
[Deploy][조이] 배포
2 parents 771569d + 52b167b commit a9f9906

3 files changed

Lines changed: 68 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ PPTX/PDF 업로드
219219

220220
- `POST /slides/:slideId/comments` - 슬라이드 댓글 작성
221221
- `POST /videos/:videoId/comments` - 영상 타임스탬프 댓글 작성
222+
- `GET /videos/:videoId/comments/all` - 영상 전체 댓글 목록 조회 (공유 댓글 목록 조회와 동일 포맷)
222223
- `PATCH /comments/:commentId` - 댓글 수정
223224
- `DELETE /comments/:commentId` - 댓글 삭제
224225
- `POST /comments/:commentId/replies` - 대댓글 작성

src/swagger.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ const options = {
1212
},
1313
servers: [
1414
{
15-
url: "http://localhost:3000",
16-
description: "로컬 테스트 서버",
15+
url: process.env.SERVER_URL || "https://api.ttorang.com",
16+
description: "또랑 운영 서버",
1717
},
1818
{
19-
url: process.env.SERVER_URL,
20-
description: "개발용 배포 서버 (GCP)",
19+
url: "http://localhost:3000",
20+
description: "로컬 테스트 서버",
2121
},
2222
],
2323
components: {

tests/comment/comment.controller.test.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { jest } from "@jest/globals";
33
const mockCreateSlideComment = jest.fn();
44
const mockCreateVideoComment = jest.fn();
55
const mockUpdateComment = jest.fn();
6+
const mockGetAllVideoComments = jest.fn();
67

78
jest.unstable_mockModule("../../src/services/comment.service.js", () => ({
89
createSlideComment: mockCreateSlideComment,
@@ -11,12 +12,14 @@ jest.unstable_mockModule("../../src/services/comment.service.js", () => ({
1112
deleteComment: jest.fn(),
1213
getSlideComments: jest.fn(),
1314
getVideoCommentsByTimestamp: jest.fn(),
15+
getAllVideoComments: mockGetAllVideoComments,
1416
}));
1517

1618
const {
1719
postSlideComment,
1820
handleCreateVideoComment,
1921
patchComment,
22+
getAllVideoCommentsController,
2023
} = await import("../../src/controllers/comment.controller.js");
2124

2225
function createRes() {
@@ -31,6 +34,7 @@ describe("comment.controller QA cases", () => {
3134
mockCreateSlideComment.mockReset();
3235
mockCreateVideoComment.mockReset();
3336
mockUpdateComment.mockReset();
37+
mockGetAllVideoComments.mockReset();
3438
});
3539

3640
test("postSlideComment forwards error for invalid slideId", async () => {
@@ -73,4 +77,63 @@ describe("comment.controller QA cases", () => {
7377

7478
expect(next).toHaveBeenCalledWith(error);
7579
});
80+
81+
test("getAllVideoCommentsController returns share-comment-shaped payload", async () => {
82+
mockGetAllVideoComments.mockResolvedValue([
83+
{
84+
id: 1n,
85+
content: "이 부분 설명이 아주 좋네요!",
86+
userId: 12n,
87+
user: { nickName: "가넷" },
88+
targetType: "video",
89+
targetId: 456n,
90+
parentId: 2n,
91+
timestampMs: 12000,
92+
createdAt: new Date("2026-02-10T15:00:00.000Z"),
93+
},
94+
]);
95+
96+
const req = { params: { videoId: "456" }, user: { id: 12n } };
97+
const res = createRes();
98+
const next = jest.fn();
99+
100+
await getAllVideoCommentsController(req, res, next);
101+
102+
expect(mockGetAllVideoComments).toHaveBeenCalledWith({ videoId: "456" });
103+
expect(res.status).toHaveBeenCalledWith(200);
104+
expect(res.json).toHaveBeenCalledWith({
105+
resultType: "SUCCESS",
106+
error: null,
107+
success: {
108+
comments: [
109+
{
110+
commentId: "1",
111+
content: "이 부분 설명이 아주 좋네요!",
112+
userId: "12",
113+
isMine: true,
114+
writer: "가넷",
115+
targetType: "video",
116+
targetId: "456",
117+
parentId: "2",
118+
timestampMs: 12000,
119+
createdAt: new Date("2026-02-10T15:00:00.000Z"),
120+
},
121+
],
122+
},
123+
});
124+
expect(next).not.toHaveBeenCalled();
125+
});
126+
127+
test("getAllVideoCommentsController forwards service error", async () => {
128+
const error = new Error("fetch failed");
129+
mockGetAllVideoComments.mockRejectedValue(error);
130+
131+
const req = { params: { videoId: "456" }, user: { id: 12n } };
132+
const res = createRes();
133+
const next = jest.fn();
134+
135+
await getAllVideoCommentsController(req, res, next);
136+
137+
expect(next).toHaveBeenCalledWith(error);
138+
});
76139
});

0 commit comments

Comments
 (0)