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
b2136584
Commit
b2136584
authored
Jan 23, 2020
by
Natalia Tepluhina
Committed by
Phil Hughes
Jan 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert Jest tests to use VTU in 'ee/spec/frontend/vue_shared'
parent
ab1b6793
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
239 additions
and
232 deletions
+239
-232
ee/spec/frontend/vue_shared/security_reports/components/__snapshots__/dast_issue_body_spec.js.snap
...rts/components/__snapshots__/dast_issue_body_spec.js.snap
+21
-0
ee/spec/frontend/vue_shared/security_reports/components/__snapshots__/sast_container_issue_body_spec.js.snap
...ents/__snapshots__/sast_container_issue_body_spec.js.snap
+19
-0
ee/spec/frontend/vue_shared/security_reports/components/__snapshots__/sast_issue_body_spec.js.snap
...rts/components/__snapshots__/sast_issue_body_spec.js.snap
+21
-0
ee/spec/frontend/vue_shared/security_reports/components/dast_issue_body_spec.js
...hared/security_reports/components/dast_issue_body_spec.js
+29
-47
ee/spec/frontend/vue_shared/security_reports/components/sast_container_issue_body_spec.js
...rity_reports/components/sast_container_issue_body_spec.js
+30
-45
ee/spec/frontend/vue_shared/security_reports/components/sast_issue_body_spec.js
...hared/security_reports/components/sast_issue_body_spec.js
+52
-94
ee/spec/frontend/vue_shared/security_reports/components/split_button_spec.js
...e_shared/security_reports/components/split_button_spec.js
+67
-46
No files found.
ee/spec/frontend/vue_shared/security_reports/components/__snapshots__/dast_issue_body_spec.js.snap
0 → 100644
View file @
b2136584
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Dast Issue Body matches the snaphot 1`] = `
<div
class="report-block-list-issue-description prepend-top-5 append-bottom-5"
>
<div
class="report-block-list-issue-description-text"
>
Low (Medium):
<modal-open-name-stub
class="js-modal-dast"
issue="[object Object]"
status="failed"
/>
</div>
</div>
`;
ee/spec/frontend/vue_shared/security_reports/components/__snapshots__/sast_container_issue_body_spec.js.snap
0 → 100644
View file @
b2136584
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Sast Container Issue Body matches snapshot 1`] = `
<div
class="report-block-list-issue-description prepend-top-5 append-bottom-5"
>
<div
class="report-block-list-issue-description-text"
>
Low:
<modal-open-name-stub
issue="[object Object]"
status="Failed"
/>
</div>
</div>
`;
ee/spec/frontend/vue_shared/security_reports/components/__snapshots__/sast_issue_body_spec.js.snap
0 → 100644
View file @
b2136584
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Sast Issue Body matches snapshot 1`] = `
<div
class="report-block-list-issue-description prepend-top-5 append-bottom-5"
>
<div
class="report-block-list-issue-description-text"
>
Medium (Low):
<modal-open-name-stub
issue="[object Object]"
status="failed"
/>
</div>
<!---->
</div>
`;
ee/spec/frontend/vue_shared/security_reports/components/dast_issue_body_spec.js
View file @
b2136584
import
Vue
from
'
vue
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
component
from
'
ee/vue_shared/security_reports/components/dast_issue_body.vue
'
;
import
DastIssueBody
from
'
ee/vue_shared/security_reports/components/dast_issue_body.vue
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
describe
(
'
dast issue b
ody
'
,
()
=>
{
describe
(
'
Dast Issue B
ody
'
,
()
=>
{
let
vm
;
let
wrapper
;
const
Component
=
Vue
.
extend
(
component
);
const
createComponent
=
()
=>
{
const
dastIssue
=
{
wrapper
=
shallowMount
(
DastIssueBody
,
{
alert
:
'
X-Content-Type-Options Header Missing
'
,
propsData
:
{
severity
:
'
Low
'
,
issue
:
{
confidence
:
'
Medium
'
,
alert
:
'
X-Content-Type-Options Header Missing
'
,
count
:
'
17
'
,
severity
:
'
Low
'
,
cweid
:
'
16
'
,
confidence
:
'
Medium
'
,
desc
:
'
<p>The Anti-MIME-Sniffing header X-Content-Type-Options was not set to "nosniff". </p>
'
,
count
:
'
17
'
,
title
:
'
X-Content-Type-Options Header Missing
'
,
cweid
:
'
16
'
,
reference
:
desc
:
'
<p>http://msdn.microsoft.com/en-us/library/ie/gg622941%28v=vs.85%29.aspx</p><p>https://www.owasp.org/index.php/List_of_useful_HTTP_headers</p>
'
,
'
<p>The Anti-MIME-Sniffing header X-Content-Type-Options was not set to "nosniff". </p>
'
,
riskcode
:
'
1
'
,
title
:
'
X-Content-Type-Options Header Missing
'
,
riskdesc
:
'
Low (Medium)
'
,
reference
:
'
<p>http://msdn.microsoft.com/en-us/library/ie/gg622941%28v=vs.85%29.aspx</p><p>https://www.owasp.org/index.php/List_of_useful_HTTP_headers</p>
'
,
riskcode
:
'
1
'
,
riskdesc
:
'
Low (Medium)
'
,
},
status
:
'
failed
'
,
},
});
};
};
const
status
=
'
failed
'
;
afterEach
(()
=>
{
afterEach
(()
=>
{
vm
.
$destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
describe
(
'
severity and confidence
'
,
()
=>
{
it
(
'
matches the snaphot
'
,
()
=>
{
it
(
'
renders severity and confidence
'
,
()
=>
{
createComponent
();
vm
=
mountComponent
(
Component
,
{
issue
:
dastIssue
,
issueIndex
:
1
,
modalTargetId
:
'
#modal-mrwidget-issue
'
,
status
,
});
expect
(
vm
.
$el
.
textContent
.
trim
()).
toContain
(
`
${
dastIssue
.
severity
}
(
${
dastIssue
.
confidence
}
)`
,
);
});
});
describe
(
'
issue title
'
,
()
=>
{
expect
(
wrapper
.
element
).
toMatchSnapshot
();
beforeEach
(()
=>
{
vm
=
mountComponent
(
Component
,
{
issue
:
dastIssue
,
issueIndex
:
1
,
modalTargetId
:
'
#modal-mrwidget-issue
'
,
status
,
});
});
it
(
'
renders button with issue title
'
,
()
=>
{
expect
(
vm
.
$el
.
textContent
.
trim
()).
toContain
(
dastIssue
.
title
);
});
});
});
});
});
ee/spec/frontend/vue_shared/security_reports/components/sast_container_issue_body_spec.js
View file @
b2136584
import
Vue
from
'
vue
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
component
from
'
ee/vue_shared/security_reports/components/sast_container_issue_body.vue
'
;
import
SastContainerIssueBody
from
'
ee/vue_shared/security_reports/components/sast_container_issue_body.vue
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
describe
(
'
Sast Container Issue Body
'
,
()
=>
{
describe
(
'
sast container issue body
'
,
()
=>
{
let
wrapper
;
let
vm
;
const
createComponent
=
severity
=>
{
const
Component
=
Vue
.
extend
(
component
);
wrapper
=
shallowMount
(
SastContainerIssueBody
,
{
propsData
:
{
const
sastContainerIssue
=
{
issue
:
{
title
:
'
CVE-2017-11671
'
,
title
:
'
CVE-2017-11671
'
,
namespace
:
'
debian:8
'
,
namespace
:
'
debian:8
'
,
path
:
'
debian:8
'
,
path
:
'
debian:8
'
,
severity
:
'
Low
'
,
severity
,
vulnerability
:
'
CVE-2017-11671
'
,
vulnerability
:
'
CVE-2017-11671
'
,
},
status
:
'
Failed
'
,
},
});
};
};
const
status
=
'
failed
'
;
afterEach
(()
=>
{
afterEach
(()
=>
{
vm
.
$destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
describe
(
'
with severity
'
,
()
=>
{
it
(
'
matches snapshot
'
,
()
=>
{
it
(
'
renders severity key
'
,
()
=>
{
createComponent
(
'
Low
'
);
vm
=
mountComponent
(
Component
,
{
issue
:
sastContainerIssue
,
status
,
});
expect
(
vm
.
$el
.
textContent
.
trim
()).
toContain
(
sastContainerIssue
.
severity
);
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
});
});
describe
(
'
without severity
'
,
()
=>
{
it
(
'
renders severity if present on issue
'
,
()
=>
{
it
(
'
does not render severity key
'
,
()
=>
{
createComponent
(
'
Low
'
);
const
issueCopy
=
Object
.
assign
({},
sastContainerIssue
);
expect
(
wrapper
.
find
(
'
.report-block-list-issue-description-text
'
).
text
()).
toBe
(
'
Low:
'
);
delete
issueCopy
.
severity
;
vm
=
mountComponent
(
Component
,
{
issue
:
issueCopy
,
status
,
});
expect
(
vm
.
$el
.
textContent
.
trim
()).
not
.
toContain
(
sastContainerIssue
.
severity
);
});
});
});
it
(
'
renders name
'
,
()
=>
{
it
(
'
does not render severity if not present on issue
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
createComponent
();
issue
:
sastContainerIssue
,
expect
(
wrapper
.
find
(
'
.report-block-list-issue-description-text
'
).
text
()).
toBe
(
''
);
status
,
});
expect
(
vm
.
$el
.
querySelector
(
'
button
'
).
textContent
.
trim
()).
toEqual
(
sastContainerIssue
.
title
);
});
});
});
});
ee/spec/frontend/vue_shared/security_reports/components/sast_issue_body_spec.js
View file @
b2136584
import
Vue
from
'
vue
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
component
from
'
ee/vue_shared/security_reports/components/sast_issue_body.vue
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
{
STATUS_FAILED
}
from
'
~/reports/constants
'
;
import
{
STATUS_FAILED
}
from
'
~/reports/constants
'
;
import
SastIssueBody
from
'
ee/vue_shared/security_reports/components/sast_issue_body.vue
'
;
import
ReportLink
from
'
~/reports/components/report_link.vue
'
;
describe
(
'
sast issue body
'
,
()
=>
{
describe
(
'
Sast Issue Body
'
,
()
=>
{
let
vm
;
let
wrapper
;
const
Component
=
Vue
.
extend
(
component
);
const
sastIssue
=
{
cve
:
'
CVE-2016-9999
'
,
file
:
'
Gemfile.lock
'
,
message
:
'
Test Information Leak Vulnerability in Action View
'
,
title
:
'
Test Information Leak Vulnerability in Action View
'
,
path
:
'
Gemfile.lock
'
,
solution
:
'
upgrade to >= 5.0.0.beta1.1, >= 4.2.5.1, ~> 4.2.5, >= 4.1.14.1, ~> 4.1.14, ~> 3.2.22.1
'
,
tool
:
'
bundler_audit
'
,
url
:
'
https://groups.google.com/forum/#!topic/rubyonrails-security/335P1DcLG00
'
,
urlPath
:
'
/Gemfile.lock
'
,
severity
:
'
medium
'
,
confidence
:
'
low
'
,
};
const
status
=
STATUS_FAILED
;
const
findDescriptionText
=
()
=>
wrapper
.
find
(
'
.report-block-list-issue-description-text
'
);
const
findReportLink
=
()
=>
wrapper
.
find
(
ReportLink
);
const
createComponent
=
issue
=>
{
wrapper
=
shallowMount
(
SastIssueBody
,
{
propsData
:
{
issue
,
status
:
STATUS_FAILED
,
},
});
};
afterEach
(()
=>
{
afterEach
(()
=>
{
vm
.
$destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
describe
(
'
with severity and confidence (new json format)
'
,
()
=>
{
it
(
'
matches snapshot
'
,
()
=>
{
it
(
'
renders severity and confidence
'
,
()
=>
{
createComponent
({
vm
=
mountComponent
(
Component
,
{
severity
:
'
medium
'
,
issue
:
sastIssue
,
confidence
:
'
low
'
,
status
,
priority
:
'
high
'
,
});
expect
(
vm
.
$el
.
textContent
.
trim
()).
toContain
(
'
Medium (Low):
'
);
});
});
});
describe
(
'
with severity and without confidence (new json format)
'
,
()
=>
{
it
(
'
renders severity only
'
,
()
=>
{
const
issueCopy
=
Object
.
assign
({},
sastIssue
);
delete
issueCopy
.
confidence
;
vm
=
mountComponent
(
Component
,
{
issue
:
issueCopy
,
status
,
});
expect
(
vm
.
$el
.
textContent
.
trim
()).
toContain
(
'
Medium:
'
);
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
});
});
describe
(
'
with confidence and without severity (new json format)
'
,
()
=>
{
it
(
'
renders priority if no security and confidence are passed
'
,
()
=>
{
it
(
'
renders confidence only
'
,
()
=>
{
createComponent
({
const
issueCopy
=
Object
.
assign
({},
sastIssue
);
priority
:
'
high
'
,
delete
issueCopy
.
severity
;
vm
=
mountComponent
(
Component
,
{
issue
:
issueCopy
,
status
,
});
expect
(
vm
.
$el
.
textContent
.
trim
()).
toContain
(
'
(Low):
'
);
});
});
expect
(
findDescriptionText
().
text
()).
toBe
(
'
high:
'
);
});
});
describe
(
'
with priority (old json format)
'
,
()
=>
{
it
(
'
renders confidence if no severity is passed
'
,
()
=>
{
it
(
'
renders priority key
'
,
()
=>
{
createComponent
({
const
issueCopy
=
Object
.
assign
({},
sastIssue
);
confidence
:
'
low
'
,
delete
issueCopy
.
severity
;
delete
issueCopy
.
confidence
;
issueCopy
.
priority
=
'
Low
'
;
vm
=
mountComponent
(
Component
,
{
issue
:
issueCopy
,
status
,
});
expect
(
vm
.
$el
.
textContent
.
trim
()).
toContain
(
issueCopy
.
priority
);
});
});
expect
(
findDescriptionText
().
text
()).
toBe
(
'
(Low):
'
);
});
});
describe
(
'
without priority
'
,
()
=>
{
it
(
'
renders severity if no confidence is passed
'
,
()
=>
{
it
(
'
does not render priority key
'
,
()
=>
{
createComponent
({
const
issueCopy
=
Object
.
assign
({},
sastIssue
);
severity
:
'
medium
'
,
delete
issueCopy
.
severity
;
});
delete
issueCopy
.
confidence
;
vm
=
mountComponent
(
Component
,
{
expect
(
findDescriptionText
().
text
()).
toBe
(
'
Medium:
'
);
issue
:
issueCopy
,
});
status
,
});
expect
(
vm
.
$el
.
textContent
.
trim
()).
not
.
toContain
(
sastIssue
.
priority
);
it
(
'
renders severity and confidence if both are passed
'
,
()
=>
{
createComponent
({
severity
:
'
medium
'
,
confidence
:
'
low
'
,
});
});
expect
(
findDescriptionText
().
text
()).
toBe
(
'
Medium (Low):
'
);
});
});
describe
(
'
title
'
,
()
=>
{
it
(
'
does not render report link if no path is passed
'
,
()
=>
{
it
(
'
renders title
'
,
()
=>
{
createComponent
({});
vm
=
mountComponent
(
Component
,
{
issue
:
sastIssue
,
status
,
});
expect
(
vm
.
$el
.
textContent
.
trim
()).
toContain
(
sastIssue
.
title
);
expect
(
findReportLink
().
exists
()).
toBe
(
false
);
});
});
});
describe
(
'
path
'
,
()
=>
{
it
(
'
renders report link if path is passed
'
,
()
=>
{
it
(
'
renders path
'
,
()
=>
{
createComponent
({
path
:
'
test-path
'
});
vm
=
mountComponent
(
Component
,
{
issue
:
sastIssue
,
status
,
});
expect
(
vm
.
$el
.
querySelector
(
'
a
'
).
getAttribute
(
'
href
'
)).
toEqual
(
sastIssue
.
urlPath
);
expect
(
findReportLink
().
exists
()).
toBe
(
true
);
expect
(
vm
.
$el
.
querySelector
(
'
a
'
).
textContent
.
trim
()).
toEqual
(
sastIssue
.
path
);
});
});
});
});
});
ee/spec/frontend/vue_shared/security_reports/components/split_button_spec.js
View file @
b2136584
import
Vue
from
'
vue
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
component
from
'
ee/vue_shared/security_reports/components/split_button.vue
'
;
import
{
GlDropdown
,
GlDropdownItem
}
from
'
@gitlab/ui
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
SplitButton
from
'
ee/vue_shared/security_reports/components/split_button.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
const
buttons
=
[
{
name
:
'
button one
'
,
tagline
:
"
button one's tagline
"
,
isLoading
:
false
,
action
:
'
button1Action
'
,
},
{
name
:
'
button two
'
,
tagline
:
"
button two's tagline
"
,
isLoading
:
false
,
action
:
'
button2Action
'
,
},
];
describe
(
'
Split Button
'
,
()
=>
{
describe
(
'
Split Button
'
,
()
=>
{
const
Component
=
Vue
.
extend
(
component
);
let
wrapper
;
const
buttons
=
[
{
const
findDropdown
=
()
=>
wrapper
.
find
(
GlDropdown
);
name
:
'
button one
'
,
const
findDropdownItems
=
()
=>
wrapper
.
findAll
(
GlDropdownItem
);
tagline
:
"
button one's tagline
"
,
isLoading
:
false
,
const
createComponent
=
props
=>
{
action
:
'
button1Action
'
,
wrapper
=
shallowMount
(
SplitButton
,
{
},
propsData
:
{
{
...
props
,
name
:
'
button two
'
,
},
tagline
:
"
button two's tagline
"
,
});
isLoading
:
false
,
};
action
:
'
button2Action
'
,
},
{
name
:
'
button three
'
,
tagline
:
"
button three's tagline
"
,
isLoading
:
true
,
action
:
'
button3Action
'
,
},
];
let
props
;
let
vm
;
afterEach
(()
=>
{
afterEach
(()
=>
{
vm
.
$destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
describe
(
'
with two buttons
'
,
()
=>
{
it
(
'
does not render dropdown if buttons array is empty
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
props
=
{
buttons
:
buttons
.
slice
(
0
,
2
)
};
buttons
:
[],
vm
=
mountComponent
(
Component
,
props
);
});
});
it
(
'
renders two dropdown items
'
,
()
=>
{
expect
(
findDropdown
().
exists
()).
toBe
(
false
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.dropdown-item
'
)).
toHaveLength
(
2
);
});
it
(
'
renders disabled dropdown if disabled prop is true
'
,
()
=>
{
createComponent
({
buttons
:
buttons
.
slice
(
0
),
disabled
:
true
,
});
});
it
(
'
displays the first button initially
'
,
()
=>
{
expect
(
findDropdown
().
attributes
().
disabled
).
toBe
(
'
true
'
);
expect
(
vm
.
$el
.
querySelector
(
'
.btn
'
).
textContent
.
trim
()).
toBe
(
buttons
[
0
].
name
);
});
it
(
'
emits correct action on dropdown click
'
,
()
=>
{
createComponent
({
buttons
:
buttons
.
slice
(
0
),
});
});
it
(
'
emits the correct event when the button is pressed
'
,
()
=>
{
findDropdown
().
vm
.
$emit
(
'
click
'
);
jest
.
spyOn
(
vm
,
'
$emit
'
);
vm
.
$el
.
querySelector
(
'
.btn
'
).
click
();
expect
(
wrapper
.
emitted
(
'
button1Action
'
)).
toBeDefined
();
expect
(
wrapper
.
emitted
(
'
button1Action
'
)).
toHaveLength
(
1
);
});
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
buttons
[
0
].
action
);
it
(
'
renders a correct amount of dropdown items
'
,
()
=>
{
createComponent
({
buttons
,
});
});
expect
(
findDropdownItems
()).
toHaveLength
(
2
);
});
});
describe
(
'
with three buttons
'
,
()
=>
{
it
(
'
renders an icon if dropdown item is selected
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
props
=
{
buttons
};
buttons
:
buttons
.
slice
(
0
),
vm
=
mountComponent
(
Component
,
props
);
});
});
it
(
'
renders three dropdown items
'
,
()
=>
{
expect
(
expect
(
vm
.
$el
.
querySelectorAll
(
'
.dropdown-item
'
)).
toHaveLength
(
3
);
findDropdownItems
()
});
.
at
(
0
)
.
find
(
Icon
)
.
exists
(),
).
toBe
(
true
);
});
});
});
});
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