Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
xpub-faraday
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container Registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
xpub
xpub-faraday
Commits
46347c5d
Commit
46347c5d
authored
6 years ago
by
Sebastian Mihalache
Browse files
Options
Downloads
Patches
Plain Diff
fix(submittedReviewers): submitted reviewers will not receive bad email
parent
79225893
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!136
Sprint 22 features (updates)
,
!126
Hin 1046
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/component-helper-service/src/services/Fragment.js
+8
-10
8 additions, 10 deletions
packages/component-helper-service/src/services/Fragment.js
packages/component-helper-service/src/tests/fragment.test.js
+153
-33
153 additions, 33 deletions
packages/component-helper-service/src/tests/fragment.test.js
with
161 additions
and
43 deletions
packages/component-helper-service/src/services/Fragment.js
+
8
−
10
View file @
46347c5d
const
get
=
require
(
'
lodash
/get
'
)
const
{
get
,
remove
}
=
require
(
'
lodash
'
)
const
User
=
require
(
'
./User
'
)
class
Fragment
{
...
...
@@ -92,15 +92,14 @@ class Fragment {
getInvitations
({
isAccepted
=
true
,
role
=
'
reviewer
'
,
type
})
{
const
{
fragment
:
{
invitations
=
[],
recommendations
=
[]
}
}
=
this
let
filteredInvitations
=
isAccepted
const
filteredInvitations
=
isAccepted
?
invitations
.
filter
(
inv
=>
inv
.
role
===
role
&&
inv
.
hasAnswer
&&
inv
.
isAccepted
,
)
:
invitations
.
filter
(
inv
=>
inv
.
role
===
role
&&
!
inv
.
hasAnswer
)
if
(
type
===
'
submitted
'
)
{
filteredInvitations
=
filteredInvitations
.
filter
(
inv
=>
return
filteredInvitations
.
filter
(
inv
=>
recommendations
.
find
(
rec
=>
rec
.
recommendationType
===
'
review
'
&&
...
...
@@ -109,12 +108,11 @@ class Fragment {
),
)
}
else
if
(
type
===
'
accepted
'
)
{
filteredInvitations
=
filteredInvitations
.
filter
(
inv
=>
recommendations
.
find
(
rec
=>
rec
.
recommendationType
===
'
review
'
&&
inv
.
userId
!==
rec
.
userId
,
),
)
recommendations
.
forEach
(
rec
=>
{
if
(
rec
.
recommendationType
===
'
review
'
&&
rec
.
submittedOn
)
{
remove
(
filteredInvitations
,
inv
=>
inv
.
userId
===
rec
.
userId
)
}
})
}
return
filteredInvitations
...
...
This diff is collapsed.
Click to expand it.
packages/component-helper-service/src/tests/fragment.test.js
+
153
−
33
View file @
46347c5d
...
...
@@ -9,10 +9,117 @@ const chance = new Chance()
const
{
fixtures
}
=
fixturesService
const
{
Fragment
}
=
require
(
'
../Helper
'
)
const
acceptedReviewerId
=
chance
.
guid
()
const
submittedReviewerId1
=
chance
.
guid
()
const
submittedReviewerId2
=
chance
.
guid
()
const
fragment
=
{
invitations
:
[
{
id
:
chance
.
guid
(),
role
:
'
reviewer
'
,
hasAnswer
:
true
,
isAccepted
:
true
,
userId
:
acceptedReviewerId
,
invitedOn
:
chance
.
timestamp
(),
respondedOn
:
chance
.
timestamp
(),
type
:
'
invitation
'
,
},
{
id
:
chance
.
guid
(),
role
:
'
reviewer
'
,
hasAnswer
:
true
,
isAccepted
:
true
,
userId
:
submittedReviewerId1
,
invitedOn
:
chance
.
timestamp
(),
respondedOn
:
chance
.
timestamp
(),
type
:
'
invitation
'
,
},
{
id
:
chance
.
guid
(),
role
:
'
reviewer
'
,
hasAnswer
:
true
,
isAccepted
:
true
,
userId
:
submittedReviewerId2
,
invitedOn
:
chance
.
timestamp
(),
respondedOn
:
chance
.
timestamp
(),
type
:
'
invitation
'
,
},
],
recommendations
:
[
{
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
:
submittedReviewerId1
,
createdOn
:
chance
.
timestamp
(),
updatedOn
:
chance
.
timestamp
(),
submittedOn
:
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
:
submittedReviewerId2
,
createdOn
:
chance
.
timestamp
(),
updatedOn
:
chance
.
timestamp
(),
submittedOn
:
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
:
acceptedReviewerId
,
createdOn
:
chance
.
timestamp
(),
updatedOn
:
chance
.
timestamp
(),
},
],
}
describe
(
'
Fragment helper
'
,
()
=>
{
let
testFixtures
=
{}
let
testFragment
=
{}
beforeEach
(()
=>
{
testFixtures
=
cloneDeep
(
fixtures
)
testFragment
=
cloneDeep
(
fragment
)
})
describe
(
'
hasReviewReport
'
,
()
=>
{
...
...
@@ -32,35 +139,18 @@ describe('Fragment helper', () => {
})
describe
(
'
getInvitations
'
,
()
=>
{
it
(
'
should return accepted invitations if type is accepted
'
,
()
=>
{
const
{
fragment
}
=
testFixtures
.
fragments
const
acceptedReviewerId
=
chance
.
guid
()
const
submittedReviewerId
=
chance
.
guid
()
it
(
'
should return accepted invitations if type is accepted and a review report has been started
'
,
()
=>
{
const
fragmentHelper
=
new
Fragment
({
fragment
:
testFragment
})
fragment
.
invitations
.
push
(
{
id
:
chance
.
guid
(),
role
:
'
reviewer
'
,
hasAnswer
:
true
,
isAccepted
:
true
,
userId
:
acceptedReviewerId
,
invitedOn
:
chance
.
timestamp
(),
respondedOn
:
chance
.
timestamp
(),
type
:
'
invitation
'
,
},
{
id
:
chance
.
guid
(),
role
:
'
reviewer
'
,
hasAnswer
:
true
,
isAccepted
:
true
,
userId
:
submittedReviewerId
,
invitedOn
:
chance
.
timestamp
(),
respondedOn
:
chance
.
timestamp
(),
type
:
'
invitation
'
,
},
)
const
acceptedInvitations
=
fragmentHelper
.
getInvitations
({
isAccepted
:
true
,
type
:
'
accepted
'
,
})
fragment
.
recommendations
.
push
(
expect
(
acceptedInvitations
).
toHaveLength
(
1
)
})
it
(
'
should return accepted invitations if type is accepted and no review report has been started
'
,
()
=>
{
testFragment
.
recommendations
=
[
{
recommendation
:
'
publish
'
,
recommendationType
:
'
review
'
,
...
...
@@ -78,7 +168,7 @@ describe('Fragment helper', () => {
},
],
id
:
chance
.
guid
(),
userId
:
submittedReviewerId
,
userId
:
submittedReviewerId
1
,
createdOn
:
chance
.
timestamp
(),
updatedOn
:
chance
.
timestamp
(),
submittedOn
:
chance
.
timestamp
(),
...
...
@@ -100,21 +190,51 @@ describe('Fragment helper', () => {
},
],
id
:
chance
.
guid
(),
userId
:
accep
tedReviewerId
,
userId
:
submit
tedReviewerId
2
,
createdOn
:
chance
.
timestamp
(),
updatedOn
:
chance
.
timestamp
(),
//
submittedOn: chance.timestamp(),
submittedOn
:
chance
.
timestamp
(),
},
)
]
const
fragmentHelper
=
new
Fragment
({
fragment
})
const
fragmentHelper
=
new
Fragment
({
fragment
:
testFragment
})
const
acceptedInvitations
=
fragmentHelper
.
getInvitations
({
isAccepted
:
true
,
type
:
'
accepted
'
,
})
console
.
log
(
acceptedInvitations
)
expect
(
acceptedInvitations
).
toHaveLength
(
1
)
})
it
(
'
should return invitations of submitted reviewers if type is submitted
'
,
()
=>
{
const
fragmentHelper
=
new
Fragment
({
fragment
:
testFragment
})
const
submittedInvitations
=
fragmentHelper
.
getInvitations
({
isAccepted
:
true
,
type
:
'
submitted
'
,
})
expect
(
submittedInvitations
).
toHaveLength
(
2
)
})
it
(
'
should return invitations of pending reviewers if type is pending and isAccepted is false
'
,
()
=>
{
testFragment
.
invitations
.
push
({
id
:
chance
.
guid
(),
role
:
'
reviewer
'
,
hasAnswer
:
false
,
isAccepted
:
false
,
userId
:
chance
.
guid
(),
invitedOn
:
chance
.
timestamp
(),
respondedOn
:
chance
.
timestamp
(),
type
:
'
invitation
'
,
})
const
fragmentHelper
=
new
Fragment
({
fragment
:
testFragment
})
const
pendingInvitations
=
fragmentHelper
.
getInvitations
({
isAccepted
:
false
,
type
:
'
pending
'
,
})
expect
(
pendingInvitations
).
toHaveLength
(
1
)
})
})
})
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment