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
29a3bab9
Commit
29a3bab9
authored
Jul 02, 2020
by
Alexander Turinske
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update location tests
- abstract out logic and property getters
parent
5f1bc407
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
61 deletions
+59
-61
ee/spec/frontend/vulnerabilities/mock_data.js
ee/spec/frontend/vulnerabilities/mock_data.js
+10
-0
ee/spec/frontend/vulnerabilities/vulnerability_list_spec.js
ee/spec/frontend/vulnerabilities/vulnerability_list_spec.js
+49
-61
No files found.
ee/spec/frontend/vulnerabilities/mock_data.js
View file @
29a3bab9
...
...
@@ -52,6 +52,16 @@ export const generateVulnerabilities = () => [
nameWithNamespace
:
'
Mixed Vulnerabilities / Rails App
'
,
},
},
{
id
:
'
id_4
'
,
title
:
'
Vulnerability 4
'
,
severity
:
'
critical
'
,
state
:
'
dismissed
'
,
location
:
{},
project
:
{
nameWithNamespace
:
'
Administrator / Security reports
'
,
},
},
];
export
const
vulnerabilities
=
generateVulnerabilities
();
ee/spec/frontend/vulnerabilities/vulnerability_list_spec.js
View file @
29a3bab9
...
...
@@ -35,6 +35,7 @@ describe('Vulnerability list component', () => {
const
findRowVulnerabilityCommentIcon
=
row
=>
findRow
(
row
).
find
(
VulnerabilityCommentIcon
);
const
findDataCell
=
label
=>
wrapper
.
find
(
`[data-testid="
${
label
}
"]`
);
const
findDataCells
=
label
=>
wrapper
.
findAll
(
`[data-testid="
${
label
}
"]`
);
const
findCellText
=
label
=>
findDataCell
(
label
).
text
();
afterEach
(()
=>
{
wrapper
.
destroy
();
...
...
@@ -116,60 +117,41 @@ describe('Vulnerability list component', () => {
});
});
it
(
'
should display the vulnerability locations
'
,
()
=>
{
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
0
].
id
}
`
).
text
()).
toContain
(
newVulnerabilities
[
0
].
project
.
nameWithNamespace
,
);
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
0
].
id
}
`
).
text
()).
toContain
(
newVulnerabilities
[
0
].
location
.
image
,
);
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
0
].
id
}
`
).
text
()).
not
.
toContain
(
'
(line:
'
);
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
1
].
id
}
`
).
text
()).
toContain
(
newVulnerabilities
[
1
].
project
.
nameWithNamespace
,
);
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
1
].
id
}
`
).
text
()).
toContain
(
newVulnerabilities
[
1
].
location
.
file
,
);
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
1
].
id
}
`
).
text
()).
toContain
(
newVulnerabilities
[
1
].
location
.
startLine
,
);
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
2
].
id
}
`
).
text
()).
toContain
(
newVulnerabilities
[
2
].
project
.
nameWithNamespace
,
);
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
2
].
id
}
`
).
text
()).
toContain
(
newVulnerabilities
[
2
].
location
.
file
,
);
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
2
].
id
}
`
).
text
()).
not
.
toContain
(
'
(line:
'
);
it
(
'
should display the vulnerability locations for images
'
,
()
=>
{
const
{
id
,
project
,
location
}
=
newVulnerabilities
[
0
];
const
cellText
=
findCellText
(
`location-
${
id
}
`
);
expect
(
cellText
).
toContain
(
project
.
nameWithNamespace
);
expect
(
cellText
).
toContain
(
location
.
image
);
expect
(
cellText
).
not
.
toContain
(
'
(line:
'
);
});
it
(
'
should display the vulnerability locations for code
'
,
()
=>
{
const
{
id
,
project
,
location
}
=
newVulnerabilities
[
1
];
const
cellText
=
findCellText
(
`location-
${
id
}
`
);
expect
(
cellText
).
toContain
(
project
.
nameWithNamespace
);
expect
(
cellText
).
toContain
(
location
.
file
);
expect
(
cellText
).
toContain
(
location
.
startLine
);
});
it
(
'
should display the vulnerability locations for code with no line data
'
,
()
=>
{
const
{
id
,
project
,
location
}
=
newVulnerabilities
[
2
];
const
cellText
=
findCellText
(
`location-
${
id
}
`
);
expect
(
cellText
).
toContain
(
project
.
nameWithNamespace
);
expect
(
cellText
).
toContain
(
location
.
file
);
expect
(
cellText
).
not
.
toContain
(
'
(line:
'
);
});
it
(
'
should not display the vulnerability locations for vulnerabilities without a location
'
,
()
=>
{
const
{
id
,
project
}
=
newVulnerabilities
[
4
];
const
cellText
=
findCellText
(
`location-
${
id
}
`
);
expect
(
cellText
).
toEqual
(
project
.
nameWithNamespace
);
expect
(
cellText
).
not
.
toContain
(
'
(line:
'
);
});
it
(
'
should not display the vulnerability report type
'
,
()
=>
{
const
scannerCell
=
findRow
().
find
(
'
[data-testid="vulnerability-report-type"
'
);
expect
(
scannerCell
.
exists
()).
toBe
(
false
);
});
it
(
'
should not display the vulnerability locations
'
,
()
=>
{
const
vulnerabilityWithoutLocation
=
[
{
id
:
'
id_0
'
,
title
:
'
Vulnerability 1
'
,
severity
:
'
critical
'
,
state
:
'
dismissed
'
,
location
:
{},
project
:
{
nameWithNamespace
:
'
Administrator / Security reports
'
,
},
},
];
wrapper
=
createWrapper
({
props
:
{
vulnerabilities
:
vulnerabilityWithoutLocation
,
shouldShowProjectNamespace
:
true
},
});
expect
(
findDataCell
(
`location-
${
vulnerabilityWithoutLocation
[
0
].
id
}
`
).
text
()).
toContain
(
'
Administrator / Security reports
'
,
);
expect
(
findDataCell
(
`location-
${
vulnerabilityWithoutLocation
[
0
].
id
}
`
).
findAll
(
'
div
'
).
length
,
).
toBe
(
2
);
});
});
describe
(
'
when displayed on a project level dashboard
'
,
()
=>
{
...
...
@@ -181,19 +163,25 @@ describe('Vulnerability list component', () => {
});
});
it
(
'
should not display the vulnerability locations
'
,
()
=>
{
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
0
].
id
}
`
).
text
()).
not
.
toContain
(
'
Administrator / Security reports
'
,
);
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
0
].
id
}
`
).
text
()).
toContain
(
'
registry.gitlab.com/groulot/container-scanning-test/master:5f21de6956aee99ddb68ae49498662d9872f50ff
'
,
);
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
1
].
id
}
`
).
text
()).
not
.
toContain
(
'
Administrator / Vulnerability reports
'
,
);
expect
(
findDataCell
(
`location-
${
newVulnerabilities
[
1
].
id
}
`
).
text
()).
toContain
(
'
src/main/java/com/gitlab/security_products/tests/App.java
'
,
);
it
(
'
should not display the vulnerability group/project locations for images
'
,
()
=>
{
const
{
id
,
project
,
location
}
=
newVulnerabilities
[
0
];
const
cellText
=
findCellText
(
`location-
${
id
}
`
);
expect
(
cellText
).
not
.
toContain
(
project
.
nameWithNamespace
);
expect
(
cellText
).
toEqual
(
location
.
image
);
});
it
(
'
should display the vulnerability locations for code
'
,
()
=>
{
const
{
id
,
project
,
location
}
=
newVulnerabilities
[
1
];
const
cellText
=
findCellText
(
`location-
${
id
}
`
);
expect
(
cellText
).
not
.
toContain
(
project
.
nameWithNamespace
);
expect
(
cellText
).
toEqual
(
`
${
location
.
file
}
(line:
${
location
.
startLine
}
)`
);
});
it
(
'
should not display the vulnerability group/project locations for code with no line data
'
,
()
=>
{
const
{
id
,
project
,
location
}
=
newVulnerabilities
[
2
];
const
cellText
=
findCellText
(
`location-
${
id
}
`
);
expect
(
cellText
).
not
.
toContain
(
project
.
nameWithNamespace
);
expect
(
cellText
).
toEqual
(
location
.
file
);
});
it
(
'
should display the vulnerability report type
'
,
()
=>
{
...
...
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