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