diff --git a/docs/ArtifactData.md b/docs/ArtifactData.md index 0f9c5da..341d703 100644 --- a/docs/ArtifactData.md +++ b/docs/ArtifactData.md @@ -6,5 +6,4 @@ It is a form data Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**typeId** | **String** | The type id. | **artifact** | **File** | The artifact file to be uploaded. | The object should have properties name(indicate the file name) and data(a Buffer represents the file content) diff --git a/docs/Criteria.md b/docs/Criteria.md index 78eb73a..985a2e9 100644 --- a/docs/Criteria.md +++ b/docs/Criteria.md @@ -6,5 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **page** | **Integer** | The page number. | Default value is 1 **perPage** | **Integer** | The number of items to list per page. | Default value is 20 +**sortBy** | **String** | The property by which to sort the result list. | Should be one of the properties of review type. +**orderBy** | **String** | The order by which to sort. | One of [`asc`, `desc`, `ASC`, `DESC`] **name** | **String** | The name filter for review types. | **isActive** | **Boolean** | The active boolean flag filter for review types. | diff --git a/docs/Review.md b/docs/Review.md index 1dd34ce..eb67679 100644 --- a/docs/Review.md +++ b/docs/Review.md @@ -6,11 +6,13 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **String** | The review id. | **score** | **Number** | The review score. | +**legacyReviewId** | **Number** | The review id in the legacy system. | **typeId** | **String** | The review type id. | **reviewerId** | **Integer or String** | The reviewer id. | **scoreCardId** | **Integer or String** | The review's scorecard id. | **submissionId** | **String** | The submission id. | -**metadata** | **Object** | The review's metadata. | +**status** | **String** | The review's status. Can be one of `queued` and `completed`. | +**metadata** | [**ReviewMetadata**](ReviewMetadata.md) | The review's metadata. | **created** | **String** | The ISO date string of created date. | **updated** | **String** | The ISO date string of updated date. | **createdBy** | **String** | The created by user. | diff --git a/docs/ReviewData.md b/docs/ReviewData.md index 3316e01..7869bac 100644 --- a/docs/ReviewData.md +++ b/docs/ReviewData.md @@ -5,8 +5,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **score** | **Number** | The review score. | +**legacyReviewId** | **Number** | The review id in the legacy system. | **typeId** | **String** | The review type id. | **reviewerId** | **Integer or String** | The reviewer id. | **scoreCardId** | **Integer or String** | The review's scorecard id. | **submissionId** | **String** | The submission id. | -**metadata** | **Object** | The review's metadata. | +**status** | **String** | The review's status. Can be one of `queued` and `completed`. | +**metadata** | [**ReviewMetadata**](ReviewMetadata.md) | The review's metadata. | diff --git a/docs/ReviewMetadata.md b/docs/ReviewMetadata.md new file mode 100644 index 0000000..d74859b --- /dev/null +++ b/docs/ReviewMetadata.md @@ -0,0 +1,9 @@ +# Review Metadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**testType** | **String** | The review metadata type. | +**public** | **Object** | The review metadata info that is available to user roles along with admin and copilot. | +**private** | **Object** | The review metadata info that is only available to admin and copilot roles. | diff --git a/docs/ReviewsApi.md b/docs/ReviewsApi.md index 7593539..e4dd886 100644 --- a/docs/ReviewsApi.md +++ b/docs/ReviewsApi.md @@ -177,11 +177,17 @@ const submissionApiJwtMethodArgClient = submissionApi(_.pick(config, 'SUBMISSION const reqBody = { score: 89, + legacyReviewId: 1234567879, reviewerId: 'a3d891ef-4002-48fc-ae35-e8623e6bd4b9', submissionId: 'e328821a-6829-4214-b0d4-d7f7bf44dc98', scoreCardId: 30001850, typeId: '68c5a381-c8ab-48af-92a7-7a869a4ee6c3', - metadata: { abc: 'def' } + status: 'queued', + metadata: { + testType: 'provisional', + public: { abc: 123 }, + private: { xyz: 789 } + } } // Promise model @@ -383,11 +389,17 @@ const submissionApiJwtMethodArg = submissionApi(_.pick(config, 'SUBMISSION_API_U const reviewId = '8f4e8b6a-0ad2-4ff6-ab19-afeb102ff3b4' const reqBody = { score: 100, + legacyReviewId: 123456789, reviewerId: 'a3d891ef-4002-48fc-ae35-e8623e6bd4b9', submissionId: 'e328821a-6829-4214-b0d4-d7f7bf44dc98', scoreCardId: 30001850, typeId: '68c5a381-c8ab-48af-92a7-7a869a4ee6c3', - metadata: { abc: 'xyz' } + status: 'completed', + metadata: { + testType: 'provisional', + public: { abc: 123 }, + private: { xyz: 789 } + } } // Promise model @@ -460,7 +472,11 @@ const reqBody = { score: 99, reviewerId: 'a3d891ef-4002-48fc-ae35-e8623e6bd4b9', typeId: '68c5a381-c8ab-48af-92a7-7a869a4ee6c3', - metadata: { abc: 'def' } + metadata: { + testType: 'provisional', + public: { abc: 123 }, + private: { xyz: 789 } + } } // Promise model diff --git a/docs/SearchReviewSummationsCriteria.md b/docs/SearchReviewSummationsCriteria.md index ff415e9..573d848 100644 --- a/docs/SearchReviewSummationsCriteria.md +++ b/docs/SearchReviewSummationsCriteria.md @@ -6,6 +6,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **page** | **Integer** | The page number. | Default value is 1 **perPage** | **Integer** | The number of items to list per page. | Default value is 20 +**sortBy** | **String** | The property by which to sort the result list. | Should be one of the properties of review summation. +**orderBy** | **String** | The order by which to sort. | One of [`asc`, `desc`, `ASC`, `DESC`] **submissionId** | **String** | The submission id filter for review summations. | **aggregateScore** | **Number** | Theaggregate score filter for review summations. |Double **scoreCardId** | **Number or String** | The score card id filter for review summations. |GUID string in swagger but integer in implementation diff --git a/docs/SearchReviewsCriteria.md b/docs/SearchReviewsCriteria.md index 8f9eb5b..f8750be 100644 --- a/docs/SearchReviewsCriteria.md +++ b/docs/SearchReviewsCriteria.md @@ -6,8 +6,12 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **page** | **Integer** | The page number. | Default value is 1 **perPage** | **Integer** | The number of items to list per page. | Default value is 20 +**sortBy** | **String** | The property by which to sort the result list. | Should be one of the properties of review. +**orderBy** | **String** | The order by which to sort. | One of [`asc`, `desc`, `ASC`, `DESC`] **score** | **Number** | The score filter for reviews. | +**legacyReviewId** | **Number** | The filter for review id in the legacy system. | **typeId** | **String** | The review type id filter for reviews. | **reviewerId** | **Integer or String** | The reviewer id filter for reviews. | **scoreCardId** | **Integer or String** | The scorecard id filter for reviews. | **submissionId** | **String** | The submission id filter for reviews. | +**status** | **String** | The review status filter. Can be one of `queued` and `completed`. | diff --git a/docs/SearchSubmissionsCriteria.md b/docs/SearchSubmissionsCriteria.md index 1e98fc8..27e8430 100644 --- a/docs/SearchSubmissionsCriteria.md +++ b/docs/SearchSubmissionsCriteria.md @@ -6,6 +6,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **page** | **Integer** | The page number. | Default value is 1 **perPage** | **Integer** | The number of items to list per page. | Default value is 20 +**sortBy** | **String** | The property by which to sort the result list. | Should be one of the properties of submission. +**orderBy** | **String** | The order by which to sort. | One of [`asc`, `desc`, `ASC`, `DESC`] **type** | **String** | The type filter for submissions. | **url** | **String** | The url filter for submissions. | **memberId** | **Integer or String** | The member id filter for submissions. | @@ -14,10 +16,12 @@ Name | Type | Description | Notes **legacyUploadId** | **Integer or String** | The legacy upload id filter for submissions. | **submissionPhaseId** | **Integer or String** | The submission phase id filter for submissions. | **review.score** | **Number** | The review score filter for submissions. | Double +**review.legacyReviewId** | **Number** | The review legacy review id filter for submissions. | **review.typeId** | **String** | The review type id filter for submissions. | **review.reviewerId** | **String** | The reviewer id filter for submissions. | **review.scoreCardId** | **String** | The review score card id filter for submissions. | **review.submissionId** | **String** | The review submission id filter for submissions. | +**review.status** | **String** | The review status filter for submissions. | **reviewSummation.scoreCardId** | **String** | The review summation score card id filter for submissions. | **reviewSummation.submissionId** | **String** | The review summation submission id filter for submissions. | **reviewSummation.aggregateScore** | **Number** | The review summation aggregate score filter for submissions. | Double diff --git a/test/ReviewApi.test.js b/test/ReviewApi.test.js index 9574e75..73f3c29 100644 --- a/test/ReviewApi.test.js +++ b/test/ReviewApi.test.js @@ -17,6 +17,11 @@ const jwtClient = makeJwtClient(api(_.pick(userConfig, 'SUBMISSION_API_URL')), u const jwtFailClient = makeJwtClient(api(_.pick(userConfig, 'SUBMISSION_API_URL')), null) const notFoundId = 'e0a789ea-6144-4266-bfae-872f9a26e749' +const testReviewMetadata = { + testType: 'provisional', + public: { abc: 123 }, + private: { xyz: 789 } +} for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], [ userClient, userFailClient, 'User Credentials' ], @@ -50,11 +55,13 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], should.exist(res.header['x-total-pages']) for (const item of res.body) { should.exist(item.id) + should.exist(item.legacyReviewId) should.exist(item.typeId) should.exist(item.submissionId) should.exist(item.reviewerId) should.exist(item.scoreCardId) should.exist(item.score) + should.exist(item.status) } // set test data from searched reviews @@ -137,6 +144,16 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], } }) + it(`failure - search reviews with invalid legacyReviewId`, async () => { + try { + await client.searchReviews({ legacyReviewId: 'd24d4180-65aa-42ec-a945-5fd21dec0504' }) + throw new Error('should not throw error here') + } catch (err) { + should.equal(err.status, 400) + should.equal(err.response.body.message, '"legacyReviewId" must be a number') + } + }) + it(`failure - search reviews with invalid typeId`, async () => { try { await client.searchReviews({ typeId: 'abc' }) @@ -177,6 +194,16 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], } }) + it(`failure - search reviews with invalid status`, async () => { + try { + await client.searchReviews({ status: 'incorrect_status' }) + throw new Error('should not throw error here') + } catch (err) { + should.equal(err.status, 400) + should.equal(err.response.body.message, '"status" must be one of [queued, completed]') + } + }) + it(`failure - search reviews with invalid credential`, async () => { try { await failClient.searchReviews({}) @@ -241,6 +268,15 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], } }) + it(`failure - head reviews with invalid legacyReviewId`, async () => { + try { + await client.headReviews({ legacyReviewId: 'd24d4180-65aa-42ec-a945-5fd21dec0504' }) + throw new Error('should not throw error here') + } catch (err) { + should.equal(err.status, 400) + } + }) + it(`failure - head reviews with invalid typeId`, async () => { try { await client.headReviews({ typeId: 'abc' }) @@ -277,6 +313,15 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], } }) + it(`failure - head reviews with invalid status`, async () => { + try { + await client.headReviews({ status: 'incorrect_status' }) + throw new Error('should not throw error here') + } catch (err) { + should.equal(err.status, 400) + } + }) + it(`failure - head reviews with invalid credential`, async () => { try { await failClient.headReviews({}) @@ -291,20 +336,24 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], it(`Create review success`, async () => { const res = await client.createReview({ score: 88, + legacyReviewId: 123456789, typeId, reviewerId: reviewerId2, scoreCardId, submissionId: submissionId2, - metadata: { abc: 'def' } + status: 'queued', + metadata: testReviewMetadata }) createdReviewId = res.body.id should.equal(res.status, 200) should.equal(res.body.score, 88) + should.equal(res.body.legacyReviewId, 123456789) should.equal(res.body.typeId, typeId) should.equal(res.body.reviewerId, reviewerId2) should.equal(res.body.scoreCardId, scoreCardId) should.equal(res.body.submissionId, submissionId2) - should.equal(true, _.isEqual(res.body.metadata, { abc: 'def' })) + should.equal(res.body.status, 'queued') + should.equal(true, _.isEqual(res.body.metadata, testReviewMetadata)) }) it(`failure - Create review with invalid credential`, async () => { @@ -338,6 +387,23 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], } }) + it(`failure - Create review with invalid request body, invalid legacyReviewId`, async () => { + try { + await client.createReview({ + score: 80, + legacyReviewId: 'd24d4180-65aa-42ec-a945-5fd21dec0504', + typeId, + reviewerId, + scoreCardId, + submissionId + }) + throw new Error('should not throw error here') + } catch (err) { + should.equal(err.status, 400) + should.equal(err.response.body.message, '"legacyReviewId" must be a number') + } + }) + it(`failure - Create review with invalid request body, invalid typeId`, async () => { try { await client.createReview({ @@ -433,6 +499,23 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], should.equal(err.response.body.message, '"submissionId" is not allowed to be empty') } }) + + it(`failure - Create review with invalid request body, invalid status`, async () => { + try { + await client.createReview({ + score: 88, + typeId, + reviewerId, + scoreCardId, + submissionId, + status: 'incorrect_status' + }) + throw new Error('should not throw error here') + } catch (err) { + should.equal(err.status, 400) + should.equal(err.response.body.message, '"status" must be one of [queued, completed]') + } + }) }) describe('Test get review by id', () => { @@ -516,20 +599,24 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], it(`Put review by id success`, async () => { const res = await client.updateReview(createdReviewId, { score: 99, + legacyReviewId: 123456789, typeId: typeId2, reviewerId, scoreCardId: scoreCardId2, submissionId, - metadata: { aa: 12 } + status: 'completed', + metadata: testReviewMetadata }) should.equal(res.status, 200) should.equal(res.body.id, createdReviewId) should.equal(res.body.score, 99) + should.equal(res.body.legacyReviewId, 123456789) should.equal(res.body.typeId, typeId2) should.equal(res.body.reviewerId, reviewerId) should.equal(res.body.scoreCardId, scoreCardId2) should.equal(res.body.submissionId, submissionId) - should.equal(true, _.isEqual(res.body.metadata, { aa: 12 })) + should.equal(res.body.status, 'completed') + should.equal(true, _.isEqual(res.body.metadata, testReviewMetadata)) }) it(`failure - Put review with invalid credential`, async () => { @@ -579,6 +666,23 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], } }) + it(`failure - Put review by id with invalid legacyReviewId`, async () => { + try { + await client.updateReview(createdReviewId, { + score: 80, + legacyReviewId: 'd24d4180-65aa-42ec-a945-5fd21dec0504', + typeId, + reviewerId, + scoreCardId, + submissionId + }) + throw new Error('should not throw error here') + } catch (err) { + should.equal(err.status, 400) + should.equal(err.response.body.message, '"legacyReviewId" must be a number') + } + }) + it(`failure - Put review by id with invalid typeId`, async () => { try { await client.updateReview(createdReviewId, { @@ -643,6 +747,23 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], } }) + it(`failure - Put review by id with invalid status`, async () => { + try { + await client.updateReview(createdReviewId, { + score: 99, + typeId, + reviewerId, + scoreCardId, + submissionId, + status: 'incorrect_status' + }) + throw new Error('should not throw error here') + } catch (err) { + should.equal(err.status, 400) + should.equal(err.response.body.message, '"status" must be one of [queued, completed]') + } + }) + it(`failure - Put review by id not found`, async () => { try { await client.updateReview(notFoundId, { @@ -666,7 +787,7 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], score: 77, reviewerId: reviewerId2, submissionId: submissionId2, - metadata: { a: 1, b: 'c' } + metadata: testReviewMetadata }) should.equal(res.status, 200) should.equal(res.body.id, createdReviewId) @@ -675,7 +796,7 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], should.equal(res.body.reviewerId, reviewerId2) should.equal(res.body.scoreCardId, scoreCardId2) should.equal(res.body.submissionId, submissionId2) - should.equal(true, _.isEqual(res.body.metadata, { a: 1, b: 'c' })) + should.equal(true, _.isEqual(res.body.metadata, testReviewMetadata)) }) it(`Patch review by id success 2`, async () => { @@ -685,7 +806,7 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], reviewerId, scoreCardId, submissionId, - metadata: { abc: 123 } + metadata: testReviewMetadata }) should.equal(res.status, 200) should.equal(res.body.id, createdReviewId) @@ -694,7 +815,7 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], should.equal(res.body.reviewerId, reviewerId) should.equal(res.body.scoreCardId, scoreCardId) should.equal(res.body.submissionId, submissionId) - should.equal(true, _.isEqual(res.body.metadata, { abc: 123 })) + should.equal(true, _.isEqual(res.body.metadata, testReviewMetadata)) }) it(`failure - Patch review with invalid credential`, async () => { @@ -732,6 +853,18 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], } }) + it(`failure - Patch review by id with invalid legacyReviewId`, async () => { + try { + await client.patchReview(createdReviewId, { + legacyReviewId: 'd24d4180-65aa-42ec-a945-5fd21dec0504' + }) + throw new Error('should not throw error here') + } catch (err) { + should.equal(err.status, 400) + should.equal(err.response.body.message, '"legacyReviewId" must be a number') + } + }) + it(`failure - Patch review by id with invalid typeId`, async () => { try { await client.patchReview(createdReviewId, { @@ -784,6 +917,22 @@ for (const c of [ [ m2mClient, m2mFailClient, 'M2M' ], } }) + it(`failure - Patch review by id with invalid status`, async () => { + try { + await client.patchReview(createdReviewId, { + score: 99, + typeId, + reviewerId, + scoreCardId, + status: 'invalid' + }) + throw new Error('should not throw error here') + } catch (err) { + should.equal(err.status, 400) + should.equal(err.response.body.message, '"status" must be one of [queued, completed]') + } + }) + it(`failure - Patch review by id not found`, async () => { try { await client.patchReview(notFoundId, { diff --git a/test/common/routes.js b/test/common/routes.js index 4b27be7..a20923a 100644 --- a/test/common/routes.js +++ b/test/common/routes.js @@ -8,6 +8,15 @@ const Reviews = require('../data/Reviews.json') const ReviewSummations = require('../data/ReviewSummations.json') const Submissions = require('../data/Submissions.json') +joi.id = () => joi.number().integer().min(1) +joi.reviewStatus = () => joi.string().valid('queued', 'completed') +joi.sortOrder = () => joi.string().valid('asc', 'desc', 'ASC', 'DESC') +joi.reviewMetadata = () => joi.object().keys({ + testType: joi.string(), + public: joi.object(), + private: joi.object() +}) + module.exports = { '/reviewTypes': { post: { @@ -25,6 +34,8 @@ module.exports = { query: joi.object().keys({ name: joi.string(), isActive: joi.boolean(), + sortBy: joi.string(), + orderBy: joi.sortOrder(), page: joi.id(), perPage: joi.pageSize() }) @@ -72,11 +83,13 @@ module.exports = { authUser: joi.object().required(), entity: joi.object().keys({ score: joi.score().required(), + legacyReviewId: joi.id(), typeId: joi.string().uuid().required(), reviewerId: joi.alternatives().try(joi.id(), joi.string().uuid()).required(), scoreCardId: joi.alternatives().try(joi.id(), joi.string().uuid()).required(), submissionId: joi.string().uuid().required(), - metadata: joi.object() + status: joi.reviewStatus().default(td.REVIEW_STATUS_DEFAULT), + metadata: joi.reviewMetadata() }).required() } }, @@ -85,10 +98,14 @@ module.exports = { schema: { query: joi.object().keys({ score: joi.score(), + legacyReviewId: joi.id(), typeId: joi.string().uuid(), reviewerId: joi.alternatives().try(joi.id(), joi.string().uuid()), scoreCardId: joi.alternatives().try(joi.id(), joi.string().uuid()), submissionId: joi.string().uuid(), + status: joi.reviewStatus(), + sortBy: joi.string(), + orderBy: joi.sortOrder(), page: joi.id(), perPage: joi.pageSize() }) @@ -110,11 +127,13 @@ module.exports = { reviewId: joi.string().uuid().required(), entity: joi.object().keys({ score: joi.score().required(), + legacyReviewId: joi.id(), typeId: joi.string().uuid().required(), reviewerId: joi.alternatives().try(joi.id(), joi.string().uuid()).required(), scoreCardId: joi.alternatives().try(joi.id(), joi.string().uuid()).required(), submissionId: joi.string().uuid().required(), - metadata: joi.object() + status: joi.reviewStatus(), + metadata: joi.reviewMetadata() }).required() } }, @@ -125,11 +144,13 @@ module.exports = { reviewId: joi.string().uuid().required(), entity: joi.object().keys({ score: joi.score(), + legacyReviewId: joi.id(), typeId: joi.string().uuid(), reviewerId: joi.alternatives().try(joi.id(), joi.string().uuid()), scoreCardId: joi.alternatives().try(joi.id(), joi.string().uuid()), submissionId: joi.string().uuid(), - metadata: joi.object() + status: joi.reviewStatus(), + metadata: joi.reviewMetadata() }) } }, @@ -164,6 +185,8 @@ module.exports = { aggregateScore: joi.score(), isPassing: joi.boolean(), isFinal: joi.boolean(), + sortBy: joi.string(), + orderBy: joi.sortOrder(), page: joi.id(), perPage: joi.pageSize() }) @@ -243,13 +266,17 @@ module.exports = { legacySubmissionId: joi.alternatives().try(joi.id(), joi.string().uuid()), legacyUploadId: joi.alternatives().try(joi.id(), joi.string().uuid()), submissionPhaseId: joi.alternatives().try(joi.id(), joi.string().uuid()), + sortBy: joi.string(), + orderBy: joi.sortOrder(), page: joi.id(), perPage: joi.pageSize(), 'review.score': joi.score(), + 'review.legacyReviewId': joi.id(), 'review.typeId': joi.string().uuid(), 'review.reviewerId': joi.string().uuid(), 'review.scoreCardId': joi.string().uuid(), 'review.submissionId': joi.string().uuid(), + 'review.status': joi.reviewStatus(), 'reviewSummation.scoreCardId': joi.string().uuid(), 'reviewSummation.submissionId': joi.string().uuid(), 'reviewSummation.aggregateScore': joi.score(), @@ -319,9 +346,7 @@ module.exports = { schema: { files: joi.any().required(), submissionId: joi.string().guid().required(), - entity: joi.object().keys({ - typeId: joi.string().uuid().required() - }).required() + entity: joi.object() } }, get: { diff --git a/test/common/testData.js b/test/common/testData.js index 26ae021..c8eab86 100644 --- a/test/common/testData.js +++ b/test/common/testData.js @@ -33,6 +33,7 @@ const JOI_FAIL_STATUS = 400 const NOT_FOUND_STATUS = 404 const NOT_FOUND_ID = 'e0a789ea-6144-4266-bfae-872f9a26e749' const SUMMATION_NOTFOUND_ID = 'ace32387-8b33-47f1-8b01-6578b817a188' +const REVIEW_STATUS_DEFAULT = 'completed' const NotFoundError = { ReviewType: `Review type with ID = ${NOT_FOUND_ID} is not found`, Review: `Review with ID = ${NOT_FOUND_ID} is not found`, @@ -66,5 +67,6 @@ module.exports = { NOT_FOUND_STATUS, NOT_FOUND_ID, SUMMATION_NOTFOUND_ID, + REVIEW_STATUS_DEFAULT, NotFoundError } diff --git a/test/data/Reviews.json b/test/data/Reviews.json index 62d7025..8901897 100644 --- a/test/data/Reviews.json +++ b/test/data/Reviews.json @@ -2,10 +2,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0501", "score": 95.5, + "legacyReviewId": 1234567891, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0503", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0501", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -14,10 +16,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0502", "score": 92.0, + "legacyReviewId": 1234567892, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0501", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0501", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -26,10 +30,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0503", "score": 80.83, + "legacyReviewId": 1234567893, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0503", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0503", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -38,10 +44,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0504", "score": 85.62, + "legacyReviewId": 1234567894, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0503", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0502", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0503", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -50,10 +58,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0505", "score": 100, + "legacyReviewId": 1234567895, "typeId": "f28b2725-ef90-4495-af59-ceb2bd98fc10", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0503", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -62,10 +72,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0506", "score": 65.0, + "legacyReviewId": 1234567896, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0503", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0504", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -74,10 +86,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0507", "score": 68.0, + "legacyReviewId": 1234567897, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0503", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0502", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0504", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -86,10 +100,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0508", "score": 100, + "legacyReviewId": 1234567898, "typeId": "f28b2725-ef90-4495-af59-ceb2bd98fc10", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0505", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -98,10 +114,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0509", "score": 92.5, + "legacyReviewId": 1234567899, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0503", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0505", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", diff --git a/test/data/Submissions.json b/test/data/Submissions.json index 7b359ab..20bec30 100644 --- a/test/data/Submissions.json +++ b/test/data/Submissions.json @@ -9,10 +9,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0501", "score": 95.5, + "legacyReviewId": 1234567891, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0503", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0501", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -21,10 +23,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0502", "score": 92.0, + "legacyReviewId": 1234567892, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0501", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0501", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -38,12 +42,14 @@ "aggregateScore": 99.0, "scoreCardId": "a12a4180-65aa-42ec-a945-5fd21dec0587", "isPassing": true, + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "copilot", "updatedBy": "copilot" } ], + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "topcoder user", @@ -55,6 +61,7 @@ "url": "https://software.topcoder.com/review/actions/DownloadContestSubmission?uid=123457", "memberId": "b24d4180-65aa-42ec-a945-5fd21dec0502", "challengeId": "c3564180-65aa-42ec-a945-5fd21dec0502", + "status": "queued", "created": "2018-05-20T06:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "topcoder user", @@ -70,10 +77,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0503", "score": 80.83, + "legacyReviewId": 1234567893, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0503", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0503", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -82,10 +91,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0504", "score": 85.62, + "legacyReviewId": 1234567894, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0503", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0502", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0503", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -94,16 +105,19 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0505", "score": 100, + "legacyReviewId": 1234567895, "typeId": "f28b2725-ef90-4495-af59-ceb2bd98fc10", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0503", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", "updatedBy": "admin" } ], + "status": "queued", "created": "2018-05-20T07:31:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "topcoder user", @@ -119,10 +133,12 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0506", "score": 65.0, + "legacyReviewId": 1234567896, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0503", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0504", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", @@ -131,16 +147,19 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0507", "score": 68.0, + "legacyReviewId": 1234567897, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0503", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0502", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0504", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", "updatedBy": "admin" } ], + "status": "queued", "created": "2018-05-20T07:00:35.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "topcoder user", @@ -156,16 +175,19 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0508", "score": 100, + "legacyReviewId": 1234567898, "typeId": "f28b2725-ef90-4495-af59-ceb2bd98fc10", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0505", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", "updatedBy": "admin" } ], + "status": "queued", "created": "2018-05-02T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "topcoder user", @@ -181,16 +203,19 @@ { "id": "d24d4180-65aa-42ec-a945-5fd21dec0509", "score": 92.5, + "legacyReviewId": 1234567899, "typeId": "c56a4180-65aa-42ec-a945-5fd21dec0503", "reviewerId": "c23a4180-65aa-42ec-a945-5fd21dec0503", "scoreCardId": "b25a4180-65aa-42ec-a945-5fd21dec0503", "submissionId": "a12a4180-65aa-42ec-a945-5fd21dec0505", + "status": "queued", "created": "2018-05-20T07:00:30.123Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "admin", "updatedBy": "admin" } ], + "status": "queued", "created": "2018-05-20T05:20:30.145Z", "updated": "2018-06-01T07:36:28.178Z", "createdBy": "topcoder user", diff --git a/test/prepare.js b/test/prepare.js index 6e66568..22542f0 100644 --- a/test/prepare.js +++ b/test/prepare.js @@ -461,10 +461,7 @@ prepare(function (done) { const route = th.findRoute({ method: 'post', path: '/submissions/:id/artifacts' }) const joiParam = { files: _.get(parsedBody, 'files'), - submissionId: td.SUBMISSION_ID1, - entity: { - typeId: _.get(parsedBody, 'typeId') - } + submissionId: td.SUBMISSION_ID1 } if (!joiParam.files) { return [td.JOI_FAIL_STATUS, { message: 'Artifact is missing or not under attribute `artifact`' }]