Skip to content
Snippets Groups Projects
Commit 7da2f4c2 authored by Sebastian Mihalache's avatar Sebastian Mihalache :hammer_pick:
Browse files

fix(mts-package): remove recommendations that have not been submitted

parent fd54980c
No related branches found
No related tags found
3 merge requests!160Update staging with master features,!156Develop,!153fix(mts-package): remove recommendations that have not been submitted
...@@ -118,6 +118,27 @@ const fragments = { ...@@ -118,6 +118,27 @@ const fragments = {
createdOn: chance.timestamp(), createdOn: chance.timestamp(),
updatedOn: chance.timestamp(), updatedOn: chance.timestamp(),
}, },
{
recommendation: 'reject',
recommendationType: 'review',
comments: [
{
content: 'This is not submitted yet',
public: true,
files: [
{
id: chance.guid(),
name: 'file.pdf',
size: chance.natural(),
},
],
},
],
id: chance.guid(),
userId: reviewer.id,
createdOn: chance.timestamp(),
updatedOn: chance.timestamp(),
},
], ],
authors: [ authors: [
{ {
......
...@@ -159,6 +159,13 @@ class Fragment { ...@@ -159,6 +159,13 @@ class Fragment {
const revAndEditorData = await Promise.all( const revAndEditorData = await Promise.all(
recommendations.map(async rec => { recommendations.map(async rec => {
if (
rec.recommendationType === configRecommendations.type.review &&
!rec.submittedOn
) {
return null
}
const user = await UserModel.find(rec.userId) const user = await UserModel.find(rec.userId)
let assignmentDate, isReviewer let assignmentDate, isReviewer
...@@ -201,7 +208,7 @@ class Fragment { ...@@ -201,7 +208,7 @@ class Fragment {
}), }),
) )
return revAndEditorData return revAndEditorData.filter(Boolean)
} }
} }
......
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0' process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
process.env.SUPPRESS_NO_CONFIG_WARNING = true process.env.SUPPRESS_NO_CONFIG_WARNING = true
const Chance = require('chance')
const config = require('config')
const { cloneDeep } = require('lodash') const { cloneDeep } = require('lodash')
const fixturesService = require('pubsweet-component-fixture-service') const fixturesService = require('pubsweet-component-fixture-service')
const Chance = require('chance')
const chance = new Chance() const chance = new Chance()
const { fixtures, Model } = fixturesService const { fixtures, Model } = fixturesService
const { Fragment } = require('../Helper') const { Fragment } = require('../Helper')
const { recommendations: configRecommendations } = config
const acceptedReviewerId = chance.guid() const acceptedReviewerId = chance.guid()
const submittedReviewerId1 = chance.guid() const submittedReviewerId1 = chance.guid()
const submittedReviewerId2 = chance.guid() const submittedReviewerId2 = chance.guid()
...@@ -240,7 +243,7 @@ describe('Fragment helper', () => { ...@@ -240,7 +243,7 @@ describe('Fragment helper', () => {
}) })
}) })
describe('getReviewersAndEditorsData', () => { describe('getReviewersAndEditorsData', () => {
it('should return an array of users (reviewers, editors) that have a connection with the fragment', async () => { it('should return an array of users (reviewers, editors) that have submitted a review', async () => {
const { collection } = testFixtures.collections const { collection } = testFixtures.collections
const { fragment } = testFixtures.fragments const { fragment } = testFixtures.fragments
const fragmentHelper = new Fragment({ fragment }) const fragmentHelper = new Fragment({ fragment })
...@@ -251,7 +254,14 @@ describe('Fragment helper', () => { ...@@ -251,7 +254,14 @@ describe('Fragment helper', () => {
}) })
expect(fragmentUsers.length).toBeGreaterThan(0) expect(fragmentUsers.length).toBeGreaterThan(0)
expect(fragmentUsers).toHaveLength(fragment.recommendations.length) const submittedRecommendations = fragment.recommendations.filter(
rec =>
rec.recommendationType === configRecommendations.type.editor ||
(rec.recommendationType === configRecommendations.type.review &&
rec.submittedOn),
)
expect(fragmentUsers).toHaveLength(submittedRecommendations.length)
}) })
it('should return an error when the collection does not have a handling editor', async () => { it('should return an error when the collection does not have a handling editor', async () => {
const { collection } = testFixtures.collections const { collection } = testFixtures.collections
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment