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

test(component-fixture-manager): Add tests for submitting a he recommendation...

test(component-fixture-manager): Add tests for submitting a he recommendation on first version or af
parent 31396ef0
No related branches found
No related tags found
3 merge requests!162Sprint 23 Features,!161Deploy S23 features and fixes,!155Hin 1130
...@@ -423,5 +423,143 @@ fragments.noInvitesFragment = { ...@@ -423,5 +423,143 @@ fragments.noInvitesFragment = {
invites: [], invites: [],
id: chance.guid(), id: chance.guid(),
} }
fragments.noInvitesFragment = {
...fragments.fragment1,
recommendations: [],
invites: [],
id: chance.guid(),
}
fragments.noInvitesFragment1 = {
...fragments.fragment,
recommendations: [],
invites: [],
id: chance.guid(),
}
fragments.minorRevisionWithoutReview = {
...fragments.fragment,
recommendations: [
{
recommendation: 'minor',
recommendationType: 'editorRecommendation',
comments: [
{
content: chance.paragraph(),
public: true,
files: [
{
id: chance.guid(),
name: 'file.pdf',
size: chance.natural(),
},
],
},
],
id: chance.guid(),
userId: handlingEditor.id,
createdOn: chance.timestamp(),
updatedOn: chance.timestamp(),
},
],
id: chance.guid(),
}
fragments.minorRevisionWithReview = {
...fragments.fragment,
recommendations: [
{
recommendation: 'minor',
recommendationType: 'editorRecommendation',
comments: [
{
content: chance.paragraph(),
public: true,
files: [
{
id: chance.guid(),
name: 'file.pdf',
size: chance.natural(),
},
],
},
],
id: chance.guid(),
userId: handlingEditor.id,
createdOn: chance.timestamp(),
updatedOn: chance.timestamp(),
},
{
recommendation: 'publish',
recommendationType: 'review',
comments: [
{
content: chance.paragraph(),
public: chance.bool(),
files: [
{
id: chance.guid(),
name: 'file.pdf',
size: chance.natural(),
},
],
},
],
id: chance.guid(),
userId: reviewer1.id,
createdOn: chance.timestamp(),
updatedOn: chance.timestamp(),
submittedOn: chance.timestamp(),
},
],
id: chance.guid(),
}
fragments.majorRevisionWithReview = {
...fragments.fragment,
recommendations: [
{
recommendation: 'major',
recommendationType: 'editorRecommendation',
comments: [
{
content: chance.paragraph(),
public: true,
files: [
{
id: chance.guid(),
name: 'file.pdf',
size: chance.natural(),
},
],
},
],
id: chance.guid(),
userId: handlingEditor.id,
createdOn: chance.timestamp(),
updatedOn: chance.timestamp(),
},
{
recommendation: 'publish',
recommendationType: 'review',
comments: [
{
content: chance.paragraph(),
public: chance.bool(),
files: [
{
id: chance.guid(),
name: 'file.pdf',
size: chance.natural(),
},
],
},
],
id: chance.guid(),
userId: reviewer1.id,
createdOn: chance.timestamp(),
updatedOn: chance.timestamp(),
submittedOn: chance.timestamp(),
},
],
id: chance.guid(),
}
module.exports = fragments module.exports = fragments
...@@ -8,5 +8,4 @@ module.exports = { ...@@ -8,5 +8,4 @@ module.exports = {
authorTeamID: chance.guid(), authorTeamID: chance.guid(),
revRecommendationTeamID: chance.guid(), revRecommendationTeamID: chance.guid(),
rev1TeamID: chance.guid(), rev1TeamID: chance.guid(),
heTeamMinorRevisionCollectionTeamID: chance.guid(),
} }
...@@ -8,11 +8,10 @@ const { ...@@ -8,11 +8,10 @@ const {
authorTeamID, authorTeamID,
revRecommendationTeamID, revRecommendationTeamID,
rev1TeamID, rev1TeamID,
heTeamMinorRevisionCollectionTeamID,
} = require('./teamIDs') } = require('./teamIDs')
const { submittingAuthor } = require('./userData') const { submittingAuthor } = require('./userData')
const { collection, collection2 } = collections const { collection } = collections
const { fragment, reviewCompletedFragment, fragment1 } = fragments const { fragment, reviewCompletedFragment, fragment1 } = fragments
const { const {
handlingEditor, handlingEditor,
...@@ -40,23 +39,6 @@ const teams = { ...@@ -40,23 +39,6 @@ const teams = {
updateProperties: jest.fn(() => teams.heTeam), updateProperties: jest.fn(() => teams.heTeam),
id: heTeamID, id: heTeamID,
}, },
heTeamMinorRevisionCollection: {
teamType: {
name: 'handlingEditor',
permissions: 'handlingEditor',
},
group: 'handlingEditor',
name: 'HandlingEditor',
object: {
type: 'collection',
id: collection2.id,
},
members: [handlingEditor.id],
save: jest.fn(() => teams.heTeam),
delete: jest.fn(),
updateProperties: jest.fn(() => teams.heTeam),
id: heTeamMinorRevisionCollectionTeamID,
},
revTeam: { revTeam: {
teamType: { teamType: {
name: 'reviewer', name: 'reviewer',
......
...@@ -8,7 +8,6 @@ const { ...@@ -8,7 +8,6 @@ const {
authorTeamID, authorTeamID,
revRecommendationTeamID, revRecommendationTeamID,
rev1TeamID, rev1TeamID,
heTeamMinorRevisionCollectionTeamID,
} = require('./teamIDs') } = require('./teamIDs')
const keys = Object.keys(usersData) const keys = Object.keys(usersData)
...@@ -19,7 +18,7 @@ users = keys.reduce((obj, item) => { ...@@ -19,7 +18,7 @@ users = keys.reduce((obj, item) => {
let teams = [] let teams = []
if (isHE) { if (isHE) {
teams = [heTeamID, heTeamMinorRevisionCollectionTeamID] teams = [heTeamID]
} }
if (item === 'author') { if (item === 'author') {
teams = [authorTeamID] teams = [authorTeamID]
......
...@@ -130,9 +130,13 @@ describe('Post fragments recommendations route handler', () => { ...@@ -130,9 +130,13 @@ describe('Post fragments recommendations route handler', () => {
it('should return success when creating a recommendation as a HE after minor revision and we have at least one review on collection.', async () => { it('should return success when creating a recommendation as a HE after minor revision and we have at least one review on collection.', async () => {
const { handlingEditor } = testFixtures.users const { handlingEditor } = testFixtures.users
const { collection2 } = testFixtures.collections const { collection } = testFixtures.collections
const { noInvitesFragment } = testFixtures.fragments const {
minorRevisionWithReview,
noInvitesFragment1,
} = testFixtures.fragments
collection.fragments = [minorRevisionWithReview.id, noInvitesFragment1.id]
const res = await requests.sendRequest({ const res = await requests.sendRequest({
body, body,
userId: handlingEditor.id, userId: handlingEditor.id,
...@@ -140,8 +144,8 @@ describe('Post fragments recommendations route handler', () => { ...@@ -140,8 +144,8 @@ describe('Post fragments recommendations route handler', () => {
route, route,
path, path,
params: { params: {
collectionId: collection2.id, collectionId: collection.id,
fragmentId: noInvitesFragment.id, fragmentId: noInvitesFragment1.id,
}, },
}) })
...@@ -150,6 +154,95 @@ describe('Post fragments recommendations route handler', () => { ...@@ -150,6 +154,95 @@ describe('Post fragments recommendations route handler', () => {
expect(data.userId).toEqual(handlingEditor.id) expect(data.userId).toEqual(handlingEditor.id)
}) })
it('should return error when creating a recommendation as a HE after minor revision and there are no reviews.', async () => {
const { handlingEditor } = testFixtures.users
const { collection } = testFixtures.collections
const {
minorRevisionWithoutReview,
noInvitesFragment1,
} = testFixtures.fragments
collection.fragments = [
minorRevisionWithoutReview.id,
noInvitesFragment1.id,
]
const res = await requests.sendRequest({
body,
userId: handlingEditor.id,
models,
route,
path,
params: {
collectionId: collection.id,
fragmentId: noInvitesFragment1.id,
},
})
expect(res.statusCode).toBe(400)
const data = JSON.parse(res._getData())
expect(data.error).toEqual(
'Cannot publish without at least one reviewer report.',
)
})
it('should return success when creating a recommendation as a HE after major revision and there are least one review on fragment.', async () => {
const { handlingEditor } = testFixtures.users
const { collection } = testFixtures.collections
const {
majorRevisionWithReview,
reviewCompletedFragment,
} = testFixtures.fragments
reviewCompletedFragment.collectionId = collection.id
collection.fragments = [
majorRevisionWithReview.id,
reviewCompletedFragment.id,
]
const res = await requests.sendRequest({
body,
userId: handlingEditor.id,
models,
route,
path,
params: {
collectionId: collection.id,
fragmentId: reviewCompletedFragment.id,
},
})
expect(res.statusCode).toBe(200)
const data = JSON.parse(res._getData())
expect(data.userId).toEqual(handlingEditor.id)
})
it('should return error when creating a recommendation as a HE after major revision there are no reviews on fragment.', async () => {
const { handlingEditor } = testFixtures.users
const { collection } = testFixtures.collections
const {
majorRevisionWithReview,
noInvitesFragment1,
} = testFixtures.fragments
collection.fragments = [majorRevisionWithReview.id, noInvitesFragment1.id]
const res = await requests.sendRequest({
body,
userId: handlingEditor.id,
models,
route,
path,
params: {
collectionId: collection.id,
fragmentId: noInvitesFragment1.id,
},
})
expect(res.statusCode).toBe(400)
const data = JSON.parse(res._getData())
expect(data.error).toEqual(
'Cannot publish without at least one reviewer report.',
)
})
it('should return an error when the fragmentId does not match the collectionId', async () => { it('should return an error when the fragmentId does not match the collectionId', async () => {
const { reviewer } = testFixtures.users const { reviewer } = testFixtures.users
const { collection } = testFixtures.collections const { collection } = testFixtures.collections
......
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