Skip to content
Snippets Groups Projects
Commit 0bac02ef authored by Anca Ursachi's avatar Anca Ursachi
Browse files

fix(mergeConflicts):

parents c12ab558 e3999201
No related branches found
No related tags found
2 merge requests!110Sprint 21 Features,!92Hin 946
......@@ -180,6 +180,17 @@ const stripeFragmentByRole = ({
? recommendations.filter(r => r.userId === user.id)
: [],
}
case 'handlingEditor':
return {
...fragment,
recommendations: recommendations
? recommendations.filter(
r =>
r.submittedOn ||
r.recommendationType === 'editorRecommendation',
)
: [],
}
default:
return fragment
}
......
......@@ -88,81 +88,129 @@ describe('Authsome Helpers', () => {
expect(result.handlingEditor).toBeFalsy()
})
it('stripeFragment - reviewer should not see authors email', () => {
const { fragment } = testFixtures.fragments
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, role: 'author' })
const { authors = [] } = result
describe('stripeFragmentByRole', () => {
it('reviewer should not see authors email', () => {
const { fragment } = testFixtures.fragments
const result = ah.stripeFragmentByRole({ fragment, role: 'reviewer' })
const { authors = [] } = result
expect(authors[0].email).toBeFalsy()
})
it('other roles than reviewer should see authors emails', () => {
const { fragment } = testFixtures.fragments
const result = ah.stripeFragmentByRole({ fragment, role: 'author' })
const { authors = [] } = result
expect(authors[0].email).toBeTruthy()
})
expect(authors[0].email).toBeTruthy()
})
it('stripeFragment - reviewer should not see cover letter', () => {
const { fragment } = testFixtures.fragments
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, role: 'reviewer' })
const { recommendations } = result
expect(recommendations).toEqual([])
})
it('reviewer should not see cover letter', () => {
const { fragment } = testFixtures.fragments
const result = ah.stripeFragmentByRole({ fragment, role: 'reviewer' })
const { files = {} } = result
expect(files.coverLetter).toBeFalsy()
})
it('reviewer should not see others reviews', () => {
const { fragment } = testFixtures.fragments
const result = ah.stripeFragmentByRole({ fragment, role: 'reviewer' })
const { recommendations } = result
expect(recommendations).toEqual([])
})
it('stripeFragment - author should not see recommendations if a decision has not been made', () => {
const { fragment } = testFixtures.fragments
fragment.recommendations = [
{
comments: [
{
content: 'private',
public: false,
},
{
content: 'public',
public: true,
},
],
},
]
const { recommendations } = ah.stripeFragmentByRole({
fragment,
role: 'author',
status: 'underReview',
isLast: true,
})
expect(recommendations).toHaveLength(0)
})
it('stripeFragment - author should see reviews only if recommendation has been made and only public ones', () => {
const { fragment } = testFixtures.fragments
fragment.recommendations = [
{
comments: [
{
content: 'private',
public: false,
},
{
content: 'public',
public: true,
},
],
},
]
const result = ah.stripeFragmentByRole({
fragment,
role: 'author',
status: 'revisionRequested',
})
const publicComments = get(result, 'recommendations[0].comments')
expect(publicComments).toHaveLength(1)
it('author should not see recommendations if a decision has not been made', () => {
const { fragment } = testFixtures.fragments
fragment.recommendations = [
{
comments: [
{
content: 'private',
public: false,
},
{
content: 'public',
public: true,
},
],
},
]
const { recommendations } = ah.stripeFragmentByRole({
fragment,
role: 'author',
status: 'underReview',
isLast: true,
})
expect(recommendations).toHaveLength(0)
})
it('author should see reviews only if recommendation has been made and only public ones', () => {
const { fragment } = testFixtures.fragments
fragment.recommendations = [
{
comments: [
{
content: 'private',
public: false,
},
{
content: 'public',
public: true,
},
],
},
]
const result = ah.stripeFragmentByRole({
fragment,
role: 'author',
status: 'revisionRequested',
})
const publicComments = get(result, 'recommendations[0].comments')
expect(publicComments).toHaveLength(1)
})
it('HE should not see unsubmitted recommendations', () => {
const { fragment } = testFixtures.fragments
fragment.recommendations = [
{
comments: [
{
content: 'private',
public: false,
},
{
content: 'public',
public: true,
},
],
},
]
const { recommendations } = ah.stripeFragmentByRole({
fragment,
role: 'handlingEditor',
})
expect(recommendations).toHaveLength(0)
})
it('HE should see submitted recommendations', () => {
const { fragment } = testFixtures.fragments
fragment.recommendations = [
{
comments: [
{
content: 'private',
public: false,
},
{
content: 'public',
public: true,
},
],
submittedOn: 1122333,
},
]
const { recommendations } = ah.stripeFragmentByRole({
fragment,
role: 'handlingEditor',
})
expect(recommendations).toHaveLength(1)
})
})
it('getUsersList - should return parsed users when the user is admin', async () => {
const { admin } = testFixtures.users
const parsedUsers = await ah.getUsersList({
......
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