diff --git a/backend/apps/admin/src/problem/problem.resolver.ts b/backend/apps/admin/src/problem/problem.resolver.ts index aa08f3abed..b2d9b6d666 100644 --- a/backend/apps/admin/src/problem/problem.resolver.ts +++ b/backend/apps/admin/src/problem/problem.resolver.ts @@ -14,7 +14,6 @@ import { AuthenticatedRequest } from '@libs/auth' import { OPEN_SPACE_ID } from '@libs/constants' import { ConflictFoundException, - EntityNotExistException, ForbiddenAccessException, UnprocessableDataException } from '@libs/exception' @@ -196,7 +195,7 @@ export class ProblemResolver { @Args('workbookId', { type: () => Int }) workbookId: number ) { try { - return this.problemService.getWorkbookProblems(groupId, workbookId) + return await this.problemService.getWorkbookProblems(groupId, workbookId) } catch (error) { if ( error instanceof UnprocessableDataException || @@ -204,7 +203,7 @@ export class ProblemResolver { ) { throw error.convert2HTTPException() } else if (error.code == 'P2025') { - throw new EntityNotExistException(error.message) + throw new NotFoundException(error.message) } this.logger.error(error) throw new InternalServerErrorException(error.message) @@ -224,7 +223,7 @@ export class ProblemResolver { @Args('orders', { type: () => [Int] }, ParseArrayPipe) orders: number[] ) { try { - return this.problemService.updateWorkbookProblemsOrder( + return await this.problemService.updateWorkbookProblemsOrder( groupId, workbookId, orders @@ -236,7 +235,7 @@ export class ProblemResolver { ) { throw error.convert2HTTPException() } else if (error.code == 'P2025') { - throw new EntityNotExistException(error.message) + throw new NotFoundException(error.message) } this.logger.error(error) throw new InternalServerErrorException(error.message) @@ -254,7 +253,7 @@ export class ProblemResolver { @Args('contestId', { type: () => Int }) contestId: number ) { try { - return this.problemService.getContestProblems(groupId, contestId) + return await this.problemService.getContestProblems(groupId, contestId) } catch (error) { if ( error instanceof UnprocessableDataException || @@ -262,7 +261,7 @@ export class ProblemResolver { ) { throw error.convert2HTTPException() } else if (error.code == 'P2025') { - throw new EntityNotExistException(error.message) + throw new NotFoundException(error.message) } this.logger.error(error) throw new InternalServerErrorException(error.message) @@ -281,7 +280,7 @@ export class ProblemResolver { @Args('orders', { type: () => [Int] }, ParseArrayPipe) orders: number[] ) { try { - return this.problemService.updateContestProblemsOrder( + return await this.problemService.updateContestProblemsOrder( groupId, contestId, orders @@ -293,7 +292,7 @@ export class ProblemResolver { ) { throw error.convert2HTTPException() } else if (error.code == 'P2025') { - throw new EntityNotExistException(error.message) + throw new NotFoundException(error.message) } this.logger.error(error) throw new InternalServerErrorException(error.message) diff --git a/collection/admin/Problem/Create Problem/Succeed.bru b/collection/admin/Problem/Create Problem/Succeed.bru new file mode 100644 index 0000000000..c5f37c0fa4 --- /dev/null +++ b/collection/admin/Problem/Create Problem/Succeed.bru @@ -0,0 +1,78 @@ +meta { + name: Succeed + type: graphql + seq: 1 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation CreateProblem($groupId: Int!, $input: CreateProblemInput!) { + createProblem(groupId: $groupId, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "input": { + "title": "createdProblem", + "description": "description", + "inputDescription": "input description", + "outputDescription": "output description", + "hint": "hint", + "template": { + "language": "Cpp", + "code": [ + { + "id": 1, + "text": "int main() {}", + "locked": false + } + ] + }, + "languages": ["Cpp"], + "timeLimit": 0, + "memoryLimit": 0, + "difficulty": "Level2", + "source": "source", + "inputExamples": [], + "outputExamples": [], + "testcases": [ + { + "input": "input", + "output": "output" + } + ], + "tagIds": [1] + } + } +} + +assert { + res.body.data.createProblem: isDefined +} + +docs { + ## Create Problem + Problem을 생성합니다. + + ### Error Cases + #### UNPROCESSABLE(1) + Problem은 최소 1개 이상의 프로그래밍 언어를 지원해야 합니다. + #### UNPROCESSABLE(2) + Problem은 Template에 존재하는 프로그래밍 언어를 지원해야 합니다. +} diff --git a/collection/admin/Problem/Create Problem/UNPROCESSABLE (1).bru b/collection/admin/Problem/Create Problem/UNPROCESSABLE (1).bru new file mode 100644 index 0000000000..875fb7c5f8 --- /dev/null +++ b/collection/admin/Problem/Create Problem/UNPROCESSABLE (1).bru @@ -0,0 +1,68 @@ +meta { + name: UNPROCESSABLE (1) + type: graphql + seq: 2 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation CreateProblem($groupId: Int!, $input: CreateProblemInput!) { + createProblem(groupId: $groupId, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "input": { + "title": "createdProblem", + "description": "description", + "inputDescription": "input description", + "outputDescription": "output description", + "hint": "hint", + "template": { + "language": "Cpp", + "code": [ + { + "id": 1, + "text": "int main() {}", + "locked": false + } + ] + }, + "languages": [], + "timeLimit": 0, + "memoryLimit": 0, + "difficulty": "Level2", + "source": "source", + "inputExamples": [], + "outputExamples": [], + "testcases": [ + { + "input": "input", + "output": "output" + } + ], + "tagIds": [1] + } + } +} + +assert { + res.body.errors[0].extensions.code: eq UNPROCESSABLE + res.body.errors[0].message: eq A problem should support at least one language +} diff --git a/collection/admin/Problem/Create Problem/UNPROCESSABLE (2).bru b/collection/admin/Problem/Create Problem/UNPROCESSABLE (2).bru new file mode 100644 index 0000000000..e089b78765 --- /dev/null +++ b/collection/admin/Problem/Create Problem/UNPROCESSABLE (2).bru @@ -0,0 +1,68 @@ +meta { + name: UNPROCESSABLE (2) + type: graphql + seq: 3 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation CreateProblem($groupId: Int!, $input: CreateProblemInput!) { + createProblem(groupId: $groupId, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "input": { + "title": "createdProblem", + "description": "description", + "inputDescription": "input description", + "outputDescription": "output description", + "hint": "hint", + "template": { + "language": "Cpp", + "code": [ + { + "id": 1, + "text": "int main() {}", + "locked": false + } + ] + }, + "languages": ["Python3"], + "timeLimit": 0, + "memoryLimit": 0, + "difficulty": "Level2", + "source": "source", + "inputExamples": [], + "outputExamples": [], + "testcases": [ + { + "input": "input", + "output": "output" + } + ], + "tagIds": [1] + } + } +} + +assert { + res.body.errors[0].extensions.code: eq UNPROCESSABLE + res.body.errors[0].message: eq This problem does not support Cpp +} diff --git a/collection/admin/Problem/Delete a Problem/NOT_FOUND.bru b/collection/admin/Problem/Delete a Problem/NOT_FOUND.bru new file mode 100644 index 0000000000..ddba780171 --- /dev/null +++ b/collection/admin/Problem/Delete a Problem/NOT_FOUND.bru @@ -0,0 +1,38 @@ +meta { + name: NOT_FOUND + type: graphql + seq: 2 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation DeleteProblem($groupId: Int!, $id: Int!) { + deleteProblem(groupId: $groupId, id: $id) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 99999, + "id": 5 + } +} + +assert { + res.body.errors[0].extensions.code: eq NOT_FOUND + res.body.errors[0].message: eq No Problem found +} diff --git a/collection/admin/Problem/Delete a Problem/Succeed.bru b/collection/admin/Problem/Delete a Problem/Succeed.bru index 523228f76e..7c7d5e85dc 100644 --- a/collection/admin/Problem/Delete a Problem/Succeed.bru +++ b/collection/admin/Problem/Delete a Problem/Succeed.bru @@ -6,6 +6,41 @@ meta { post { url: {{gqlUrl}} - body: none + body: graphql auth: none } + +body:graphql { + mutation DeleteProblem($groupId: Int!, $id: Int!) { + deleteProblem(groupId: $groupId, id: $id) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "id": 5 + } +} + +assert { + res.body.data.deleteProblem: isDefined +} + +docs { + ## Delete Problem + Problem을 삭제합니다. + + ### Error Cases + #### NOT_FOUND + 존재하는 id, groupId를 사용해야 합니다. +} diff --git a/collection/admin/Problem/Get ContestProblems by ID/Error: No Contest found.bru b/collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru similarity index 73% rename from collection/admin/Problem/Get ContestProblems by ID/Error: No Contest found.bru rename to collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru index a0e9888b25..8c7cedd9ba 100644 --- a/collection/admin/Problem/Get ContestProblems by ID/Error: No Contest found.bru +++ b/collection/admin/Problem/Get Contest Problems/NOT_FOUND.bru @@ -1,5 +1,5 @@ meta { - name: Error: No Contest found + name: NOT_FOUND type: graphql seq: 2 } @@ -33,10 +33,5 @@ body:graphql:vars { assert { res.body.errors[0].message: eq No Contest found -} - -docs { - # Error: No Contest found - - - `contestId`가 `groupId`에 속하지 않으면, `No Contest found` Error를 반환합니다. + res.body.errors[0].extensions.code: eq NOT_FOUND } diff --git a/collection/admin/Problem/Get Contest Problems/Succeed.bru b/collection/admin/Problem/Get Contest Problems/Succeed.bru new file mode 100644 index 0000000000..68fa5e1ee2 --- /dev/null +++ b/collection/admin/Problem/Get Contest Problems/Succeed.bru @@ -0,0 +1,45 @@ +meta { + name: Succeed + type: graphql + seq: 1 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + query GetContestProblems($groupId: Int!, $contestId: Int!) { + getContestProblems(groupId: $groupId, contestId: $contestId) { + order + contestId + problemId + score + createTime + updateTime + } + } + +} + +body:graphql:vars { + { + "groupId": 1, + "contestId": 1 + } +} + +assert { + res.body.data.getContestProblems: isDefined +} + +docs { + ## Get Contest Problems + Contest Problem들을 가져옵니다. + + ### Error Cases + #### NOT_FOUND + 존재하는 group id와 contest id가 필요합니다. +} diff --git a/collection/admin/Problem/Get ContestProblems by ID/Succeed.bru b/collection/admin/Problem/Get ContestProblems by ID/Succeed.bru deleted file mode 100644 index 5008a6bbb8..0000000000 --- a/collection/admin/Problem/Get ContestProblems by ID/Succeed.bru +++ /dev/null @@ -1,48 +0,0 @@ -meta { - name: Succeed - type: graphql - seq: 1 -} - -post { - url: {{gqlUrl}} - body: graphql - auth: none -} - -body:graphql { - query GetContestProblems($groupId: Int!, $contestId: Int!) { - getContestProblems(groupId: $groupId, contestId: $contestId) { - order - contestId - problemId - score - createTime - updateTime - } - } - -} - -body:graphql:vars { - { - "groupId": 1, - "contestId": 1 - } -} - -assert { - res.body.data.getContestProblems[0].order: isNumber - res.body.data.getContestProblems[0].contestId: isNumber - res.body.data.getContestProblems[0].problemId: isNumber - res.body.data.getContestProblems[0].score: isNumber - res.body.data.getContestProblems[0].createTime: isString - res.body.data.getContestProblems[0].createTime: isString -} - -docs { - # Get ContestProblems by ID - - - `contestId`와 `workbookId`를 이용하여, `WorkbookProblem`들을 모두 가져 옵니다. - - `contestId`가 `groupId`에 속하지 않으면, 에러를 반환합니다. -} diff --git a/collection/admin/Problem/Get Problems/Succeed.bru b/collection/admin/Problem/Get Problems/Succeed.bru new file mode 100644 index 0000000000..13d74aa306 --- /dev/null +++ b/collection/admin/Problem/Get Problems/Succeed.bru @@ -0,0 +1,48 @@ +meta { + name: Succeed + type: graphql + seq: 1 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + query GetProblems($groupId: Int!, $cursor: Int, $take: Int!, $input: FilterProblemsInput!) { + getProblems(groupId: $groupId, cursor: $cursor, take: $take, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "cursor": 1, + "take": 10, + "input": { + "difficulty": ["Level1", "Level2", "Level3", "Level4", "Level5"], + "languages": ["C", "Cpp", "Java", "Python3"] + } + } +} + +assert { + res.body.data.getProblems: isDefined +} + +docs { + ## Get Problems + 조건에 맞는 Problem들을 가져옵니다. + 조건에 맞는 Problem이 없다면, 빈 배열을 반환합니다. +} diff --git a/collection/admin/Problem/Get WorkbookProblems by ID/Succeed.bru b/collection/admin/Problem/Get WorkbookProblems by ID/Succeed.bru deleted file mode 100644 index 525aabcd08..0000000000 --- a/collection/admin/Problem/Get WorkbookProblems by ID/Succeed.bru +++ /dev/null @@ -1,46 +0,0 @@ -meta { - name: Succeed - type: graphql - seq: 1 -} - -post { - url: {{gqlUrl}} - body: graphql - auth: none -} - -body:graphql { - query GetWorkbookProblems($groupId: Int!, $workbookId: Int!) { - getWorkbookProblems(groupId: $groupId, workbookId: $workbookId) { - order - workbookId - problemId - createTime - updateTime - } - } - -} - -body:graphql:vars { - { - "groupId": 1, - "workbookId": 1 - } -} - -assert { - res.body.data.getWorkbookProblems[0].order: isNumber - res.body.data.getWorkbookProblems[0].workbookId: isNumber - res.body.data.getWorkbookProblems[0].problemId: isNumber - res.body.data.getWorkbookProblems[0].createTime: isString - res.body.data.getWorkbookProblems[0].updateTime: isString -} - -docs { - # Get WorkbookProblems by ID - - - `groupId`와 `workbookId`를 이용하여, `WorkbookProblem`들을 모두 가져 옵니다. - - `workbookId`가 `groupId`에 속하지 않으면, 에러를 반환합니다. -} diff --git a/collection/admin/Problem/Get WorkbookProblems by ID/Error: No Workbook found.bru b/collection/admin/Problem/Get WorkbookProblems/NOT_FOUND.bru similarity index 66% rename from collection/admin/Problem/Get WorkbookProblems by ID/Error: No Workbook found.bru rename to collection/admin/Problem/Get WorkbookProblems/NOT_FOUND.bru index 1c12907334..d1994bd90c 100644 --- a/collection/admin/Problem/Get WorkbookProblems by ID/Error: No Workbook found.bru +++ b/collection/admin/Problem/Get WorkbookProblems/NOT_FOUND.bru @@ -1,5 +1,5 @@ meta { - name: Error: No Workbook found + name: NOT_FOUND type: graphql seq: 2 } @@ -25,17 +25,12 @@ body:graphql { body:graphql:vars { { - "groupId": 1, - "workbookId": 99 + "groupId": 99999, + "workbookId": 1 } } assert { + res.body.errors[0].extensions.code: eq NOT_FOUND res.body.errors[0].message: eq No Workbook found } - -docs { - # Error: No Workbook found - - - `workbookId`가 `groupId`에 속하지 않으면, `No Workbook found` Error를 반환합니다. -} diff --git a/collection/admin/Problem/Get WorkbookProblems/Succeed.bru b/collection/admin/Problem/Get WorkbookProblems/Succeed.bru new file mode 100644 index 0000000000..8f58fe9df8 --- /dev/null +++ b/collection/admin/Problem/Get WorkbookProblems/Succeed.bru @@ -0,0 +1,44 @@ +meta { + name: Succeed + type: graphql + seq: 1 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + query GetWorkbookProblems($groupId: Int!, $workbookId: Int!) { + getWorkbookProblems(groupId: $groupId, workbookId: $workbookId) { + order + workbookId + problemId + createTime + updateTime + } + } + +} + +body:graphql:vars { + { + "groupId": 1, + "workbookId": 1 + } +} + +assert { + res.body.data.getWorkbookProblems: isDefined NOT_FOUND +} + +docs { + ## Get WorkbookProblems + workbook problem들을 가져옵니다. + + ### Error Cases + #### NOT_FOUND + 존재하는 groupId 또는 workbookId를 전달해야 합니다. +} diff --git a/collection/admin/Problem/Get a Problem/NOT_FOUND.bru b/collection/admin/Problem/Get a Problem/NOT_FOUND.bru new file mode 100644 index 0000000000..d4271dce52 --- /dev/null +++ b/collection/admin/Problem/Get a Problem/NOT_FOUND.bru @@ -0,0 +1,38 @@ +meta { + name: NOT_FOUND + type: graphql + seq: 2 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + query GetProblem($groupId: Int!, $id: Int!) { + getProblem(groupId: $groupId, id: $id) { + id + groupId + inputDescription + outputDescription + languages + submissionCount + difficulty + exposeTime + } + } +} + +body:graphql:vars { + { + "groupId": 99999, + "id": 1 + } +} + +assert { + res.body.errors[0].extensions.code: eq NOT_FOUND + res.body.errors[0].message: eq No Problem found +} diff --git a/collection/admin/Problem/Get a Problem/Succeed.bru b/collection/admin/Problem/Get a Problem/Succeed.bru new file mode 100644 index 0000000000..147d6fd720 --- /dev/null +++ b/collection/admin/Problem/Get a Problem/Succeed.bru @@ -0,0 +1,46 @@ +meta { + name: Succeed + type: graphql + seq: 1 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + query GetProblem($groupId: Int!, $id: Int!) { + getProblem(groupId: $groupId, id: $id) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "id": 1 + } +} + +assert { + res.body.data.getProblem: isDefined +} + +docs { + ## Get a Problem + Problem을 가져옵니다. + + ### Error Cases + #### NOT_FOUND + 존재하지 않는 groupId 또는 id를 전달하는 경우 발생합니다. +} diff --git a/collection/admin/Problem/Update ContestProblems Order/Error: No Contest found.bru b/collection/admin/Problem/Update ContestProblems Order/NOT_FOUND.bru similarity index 76% rename from collection/admin/Problem/Update ContestProblems Order/Error: No Contest found.bru rename to collection/admin/Problem/Update ContestProblems Order/NOT_FOUND.bru index 43f62d6947..2a56432f22 100644 --- a/collection/admin/Problem/Update ContestProblems Order/Error: No Contest found.bru +++ b/collection/admin/Problem/Update ContestProblems Order/NOT_FOUND.bru @@ -1,5 +1,5 @@ meta { - name: Erro: No Contest found + name: NOT_FOUND type: graphql seq: 1 } @@ -21,7 +21,7 @@ body:graphql { updateTime } } - + } body:graphql:vars { @@ -34,10 +34,5 @@ body:graphql:vars { assert { res.body.errors[0].message: eq No Contest found -} - -docs { - # Error: No Contest found - - - `contestId`가 `groupId`에 속하지 않으면, `No Contest found` Error를 반환합니다. + res.body.errors[0].extensions.code: eq NOT_FOUND } diff --git a/collection/admin/Problem/Update ContestProblems Order/Succeed.bru b/collection/admin/Problem/Update ContestProblems Order/Succeed.bru index 49c806347d..6424a35b55 100644 --- a/collection/admin/Problem/Update ContestProblems Order/Succeed.bru +++ b/collection/admin/Problem/Update ContestProblems Order/Succeed.bru @@ -21,7 +21,7 @@ body:graphql { updateTime } } - + } body:graphql:vars { @@ -33,21 +33,19 @@ body:graphql:vars { } assert { - res.body.data.getContestProblems[0].order: isNumber - res.body.data.getContestProblems[0].contestId: isNumber - res.body.data.getContestProblems[0].problemId: isNumber - res.body.data.getContestProblems[0].score: isNumber - res.body.data.getContestProblems[0].createTime: isString - res.body.data.getContestProblems[0].createTime: isString + res.body.data.updateContestProblemsOrder: isDefined } docs { - # Update ContestProblems Order - - - `groupId`, `contestId` and `orders`가 필요합니다. - - `contestId`가 `groupId`에 속해있지 않으면 실패합니다. - - `orders`의 길이가 `contestId`에 속한 `problem`의 개수와 다르면 실패합니다. - - `orders`의 원소값은 `contestId`에 속한 `problemId`를 의미합니다. - - `orders`: [3, 4, 5, 6, 7, 8, 1, 2]와 같이 `problemId`의 순서를 변경할 수 있습니다. - - 위의 예시는 3번, 4번, 5번, 6번, 7번, 8번, 1번, 2번 `problemId` 순으로 (3번 problem이 1번 `order`, 2번 problem이 10번 `order`) `problemId`의 순서를 변경합니다. + ## Update ContestProblems order + contest problems의 정렬 순서를 변경합니다. + + order: [3, 4, 5, 6, 7, 8, 1, 2]와 같이 `problemId`의 순서를 변경할 수 있습니다. + 위의 예시는 3번, 4번, 5번, 6번, 7번, 8번, 1번, 2번 `problemId` 순으로 (3번 problem이 1번 `order`, 2번 problem이 10번 `order`) `problemId`의 순서를 변경합니다. + + ### Error Cases + #### UNPROCESSABLE + `orders`의 길이는 contest에 속한 문제들의 개수와 같아야 합니다. + #### NOT_FOUND + 존재하는 group id와 contest id가 필요합니다. } diff --git a/collection/admin/Problem/Update ContestProblems Order/Error: Length not equal.bru b/collection/admin/Problem/Update ContestProblems Order/UNPROCESSABLE.bru similarity index 72% rename from collection/admin/Problem/Update ContestProblems Order/Error: Length not equal.bru rename to collection/admin/Problem/Update ContestProblems Order/UNPROCESSABLE.bru index a0c6d21d18..ac070f4db8 100644 --- a/collection/admin/Problem/Update ContestProblems Order/Error: Length not equal.bru +++ b/collection/admin/Problem/Update ContestProblems Order/UNPROCESSABLE.bru @@ -1,5 +1,5 @@ meta { - name: Error: Length not equal + name: UNPROCESSABLE type: graphql seq: 1 } @@ -21,7 +21,7 @@ body:graphql { updateTime } } - + } body:graphql:vars { @@ -34,10 +34,5 @@ body:graphql:vars { assert { res.body.errors[0].message: eq the len of orders and the len of contestProblem are not equal. -} - -docs { - # Error: the len of orders and the len of contestProblem are not equal - - - `orders`와 `contestId`에서 긁어온 `contestProblem`의 길이가 다를 때 발생하는 에러입니다. + res.body.errors[0].extensions.code: eq UNPROCESSABLE } diff --git a/collection/admin/Problem/Update WorkbookProblems Order/Error: No Workbook found.bru b/collection/admin/Problem/Update WorkbookProblems Order/NOT_FOUND.bru similarity index 76% rename from collection/admin/Problem/Update WorkbookProblems Order/Error: No Workbook found.bru rename to collection/admin/Problem/Update WorkbookProblems Order/NOT_FOUND.bru index c99518bbf2..2be3c19001 100644 --- a/collection/admin/Problem/Update WorkbookProblems Order/Error: No Workbook found.bru +++ b/collection/admin/Problem/Update WorkbookProblems Order/NOT_FOUND.bru @@ -1,5 +1,5 @@ meta { - name: Error: No Workbook found + name: NOT_FOUND type: graphql seq: 1 } @@ -20,7 +20,7 @@ body:graphql { updateTime } } - + } body:graphql:vars { @@ -33,10 +33,5 @@ body:graphql:vars { assert { res.body.errors[0].message: eq No Workbook found -} - -docs { - # Error: No Workbook found - - - `workbookId`가 `groupId`에 속하지 않으면, `No Workbook found` Error를 반환합니다. + res.body.errors[0].extensions.code: eq NOT_FOUND } diff --git a/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru b/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru index 4ed0bd085e..a6a0e481da 100644 --- a/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru +++ b/collection/admin/Problem/Update WorkbookProblems Order/Succeed.bru @@ -20,7 +20,7 @@ body:graphql { updateTime } } - + } body:graphql:vars { @@ -32,21 +32,19 @@ body:graphql:vars { } assert { - res.body.data.getWorkbookProblems[0].order: isNumber - res.body.data.getWorkbookProblems[0].workbookId: isNumber - res.body.data.getWorkbookProblems[0].problemId: isNumber - res.body.data.getWorkbookProblems[0].createTime: isString - res.body.data.getWorkbookProblems[0].updateTime: isString + res.body.data.updateWorkbookProblemsOrder: isDefined } docs { - # Update WorkbookProblems Order - - - `groupId`, `workbookId` and `orders`가 필요합니다. - - `workbookId`가 `groupId`에 속해있지 않으면 실패합니다. - - `orders`의 길이가 `workbookId`에 속한 `problem`의 개수와 다르면 실패합니다. - - `orders`의 원소값은 `workbookId`에 속한 `problemId`를 의미합니다. - - `orders`: [3, 4, 5, 6, 7, 8, 1, 2]와 같이 `problemId`의 순서를 변경할 수 있습니다. - - 위의 예시는 3번, 4번, 5번, 6번, 7번, 8번, 1번, 2번 `problemId` 순으로 (3번 problem이 1번 `order`, 2번 problem이 10번 `order`) `problemId`의 순서를 변경합니다. - + ## Update WorkbookProblems order + workbook problems의 정렬 순서를 변경합니다. + + order: [3, 4, 5, 6, 7, 8, 1, 2]와 같이 `problemId`의 순서를 변경할 수 있습니다. + 위의 예시는 3번, 4번, 5번, 6번, 7번, 8번, 1번, 2번 `problemId` 순으로 (3번 problem이 1번 `order`, 2번 problem이 10번 `order`) `problemId`의 순서를 변경합니다. + + ### Error Cases + #### UNPROCESSABLE + `orders`의 길이는 workbook에 속한 문제들의 개수와 같아야 합니다. + #### NOT_FOUND + 존재하는 group id와 workbook id가 필요합니다. } diff --git a/collection/admin/Problem/Update WorkbookProblems Order/Error: Length not equal.bru b/collection/admin/Problem/Update WorkbookProblems Order/UNPROCESSABLE.bru similarity index 71% rename from collection/admin/Problem/Update WorkbookProblems Order/Error: Length not equal.bru rename to collection/admin/Problem/Update WorkbookProblems Order/UNPROCESSABLE.bru index faa1abc27a..ee3aa9257c 100644 --- a/collection/admin/Problem/Update WorkbookProblems Order/Error: Length not equal.bru +++ b/collection/admin/Problem/Update WorkbookProblems Order/UNPROCESSABLE.bru @@ -1,5 +1,5 @@ meta { - name: Error: Length not equal + name: UNPROCESSABLE type: graphql seq: 1 } @@ -20,7 +20,7 @@ body:graphql { updateTime } } - + } body:graphql:vars { @@ -33,10 +33,5 @@ body:graphql:vars { assert { res.body.errors[0].message: eq the len of orders and the len of workbookProblem are not equal. -} - -docs { - # Error: the len of orders and the len of workbookProblem are not equal - - - `orders`와 `workbookId`에서 긁어온 `workbookProblem`의 길이가 다를 때 발생하는 에러입니다. + res.body.errors[0].extensions.code: eq UNPROCESSABLE } diff --git a/collection/admin/Problem/Update a Problem/Succeed.bru b/collection/admin/Problem/Update a Problem/Succeed.bru new file mode 100644 index 0000000000..7e6657ad9d --- /dev/null +++ b/collection/admin/Problem/Update a Problem/Succeed.bru @@ -0,0 +1,55 @@ +meta { + name: Succeed + type: graphql + seq: 1 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation UpdateProblem($groupId: Int!, $input: UpdateProblemInput!) { + updateProblem(groupId: $groupId, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "input": { + "id": 4, + "title": "updatedProblem", + "description": "updated description", + "inputDescription": "updated input description", + "outputDescription": "updated output description", + "hint": "updated hint" + } + } +} + +assert { + res.body.data.updateProblem: isDefined +} + +docs { + ## Update Problem + Problem 정보를 수정합니다. + + ### Error Cases + #### UNPROCESSABLE(1) + 수정된 Problem은 최소 1개 이상의 프로그래밍 언어를 지원해야 합니다. + #### UNPROCESSABLE(2) + 수정된 Problem은 Template에 존재하는 프로그래밍 언어를 지원해야 합니다. +} diff --git a/collection/admin/Problem/Update a Problem/UNPROCESSABLE (1).bru b/collection/admin/Problem/Update a Problem/UNPROCESSABLE (1).bru new file mode 100644 index 0000000000..d1f645289a --- /dev/null +++ b/collection/admin/Problem/Update a Problem/UNPROCESSABLE (1).bru @@ -0,0 +1,56 @@ +meta { + name: UNPROCESSABLE (1) + type: graphql + seq: 2 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation UpdateProblem($groupId: Int!, $input: UpdateProblemInput!) { + updateProblem(groupId: $groupId, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "input": { + "id": 4, + "title": "updatedProblem", + "description": "updated description", + "inputDescription": "updated input description", + "outputDescription": "updated output description", + "hint": "updated hint", + "template": { + "language": "Cpp", + "code": [ + { + "id": 1, + "text": "int main() {}", + "locked": false + } + ] + }, + "languages": [] + } + } +} + +assert { + res.body.errors[0].extensions.code: eq UNPROCESSABLE + res.body.errors[0].message: eq A problem should support at least one language +} diff --git a/collection/admin/Problem/Update a Problem/UNPROCESSABLE (2).bru b/collection/admin/Problem/Update a Problem/UNPROCESSABLE (2).bru new file mode 100644 index 0000000000..975c4e62ee --- /dev/null +++ b/collection/admin/Problem/Update a Problem/UNPROCESSABLE (2).bru @@ -0,0 +1,56 @@ +meta { + name: UNPROCESSABLE (2) + type: graphql + seq: 3 +} + +post { + url: {{gqlUrl}} + body: graphql + auth: none +} + +body:graphql { + mutation UpdateProblem($groupId: Int!, $input: UpdateProblemInput!) { + updateProblem(groupId: $groupId, input: $input) { + id + createdById + groupId + title + description + inputDescription + outputDescription + hint + } + } +} + +body:graphql:vars { + { + "groupId": 1, + "input": { + "id": 4, + "title": "updatedProblem", + "description": "updated description", + "inputDescription": "updated input description", + "outputDescription": "updated output description", + "hint": "updated hint", + "template": { + "language": "Cpp", + "code": [ + { + "id": 1, + "text": "int main() {}", + "locked": false + } + ] + }, + "languages": ["Python3"] + } + } +} + +assert { + res.body.errors[0].extensions.code: eq UNPROCESSABLE + res.body.errors[0].message: eq This problem does not support Cpp +}