Skip to content
Snippets Groups Projects
Commit 625b20c8 authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

Merge branch 'develop' of gitlab.coko.foundation:xpub/xpub-faraday into develop

parents 12f173bb b4b3de30
No related branches found
No related tags found
1 merge request!13Sprint #14
...@@ -142,7 +142,7 @@ const stripeCollectionByRole = (coll = {}, role = '') => { ...@@ -142,7 +142,7 @@ const stripeCollectionByRole = (coll = {}, role = '') => {
const { handlingEditor } = coll const { handlingEditor } = coll
if (!authorAllowedStatuses.includes(coll.status)) { if (!authorAllowedStatuses.includes(coll.status)) {
coll = { return {
...coll, ...coll,
handlingEditor: handlingEditor && handlingEditor: handlingEditor &&
handlingEditor.isAccepted && { handlingEditor.isAccepted && {
...@@ -155,12 +155,12 @@ const stripeCollectionByRole = (coll = {}, role = '') => { ...@@ -155,12 +155,12 @@ const stripeCollectionByRole = (coll = {}, role = '') => {
return coll return coll
} }
const stripeFragmentByRole = ( const stripeFragmentByRole = ({
fragment = {}, fragment = {},
role = '', role = '',
status = '', status = 'draft',
user = {}, user = {},
) => { }) => {
const { recommendations, files, authors } = fragment const { recommendations, files, authors } = fragment
switch (role) { switch (role) {
case 'author': case 'author':
......
...@@ -137,7 +137,12 @@ async function applyAuthenticatedUserPolicy(user, operation, object, context) { ...@@ -137,7 +137,12 @@ async function applyAuthenticatedUserPolicy(user, operation, object, context) {
return { return {
filter: fragment => filter: fragment =>
helpers.stripeFragmentByRole(fragment, permission.role, status, user), helpers.stripeFragmentByRole({
fragment,
role: permission.role,
status,
user,
}),
} }
} }
......
...@@ -14,7 +14,7 @@ describe('Authsome Helpers', () => { ...@@ -14,7 +14,7 @@ describe('Authsome Helpers', () => {
}) })
it('stripeFragment - should return fragment', () => { it('stripeFragment - should return fragment', () => {
const { fragment } = testFixtures.fragments const { fragment } = testFixtures.fragments
const result = ah.stripeFragmentByRole(fragment) const result = ah.stripeFragmentByRole({ fragment })
expect(result).toBeTruthy() expect(result).toBeTruthy()
}) })
...@@ -88,13 +88,13 @@ describe('Authsome Helpers', () => { ...@@ -88,13 +88,13 @@ describe('Authsome Helpers', () => {
it('stripeFragment - reviewer should not see authors email', () => { it('stripeFragment - reviewer should not see authors email', () => {
const { fragment } = testFixtures.fragments const { fragment } = testFixtures.fragments
const result = ah.stripeFragmentByRole(fragment, 'reviewer') const result = ah.stripeFragmentByRole({ fragment, role: 'reviewer' })
const { authors = [] } = result const { authors = [] } = result
expect(authors[0].email).toBeFalsy() expect(authors[0].email).toBeFalsy()
}) })
it('stripeFragment - other roles than reviewer should see authors emails', () => { it('stripeFragment - other roles than reviewer should see authors emails', () => {
const { fragment } = testFixtures.fragments const { fragment } = testFixtures.fragments
const result = ah.stripeFragmentByRole(fragment, 'author') const result = ah.stripeFragmentByRole({ fragment, role: 'author' })
const { authors = [] } = result const { authors = [] } = result
expect(authors[0].email).toBeTruthy() expect(authors[0].email).toBeTruthy()
...@@ -102,13 +102,13 @@ describe('Authsome Helpers', () => { ...@@ -102,13 +102,13 @@ describe('Authsome Helpers', () => {
it('stripeFragment - reviewer should not see cover letter', () => { it('stripeFragment - reviewer should not see cover letter', () => {
const { fragment } = testFixtures.fragments const { fragment } = testFixtures.fragments
const result = ah.stripeFragmentByRole(fragment, 'reviewer') const result = ah.stripeFragmentByRole({ fragment, role: 'reviewer' })
const { files = {} } = result const { files = {} } = result
expect(files.coverLetter).toBeFalsy() expect(files.coverLetter).toBeFalsy()
}) })
it('stripeFragment - reviewer should not see others reviews', () => { it('stripeFragment - reviewer should not see others reviews', () => {
const { fragment } = testFixtures.fragments const { fragment } = testFixtures.fragments
const result = ah.stripeFragmentByRole(fragment, 'reviewer') const result = ah.stripeFragmentByRole({ fragment, role: 'reviewer' })
const { recommendations } = result const { recommendations } = result
expect(recommendations).toEqual([]) expect(recommendations).toEqual([])
}) })
...@@ -129,14 +129,14 @@ describe('Authsome Helpers', () => { ...@@ -129,14 +129,14 @@ describe('Authsome Helpers', () => {
], ],
}, },
] ]
const { recommendations } = ah.stripeFragmentByRole( const { recommendations } = ah.stripeFragmentByRole({
fragment, fragment,
'author', role: 'author',
'underReview', status: 'underReview',
) })
expect(recommendations).toHaveLength(0) expect(recommendations).toHaveLength(0)
}) })
it('stripeFragment - author should see reviews only if recommendation has been made', () => { it('stripeFragment - author should see reviews only if recommendation has been made and only public ones', () => {
const { fragment } = testFixtures.fragments const { fragment } = testFixtures.fragments
fragment.recommendations = [ fragment.recommendations = [
{ {
...@@ -152,12 +152,12 @@ describe('Authsome Helpers', () => { ...@@ -152,12 +152,12 @@ describe('Authsome Helpers', () => {
], ],
}, },
] ]
const result = ah.stripeFragmentByRole( const result = ah.stripeFragmentByRole({
fragment, fragment,
'author', role: 'author',
'revisionRequested', status: 'revisionRequested',
) })
const privateComments = get(result, 'recommendations[0].comments') const publicComments = get(result, 'recommendations[0].comments')
expect(privateComments).toHaveLength(1) expect(publicComments).toHaveLength(1)
}) })
}) })
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