Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f421ae87
Commit
f421ae87
authored
Oct 05, 2020
by
Kev
Committed by
Brandon Labuschagne
Oct 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor createWrapper to take object instead of multiple arguments
parent
66cb72b6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
20 deletions
+25
-20
ee/changelogs/unreleased/259680-Refactor-createWrapper.yml
ee/changelogs/unreleased/259680-Refactor-createWrapper.yml
+5
-0
ee/spec/frontend/vulnerabilities/related_issues_spec.js
ee/spec/frontend/vulnerabilities/related_issues_spec.js
+20
-20
No files found.
ee/changelogs/unreleased/259680-Refactor-createWrapper.yml
0 → 100644
View file @
f421ae87
---
title
:
Refactor vulnerabilities related issues component test createWrapper method to take an object instead of multiple arguments
merge_request
:
44035
author
:
Kev @KevSlashNull
type
:
other
ee/spec/frontend/vulnerabilities/related_issues_spec.js
View file @
f421ae87
...
@@ -33,7 +33,7 @@ describe('Vulnerability related issues component', () => {
...
@@ -33,7 +33,7 @@ describe('Vulnerability related issues component', () => {
const
issue1
=
{
id
:
3
,
vulnerabilityLinkId
:
987
};
const
issue1
=
{
id
:
3
,
vulnerabilityLinkId
:
987
};
const
issue2
=
{
id
:
25
,
vulnerabilityLinkId
:
876
};
const
issue2
=
{
id
:
25
,
vulnerabilityLinkId
:
876
};
const
createWrapper
=
async
(
data
=
{},
provide
=
{},
opts
)
=>
{
const
createWrapper
=
async
(
{
data
=
{},
provide
=
{},
stubs
=
{}
}
=
{}
)
=>
{
wrapper
=
shallowMount
(
RelatedIssues
,
{
wrapper
=
shallowMount
(
RelatedIssues
,
{
propsData
,
propsData
,
data
:
()
=>
data
,
data
:
()
=>
data
,
...
@@ -46,7 +46,7 @@ describe('Vulnerability related issues component', () => {
...
@@ -46,7 +46,7 @@ describe('Vulnerability related issues component', () => {
permissionsHelpPath
,
permissionsHelpPath
,
...
provide
,
...
provide
,
},
},
...
opt
s
,
stub
s
,
});
});
// Need this special check because RelatedIssues creates the store and uses its state in the data function, so we
// Need this special check because RelatedIssues creates the store and uses its state in the data function, so we
// need to set the state of the store, not replace the state property.
// need to set the state of the store, not replace the state property.
...
@@ -79,7 +79,7 @@ describe('Vulnerability related issues component', () => {
...
@@ -79,7 +79,7 @@ describe('Vulnerability related issues component', () => {
},
},
};
};
createWrapper
(
data
);
createWrapper
(
{
data
}
);
expect
(
relatedIssuesBlock
().
props
()).
toMatchObject
({
expect
(
relatedIssuesBlock
().
props
()).
toMatchObject
({
helpPath
:
propsData
.
helpPath
,
helpPath
:
propsData
.
helpPath
,
...
@@ -120,7 +120,7 @@ describe('Vulnerability related issues component', () => {
...
@@ -120,7 +120,7 @@ describe('Vulnerability related issues component', () => {
describe
(
'
add related issue
'
,
()
=>
{
describe
(
'
add related issue
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mockAxios
.
onGet
(
propsData
.
endpoint
).
replyOnce
(
httpStatusCodes
.
OK
,
[]);
mockAxios
.
onGet
(
propsData
.
endpoint
).
replyOnce
(
httpStatusCodes
.
OK
,
[]);
createWrapper
({
isFormVisible
:
true
});
createWrapper
({
data
:
{
isFormVisible
:
true
}
});
});
});
it
(
'
adds related issue with vulnerabilityLinkId populated
'
,
async
()
=>
{
it
(
'
adds related issue with vulnerabilityLinkId populated
'
,
async
()
=>
{
...
@@ -178,7 +178,7 @@ describe('Vulnerability related issues component', () => {
...
@@ -178,7 +178,7 @@ describe('Vulnerability related issues component', () => {
${
true
}
|
${
false
}
${
true
}
|
${
false
}
${
false
}
|
${
true
}
${
false
}
|
${
true
}
`
(
'
toggles form visibility from $from to $to
'
,
async
({
from
,
to
})
=>
{
`
(
'
toggles form visibility from $from to $to
'
,
async
({
from
,
to
})
=>
{
createWrapper
({
isFormVisible
:
from
});
createWrapper
({
data
:
{
isFormVisible
:
from
}
});
blockEmit
(
'
toggleAddRelatedIssuesForm
'
);
blockEmit
(
'
toggleAddRelatedIssuesForm
'
);
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
...
@@ -187,9 +187,11 @@ describe('Vulnerability related issues component', () => {
...
@@ -187,9 +187,11 @@ describe('Vulnerability related issues component', () => {
it
(
'
resets form and hides it
'
,
async
()
=>
{
it
(
'
resets form and hides it
'
,
async
()
=>
{
createWrapper
({
createWrapper
({
data
:
{
inputValue
:
'
some input value
'
,
inputValue
:
'
some input value
'
,
isFormVisible
:
true
,
isFormVisible
:
true
,
state
:
{
pendingReferences
:
[
'
135
'
,
'
246
'
]
},
state
:
{
pendingReferences
:
[
'
135
'
,
'
246
'
]
},
},
});
});
blockEmit
(
'
addIssuableFormCancel
'
);
blockEmit
(
'
addIssuableFormCancel
'
);
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
...
@@ -205,7 +207,7 @@ describe('Vulnerability related issues component', () => {
...
@@ -205,7 +207,7 @@ describe('Vulnerability related issues component', () => {
const
pendingReferences
=
[
'
135
'
,
'
246
'
];
const
pendingReferences
=
[
'
135
'
,
'
246
'
];
const
untouchedRawReferences
=
[
'
357
'
,
'
468
'
];
const
untouchedRawReferences
=
[
'
357
'
,
'
468
'
];
const
touchedReference
=
'
touchedReference
'
;
const
touchedReference
=
'
touchedReference
'
;
createWrapper
({
state
:
{
pendingReferences
}
});
createWrapper
({
data
:
{
state
:
{
pendingReferences
}
}
});
blockEmit
(
'
addIssuableFormInput
'
,
{
untouchedRawReferences
,
touchedReference
});
blockEmit
(
'
addIssuableFormInput
'
,
{
untouchedRawReferences
,
touchedReference
});
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
...
@@ -225,7 +227,7 @@ describe('Vulnerability related issues component', () => {
...
@@ -225,7 +227,7 @@ describe('Vulnerability related issues component', () => {
});
});
it
(
'
removes pending reference
'
,
async
()
=>
{
it
(
'
removes pending reference
'
,
async
()
=>
{
createWrapper
({
state
:
{
pendingReferences
:
[
'
135
'
,
'
246
'
,
'
357
'
]
}
});
createWrapper
({
data
:
{
state
:
{
pendingReferences
:
[
'
135
'
,
'
246
'
,
'
357
'
]
}
}
});
blockEmit
(
'
pendingIssuableRemoveRequest
'
,
1
);
blockEmit
(
'
pendingIssuableRemoveRequest
'
,
1
);
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
...
@@ -266,14 +268,13 @@ describe('Vulnerability related issues component', () => {
...
@@ -266,14 +268,13 @@ describe('Vulnerability related issues component', () => {
describe
(
'
when linked issue is already created
'
,
()
=>
{
describe
(
'
when linked issue is already created
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createWrapper
(
createWrapper
(
{
{
data
:
{
isFetching
:
false
,
isFetching
:
false
,
state
:
{
relatedIssues
:
[
issue1
,
{
...
issue2
,
vulnerabilityLinkType
:
'
created
'
}]
},
state
:
{
relatedIssues
:
[
issue1
,
{
...
issue2
,
vulnerabilityLinkType
:
'
created
'
}]
},
},
},
{},
stubs
:
{
RelatedIssuesBlock
},
{
stubs
:
{
RelatedIssuesBlock
}
},
});
);
});
});
it
(
'
does not display the create issue button
'
,
()
=>
{
it
(
'
does not display the create issue button
'
,
()
=>
{
...
@@ -291,7 +292,7 @@ describe('Vulnerability related issues component', () => {
...
@@ -291,7 +292,7 @@ describe('Vulnerability related issues component', () => {
beforeEach
(
async
()
=>
{
beforeEach
(
async
()
=>
{
mockAxios
.
onGet
(
propsData
.
endpoint
).
replyOnce
(
httpStatusCodes
.
OK
,
[
issue1
,
issue2
]);
mockAxios
.
onGet
(
propsData
.
endpoint
).
replyOnce
(
httpStatusCodes
.
OK
,
[
issue1
,
issue2
]);
createWrapper
({
},
{},
{
stubs
:
{
RelatedIssuesBlock
}
});
createWrapper
({
stubs
:
{
RelatedIssuesBlock
}
});
await
axios
.
waitForAll
();
await
axios
.
waitForAll
();
});
});
...
@@ -332,12 +333,11 @@ describe('Vulnerability related issues component', () => {
...
@@ -332,12 +333,11 @@ describe('Vulnerability related issues component', () => {
describe
(
'
when project issue tracking is disabled
'
,
()
=>
{
describe
(
'
when project issue tracking is disabled
'
,
()
=>
{
it
(
'
hides the "Create Issue" button
'
,
()
=>
{
it
(
'
hides the "Create Issue" button
'
,
()
=>
{
createWrapper
(
createWrapper
({
{},
provide
:
{
{
createIssueUrl
:
undefined
,
createIssueUrl
:
undefined
,
},
},
);
}
);
expect
(
findCreateIssueButton
().
exists
()).
toBe
(
false
);
expect
(
findCreateIssueButton
().
exists
()).
toBe
(
false
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment