diff --git a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js index 7fc2e98e5d3812c8237e7986d28377673d4260a5..07fcac0087453c6943265160174beb18b23f95f0 100644 --- a/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js +++ b/packages/component-faraday-ui/src/manuscriptDetails/ManuscriptEicDecision.js @@ -1,5 +1,5 @@ import React from 'react' -import { get, last } from 'lodash' +import { get, initial } from 'lodash' import { compose, withProps } from 'recompose' import styled from 'styled-components' import { reduxForm } from 'redux-form' @@ -33,23 +33,23 @@ const eicDecisions = [ modalTitle: 'Publish Manuscript', modalSubtitle: 'A publish decision is final', }, - { - value: 'revision', - label: 'Request Revision', - modalTitle: 'Request Revision', - }, { value: 'reject', label: 'Reject', modalTitle: 'Reject Manuscript', modalSubtitle: 'A rejection decision is final', }, + { + value: 'revision', + label: 'Request Revision', + modalTitle: 'Request Revision', + }, ] const filterOptions = (eicDecisions, status) => { if (status === 'submitted') return eicDecisions.slice(2) - if (status === 'pendingApproval') return eicDecisions - return [last(eicDecisions)] + if (status === 'pendingApproval') return initial(eicDecisions) + return eicDecisions.slice(2, 3) } const ManuscriptEicDecision = ({ status, diff --git a/packages/component-fixture-manager/src/fixtures/collectionIDs.js b/packages/component-fixture-manager/src/fixtures/collectionIDs.js index a964c2c498c452599e68dd3457a24eac4c0a3b49..a6082362b1083a2123f8013aea6451fdb4b23023 100644 --- a/packages/component-fixture-manager/src/fixtures/collectionIDs.js +++ b/packages/component-fixture-manager/src/fixtures/collectionIDs.js @@ -4,9 +4,13 @@ const chance = new Chance() module.exports = { standardCollID: chance.guid(), - collectionReviewCompletedID: chance.guid(), collectionNoInvitesID: chance.guid(), twoVersionsCollectionId: chance.guid(), + minorRevisionCollectionID: chance.guid(), + majorRevisionCollectionID: chance.guid(), + collectionReviewCompletedID: chance.guid(), oneReviewedFragmentCollectionID: chance.guid(), noEditorRecomedationCollectionID: chance.guid(), + minorRevisionWithoutReviewCollectionID: chance.guid(), + majorRevisionWithoutReviewCollectionID: chance.guid(), } diff --git a/packages/component-fixture-manager/src/fixtures/collections.js b/packages/component-fixture-manager/src/fixtures/collections.js index 0fbff658ca84fc9266a31674461679e769a1ff13..4d92999127af2422edb3c3edd927ec744f25ea92 100644 --- a/packages/component-fixture-manager/src/fixtures/collections.js +++ b/packages/component-fixture-manager/src/fixtures/collections.js @@ -1,24 +1,35 @@ const Chance = require('chance') + const { user, handlingEditor, answerHE, noRecommendationHE, } = require('./userData') + const { fragment, fragment1, - reviewCompletedFragment, noInvitesFragment, + noInvitesFragment1, + minorRevisionWithReview, + majorRevisionWithReview, + reviewCompletedFragment, + minorRevisionWithoutReview, noEditorRecomedationFragment, } = require('./fragments') + const { standardCollID, - collectionReviewCompletedID, collectionNoInvitesID, twoVersionsCollectionId, + minorRevisionCollectionID, + majorRevisionCollectionID, + collectionReviewCompletedID, oneReviewedFragmentCollectionID, noEditorRecomedationCollectionID, + minorRevisionWithoutReviewCollectionID, + majorRevisionWithoutReviewCollectionID, } = require('./collectionIDs') const chance = new Chance() @@ -302,6 +313,152 @@ const collections = { status: 'revisionRequested', customId: chance.natural({ min: 999999, max: 9999999 }), }, + minorRevisionCollection: { + id: minorRevisionCollectionID, + delete: jest.fn(), + title: chance.sentence(), + type: 'collection', + fragments: [minorRevisionWithReview.id, noInvitesFragment1.id], + owners: [user.id], + save: jest.fn(() => collections.minorRevisionCollection), + getFragments: jest.fn(() => [minorRevisionWithReview, noInvitesFragment1]), + invitations: [ + { + id: chance.guid(), + role: 'handlingEditor', + hasAnswer: true, + isAccepted: true, + userId: handlingEditor.id, + invitedOn: chance.timestamp(), + respondedOn: null, + }, + ], + handlingEditor: { + id: handlingEditor.id, + hasAnswer: true, + isAccepted: true, + email: handlingEditor.email, + invitedOn: chance.timestamp(), + respondedOn: chance.timestamp(), + name: `${handlingEditor.firstName} ${handlingEditor.lastName}`, + }, + technicalChecks: { + token: chance.guid(), + }, + status: 'reviewCompleted', + customId: chance.natural({ min: 999999, max: 9999999 }), + }, + minorRevisionWithoutReviewCollection: { + id: minorRevisionWithoutReviewCollectionID, + delete: jest.fn(), + title: chance.sentence(), + type: 'collection', + fragments: [minorRevisionWithoutReview.id, noInvitesFragment1.id], + owners: [user.id], + save: jest.fn(() => collections.minorRevisionWithoutReviewCollection), + getFragments: jest.fn(() => [ + minorRevisionWithoutReview, + noInvitesFragment1, + ]), + invitations: [ + { + id: chance.guid(), + role: 'handlingEditor', + hasAnswer: true, + isAccepted: true, + userId: handlingEditor.id, + invitedOn: chance.timestamp(), + respondedOn: null, + }, + ], + handlingEditor: { + id: handlingEditor.id, + hasAnswer: true, + isAccepted: true, + email: handlingEditor.email, + invitedOn: chance.timestamp(), + respondedOn: chance.timestamp(), + name: `${handlingEditor.firstName} ${handlingEditor.lastName}`, + }, + technicalChecks: { + token: chance.guid(), + }, + status: 'reviewCompleted', + customId: chance.natural({ min: 999999, max: 9999999 }), + }, + majorRevisionCollection: { + id: majorRevisionCollectionID, + delete: jest.fn(), + title: chance.sentence(), + type: 'collection', + fragments: [majorRevisionWithReview.id, reviewCompletedFragment.id], + owners: [user.id], + save: jest.fn(() => collections.minorRevisionCollection), + getFragments: jest.fn(() => [ + majorRevisionWithReview, + reviewCompletedFragment, + ]), + invitations: [ + { + id: chance.guid(), + role: 'handlingEditor', + hasAnswer: true, + isAccepted: true, + userId: handlingEditor.id, + invitedOn: chance.timestamp(), + respondedOn: null, + }, + ], + handlingEditor: { + id: handlingEditor.id, + hasAnswer: true, + isAccepted: true, + email: handlingEditor.email, + invitedOn: chance.timestamp(), + respondedOn: chance.timestamp(), + name: `${handlingEditor.firstName} ${handlingEditor.lastName}`, + }, + technicalChecks: { + token: chance.guid(), + }, + status: 'reviewCompleted', + customId: chance.natural({ min: 999999, max: 9999999 }), + }, + majorRevisionWithoutReviewCollection: { + id: majorRevisionWithoutReviewCollectionID, + delete: jest.fn(), + title: chance.sentence(), + type: 'collection', + fragments: [majorRevisionWithReview.id, noInvitesFragment1.id], + owners: [user.id], + save: jest.fn(() => collections.majorRevisionWithoutReviewCollection), + getFragments: jest.fn(() => [majorRevisionWithReview, noInvitesFragment1]), + invitations: [ + { + id: chance.guid(), + role: 'handlingEditor', + hasAnswer: true, + isAccepted: true, + userId: handlingEditor.id, + invitedOn: chance.timestamp(), + respondedOn: null, + }, + ], + handlingEditor: { + id: handlingEditor.id, + hasAnswer: true, + isAccepted: true, + email: handlingEditor.email, + invitedOn: chance.timestamp(), + respondedOn: chance.timestamp(), + name: `${handlingEditor.firstName} ${handlingEditor.lastName}`, + }, + technicalChecks: { + token: chance.guid(), + }, + status: 'reviewCompleted', + customId: chance.natural({ min: 999999, max: 9999999 }), + }, } module.exports = collections diff --git a/packages/component-fixture-manager/src/fixtures/teamIDs.js b/packages/component-fixture-manager/src/fixtures/teamIDs.js index 162cdb391585ed6789018579dbb1469271f8d2f2..1de0429354609073c2809e77c3f470ccc8094562 100644 --- a/packages/component-fixture-manager/src/fixtures/teamIDs.js +++ b/packages/component-fixture-manager/src/fixtures/teamIDs.js @@ -5,9 +5,10 @@ const chance = new Chance() module.exports = { heTeamID: chance.guid(), revTeamID: chance.guid(), + rev1TeamID: chance.guid(), authorTeamID: chance.guid(), + majorRevisionHeTeamID: chance.guid(), revRecommendationTeamID: chance.guid(), - rev1TeamID: chance.guid(), heNoRecommendationTeamID: chance.guid(), revNoEditorRecommendationTeamID: chance.guid(), } diff --git a/packages/component-fixture-manager/src/fixtures/teams.js b/packages/component-fixture-manager/src/fixtures/teams.js index dbd51a4aca783c1315e45fe3749b7c2bd1f8145c..79b650069ccefcad84384488bc42b4294186fde9 100644 --- a/packages/component-fixture-manager/src/fixtures/teams.js +++ b/packages/component-fixture-manager/src/fixtures/teams.js @@ -5,21 +5,28 @@ const fragments = require('./fragments') const { heTeamID, revTeamID, + rev1TeamID, authorTeamID, + majorRevisionHeTeamID, revRecommendationTeamID, - rev1TeamID, heNoRecommendationTeamID, revNoEditorRecommendationTeamID, } = require('./teamIDs') const { submittingAuthor } = require('./userData') -const { collection, noEditorRecomedationCollection } = collections +const { + collection, + majorRevisionCollection, + noEditorRecomedationCollection, +} = collections + const { fragment, - reviewCompletedFragment, fragment1, + reviewCompletedFragment, noEditorRecomedationFragment, } = fragments + const { handlingEditor, reviewer, @@ -148,5 +155,22 @@ const teams = { updateProperties: jest.fn(() => teams.revNoEditorRecommendationTeam), id: revNoEditorRecommendationTeamID, }, + majorRevisionHeTeam: { + teamType: { + name: 'handlingEditor', + permissions: 'handlingEditor', + }, + group: 'handlingEditor', + name: 'HandlingEditor', + object: { + type: 'collection', + id: majorRevisionCollection.id, + }, + members: [handlingEditor.id], + save: jest.fn(() => teams.majorRevisionHeTeam), + delete: jest.fn(), + updateProperties: jest.fn(() => teams.majorRevisionHeTeam), + id: majorRevisionHeTeamID, + }, } module.exports = teams diff --git a/packages/component-fixture-manager/src/fixtures/users.js b/packages/component-fixture-manager/src/fixtures/users.js index 0ec653aab24e414415d7a11904367c2fdf94ede3..2b03c59776ada663e00e2a9ac58f8c73a4060db7 100644 --- a/packages/component-fixture-manager/src/fixtures/users.js +++ b/packages/component-fixture-manager/src/fixtures/users.js @@ -5,9 +5,10 @@ const chance = new Chance() const { heTeamID, revTeamID, + rev1TeamID, authorTeamID, + majorRevisionHeTeamID, revRecommendationTeamID, - rev1TeamID, heNoRecommendationTeamID, revNoEditorRecommendationTeamID, } = require('./teamIDs') @@ -24,7 +25,7 @@ users = keys.reduce((obj, item) => { teams = [heTeamID] break case 'handlingEditor': - teams = [heTeamID] + teams = [heTeamID, majorRevisionHeTeamID] break case 'noRecommendationHE': teams = [heNoRecommendationTeamID] diff --git a/packages/component-helper-service/src/services/Collection.js b/packages/component-helper-service/src/services/Collection.js index ece6c1339e26542a0509c2f0606ded4b2f7e92e4..e95d5e8666a94464384fac61f693d199fe3c154b 100644 --- a/packages/component-helper-service/src/services/Collection.js +++ b/packages/component-helper-service/src/services/Collection.js @@ -93,7 +93,8 @@ class Collection { const allCollectionInvitations = flatMap( allCollectionFragments, fragment => fragment.invitations, - ) + ).filter(Boolean) + const allNumberedInvitationsForUser = allCollectionInvitations .filter(invite => invite.userId === userId) .filter(invite => invite.reviewerNumber) @@ -134,7 +135,9 @@ class Collection { if (lastEditorRecommendation.recommendation === 'minor') { return this.hasAtLeastOneReviewReport(fragments) - } else if (lastEditorRecommendation.recommendation === 'major') { + } else if ( + ['major', 'revision'].includes(lastEditorRecommendation.recommendation) + ) { return fragmentHelper.hasReviewReport() } diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/strategies/hePublish.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/strategies/hePublish.js index 238efbc141b40fda46e5c048afb3e9031a8213fb..bbbe74cae92f7fdbb0c82d76906163eca09cf771 100644 --- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/strategies/hePublish.js +++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/strategies/hePublish.js @@ -7,7 +7,7 @@ module.exports = { newRecommendation, }) => { const fragments = await collectionHelper.collection.getFragments() - + // console.log('FRAGs', fragments) if (!collectionHelper.canHEMakeRecommendation(fragments, fragmentHelper)) { throw new Error('Cannot publish without at least one reviewer report.') } diff --git a/packages/component-manuscript-manager/src/tests/collections/get.test.js b/packages/component-manuscript-manager/src/tests/collections/get.test.js index 28c027fd4e5d103a9347bc9640a8344a14499071..7ad0c1284762c4173c9b7e948fb2d273233eb166 100644 --- a/packages/component-manuscript-manager/src/tests/collections/get.test.js +++ b/packages/component-manuscript-manager/src/tests/collections/get.test.js @@ -36,7 +36,7 @@ describe('Get collections route handler', () => { expect(res.statusCode).toBe(200) const data = JSON.parse(res._getData()) - expect(data).toHaveLength(1) + expect(data).toHaveLength(handlingEditor.teams.length) expect(data[0].type).toEqual('collection') expect(data[0]).toHaveProperty('currentVersion') expect(data[0]).toHaveProperty('visibleStatus') diff --git a/packages/component-manuscript-manager/src/tests/fragmentsRecommendations/post.test.js b/packages/component-manuscript-manager/src/tests/fragmentsRecommendations/post.test.js index 48138e455a6faa71295bce04c944903c7fb9b9c7..409e5238ef0062715a53031633e33413f27dcbf5 100644 --- a/packages/component-manuscript-manager/src/tests/fragmentsRecommendations/post.test.js +++ b/packages/component-manuscript-manager/src/tests/fragmentsRecommendations/post.test.js @@ -130,52 +130,45 @@ describe('Post fragments recommendations route handler', () => { }) it('should return success when creating a recommendation as a HE after minor revision and we have at least one review on collection.', async () => { - const { handlingEditor } = testFixtures.users - const { collection } = testFixtures.collections + const { handlingEditor: { id: userId } } = testFixtures.users const { - minorRevisionWithReview, - noInvitesFragment1, - } = testFixtures.fragments + minorRevisionCollection: { id: collectionId }, + } = testFixtures.collections + const { noInvitesFragment1: { id: fragmentId } } = testFixtures.fragments - collection.fragments = [minorRevisionWithReview.id, noInvitesFragment1.id] const res = await requests.sendRequest({ body, - userId: handlingEditor.id, + userId, models, route, path, params: { - collectionId: collection.id, - fragmentId: noInvitesFragment1.id, + collectionId, + fragmentId, }, }) expect(res.statusCode).toBe(200) const data = JSON.parse(res._getData()) - expect(data.userId).toEqual(handlingEditor.id) + expect(data.userId).toEqual(userId) }) it('should return error when creating a recommendation as a HE after minor revision and there are no reviews.', async () => { - const { handlingEditor } = testFixtures.users - const { collection } = testFixtures.collections + const { handlingEditor: { id: userId } } = testFixtures.users const { - minorRevisionWithoutReview, - noInvitesFragment1, - } = testFixtures.fragments - - collection.fragments = [ - minorRevisionWithoutReview.id, - noInvitesFragment1.id, - ] + minorRevisionWithoutReviewCollection: { id: collectionId }, + } = testFixtures.collections + const { noInvitesFragment1: { id: fragmentId } } = testFixtures.fragments + const res = await requests.sendRequest({ body, - userId: handlingEditor.id, + userId, models, route, path, params: { - collectionId: collection.id, - fragmentId: noInvitesFragment1.id, + collectionId, + fragmentId, }, }) @@ -187,53 +180,46 @@ describe('Post fragments recommendations route handler', () => { }) it('should return success when creating a recommendation as a HE after major revision and there are least one review on fragment.', async () => { - const { handlingEditor } = testFixtures.users - const { collection } = testFixtures.collections + const { handlingEditor: { id: userId } } = testFixtures.users const { - majorRevisionWithReview, - reviewCompletedFragment, - } = testFixtures.fragments - - reviewCompletedFragment.collectionId = collection.id - collection.fragments = [ - majorRevisionWithReview.id, - reviewCompletedFragment.id, - ] + majorRevisionCollection: { id: collectionId }, + } = testFixtures.collections + const { reviewCompletedFragment } = testFixtures.fragments + + reviewCompletedFragment.collectionId = collectionId const res = await requests.sendRequest({ body, - userId: handlingEditor.id, + userId, models, route, path, params: { - collectionId: collection.id, + collectionId, fragmentId: reviewCompletedFragment.id, }, }) expect(res.statusCode).toBe(200) const data = JSON.parse(res._getData()) - expect(data.userId).toEqual(handlingEditor.id) + expect(data.userId).toEqual(userId) }) it('should return error when creating a recommendation as a HE after major revision there are no reviews on fragment.', async () => { - const { handlingEditor } = testFixtures.users - const { collection } = testFixtures.collections + const { handlingEditor: { id: userId } } = testFixtures.users const { - majorRevisionWithReview, - noInvitesFragment1, - } = testFixtures.fragments + majorRevisionWithoutReviewCollection: { id: collectionId }, + } = testFixtures.collections + const { noInvitesFragment1: { id: fragmentId } } = testFixtures.fragments - collection.fragments = [majorRevisionWithReview.id, noInvitesFragment1.id] const res = await requests.sendRequest({ body, - userId: handlingEditor.id, + userId, models, route, path, params: { - collectionId: collection.id, - fragmentId: noInvitesFragment1.id, + collectionId, + fragmentId, }, }) diff --git a/packages/component-mts-package/src/MTS.js b/packages/component-mts-package/src/MTS.js index 3f9e503df78bbf5d3273f0e7e19dd4d3c764b1e1..4b9cdadfcd4ce88fcebde24378b9b5ab6c527a7d 100644 --- a/packages/component-mts-package/src/MTS.js +++ b/packages/component-mts-package/src/MTS.js @@ -38,17 +38,21 @@ module.exports = { fragment, xmlFile, isEQA, - }).then(() => { - const packageName = get(xmlFile, 'name', '').replace('.xml', '') - const filename = isEQA - ? `ACCEPTED_${packageName}.${fragment.version}.zip` - : `${packageName}.zip` + }) + .then(() => { + const packageName = get(xmlFile, 'name', '').replace('.xml', '') + const filename = isEQA + ? `ACCEPTED_${packageName}.${fragment.version}.zip` + : `${packageName}.zip` - return PackageManager.uploadFiles({ - filename, - s3Config, - config: ftpConfig, + return PackageManager.uploadFiles({ + filename, + s3Config, + config: ftpConfig, + }) + }) + .catch(e => { + throw new Error(e) }) - }) }, } diff --git a/packages/xpub-faraday/tests/config/authsome-helpers.test.js b/packages/xpub-faraday/tests/config/authsome-helpers.test.js index 41fa760afb11a7bb0cb7896549aa19151e3ce79a..10571579af13e2834aa58b9ca6a4f7fe72971397 100644 --- a/packages/xpub-faraday/tests/config/authsome-helpers.test.js +++ b/packages/xpub-faraday/tests/config/authsome-helpers.test.js @@ -167,7 +167,7 @@ describe('Authsome Helpers', () => { user: answerReviewer, }) const { recommendations } = result - expect(recommendations).toHaveLength(7) + expect(recommendations).toHaveLength(8) }) it('reviewer should not see other reviewers recommendations on latest fragment', () => { @@ -181,7 +181,7 @@ describe('Authsome Helpers', () => { user: answerReviewer, }) const { recommendations } = result - expect(recommendations).toHaveLength(6) + expect(recommendations).toHaveLength(7) }) it('reviewer should not see any reviewer recommendation on previous version if he did not submit a review on that fragment', () => {