diff --git a/packages/component-fixture-manager/src/fixtures/fragments.js b/packages/component-fixture-manager/src/fixtures/fragments.js index 3f149caf0e0a148bf47b04fae1076dd58323e36d..c8931dd9bb71a0259f0817a5a0a448ea53e37e42 100644 --- a/packages/component-fixture-manager/src/fixtures/fragments.js +++ b/packages/component-fixture-manager/src/fixtures/fragments.js @@ -46,6 +46,28 @@ const fragments = { updatedOn: chance.timestamp(), submittedOn: chance.timestamp(), }, + { + recommendation: 'reject', + recommendationType: 'review', + comments: [ + { + content: chance.paragraph(), + public: chance.bool(), + files: [ + { + id: chance.guid(), + name: 'file.pdf', + size: chance.natural(), + }, + ], + }, + ], + id: chance.guid(), + userId: '1231njfsdknfkjs23', + createdOn: chance.timestamp(), + updatedOn: chance.timestamp(), + submittedOn: chance.timestamp(), + }, { recommendation: 'minor', recommendationType: 'editorRecommendation', 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 0862779b60d66f4d415632ce421f90fda6290010..6ee20a4684bf3b12a882a095ffa0bda64225095e 100644 --- a/packages/component-manuscript-manager/src/tests/collections/get.test.js +++ b/packages/component-manuscript-manager/src/tests/collections/get.test.js @@ -24,6 +24,7 @@ describe('Get collections route handler', () => { it('should return collections with the latest fragments if the request user is HE', async () => { const { handlingEditor } = testFixtures.users + const { recommendations } = testFixtures.fragments.fragment const res = await requests.sendRequest({ userId: handlingEditor.id, @@ -40,7 +41,9 @@ describe('Get collections route handler', () => { expect(data[0]).toHaveProperty('currentVersion') expect(data[0]).toHaveProperty('visibleStatus') expect(data[0].currentVersion.type).toEqual('fragment') - expect(data[0].currentVersion.recommendations).toHaveLength(3) + expect(data[0].currentVersion.recommendations).toHaveLength( + recommendations.length, + ) }) it('should return collections with the latest fragments if the request user is reviewer', async () => { @@ -58,7 +61,7 @@ describe('Get collections route handler', () => { expect(data).toHaveLength(2) expect(data[0].type).toEqual('collection') - expect(data[0].currentVersion.recommendations).toHaveLength(1) + expect(data[0].currentVersion.recommendations).toHaveLength(3) expect(data[0].currentVersion.authors[0]).not.toHaveProperty('email') }) @@ -77,6 +80,7 @@ describe('Get collections route handler', () => { it('should return all collections with the latest fragments if the request user is admin/EiC', async () => { const { editorInChief } = testFixtures.users + const { recommendations } = testFixtures.fragments.fragment const res = await requests.sendRequest({ userId: editorInChief.id, @@ -91,6 +95,8 @@ describe('Get collections route handler', () => { expect(data).toHaveLength(size(testFixtures.collections)) expect(data[0].type).toEqual('collection') expect(data[0]).toHaveProperty('visibleStatus') - expect(data[0].currentVersion.recommendations).toHaveLength(3) + expect(data[0].currentVersion.recommendations).toHaveLength( + recommendations.length, + ) }) }) diff --git a/packages/xpub-faraday/config/authsome-helpers.js b/packages/xpub-faraday/config/authsome-helpers.js index a8518a054f7f6417e57613c3d7507594f1159059..c962ebd7c50c2c70c4a60e310368f00e089682c2 100644 --- a/packages/xpub-faraday/config/authsome-helpers.js +++ b/packages/xpub-faraday/config/authsome-helpers.js @@ -178,11 +178,16 @@ const stripeFragmentByRole = ({ files: omit(files, ['coverLetter']), authors: authors.map(a => omit(a, ['email'])), recommendations: recommendations - ? recommendations.filter( - r => - r.userId === user.id || - r.recommendationType === 'editorRecommendation', - ) + ? recommendations + .filter( + r => + r.userId === user.id || + r.recommendationType === 'editorRecommendation', + ) + .map(r => ({ + ...r, + comments: r.comments.filter(c => c.public === true), + })) : [], } case 'handlingEditor': diff --git a/packages/xpub-faraday/tests/config/authsome-helpers.test.js b/packages/xpub-faraday/tests/config/authsome-helpers.test.js index 606bb666465c1455e78ce9cc9bb3cfb56cadfddb..cd0da494190d265741454051629aa195bc00e675 100644 --- a/packages/xpub-faraday/tests/config/authsome-helpers.test.js +++ b/packages/xpub-faraday/tests/config/authsome-helpers.test.js @@ -119,7 +119,7 @@ describe('Authsome Helpers', () => { const { fragment } = testFixtures.fragments const result = ah.stripeFragmentByRole({ fragment, role: 'reviewer' }) const { recommendations } = result - expect(recommendations).toEqual([]) + expect(recommendations).toHaveLength(2) }) it('author should not see recommendations if a decision has not been made', () => {