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
46a716d0
Commit
46a716d0
authored
Aug 20, 2021
by
Savas Vedova
Committed by
Brandon Labuschagne
Aug 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Normalize reportType filter for graphql query
parent
bf553406
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
7 deletions
+29
-7
ee/app/assets/javascripts/security_dashboard/components/pipeline/pipeline_findings.vue
...urity_dashboard/components/pipeline/pipeline_findings.vue
+10
-6
ee/spec/frontend/security_dashboard/components/pipeline/pipeline_findings_spec.js
...y_dashboard/components/pipeline/pipeline_findings_spec.js
+19
-1
No files found.
ee/app/assets/javascripts/security_dashboard/components/pipeline/pipeline_findings.vue
View file @
46a716d0
...
...
@@ -54,12 +54,8 @@ export default {
pipelineId
:
this
.
pipeline
.
iid
,
fullPath
:
this
.
projectFullPath
,
first
:
VULNERABILITIES_PER_PAGE
,
// Two issues here:
// 1. Severity filter, unlike vulnerabilities, need to be lower case.
// 2. Empty array returns an empty result, therefore we need to pass undefined in that case.
severity
:
this
.
filters
?.
severity
?.
length
?
this
.
filters
.
severity
.
map
((
s
)
=>
s
.
toLowerCase
())
:
undefined
,
reportType
:
this
.
normalizeForGraphQLQuery
(
'
reportType
'
),
severity
:
this
.
normalizeForGraphQLQuery
(
'
severity
'
),
};
},
update
:
({
project
})
=>
...
...
@@ -93,6 +89,14 @@ export default {
},
},
methods
:
{
// Two issues here:
// 1. Severity and reportType filters, unlike in vulnerabilities, need to be lower case.
// 2. Empty array returns an empty result, therefore we need to pass undefined in that case.
normalizeForGraphQLQuery
(
filterName
)
{
return
this
.
filters
?.[
filterName
]?.
length
?
this
.
filters
[
filterName
].
map
((
s
)
=>
s
.
toLowerCase
())
:
undefined
;
},
dismissError
()
{
this
.
errorLoadingFindings
=
false
;
},
...
...
ee/spec/frontend/security_dashboard/components/pipeline/pipeline_findings_spec.js
View file @
46a716d0
...
...
@@ -41,8 +41,9 @@ describe('Pipeline findings', () => {
});
};
const
createWrapperWithApollo
=
(
resolver
)
=>
{
const
createWrapperWithApollo
=
(
resolver
,
data
)
=>
{
return
createWrapper
({
...
data
,
apolloProvider
:
createMockApollo
([[
pipelineFindingsQuery
,
resolver
]]),
});
};
...
...
@@ -136,4 +137,21 @@ describe('Pipeline findings', () => {
expect
(
findAlert
().
exists
()).
toBe
(
true
);
});
});
describe
(
'
filtering
'
,
()
=>
{
it
.
each
([
'
reportType
'
,
'
severity
'
])(
`normalizes the GraphQL's query variable for the "%s" filter`
,
(
filterName
)
=>
{
const
filterValues
=
[
'
FOO
'
,
'
BAR
'
,
'
FOO_BAR
'
];
const
normalizedFilterValues
=
[
'
foo
'
,
'
bar
'
,
'
foo_bar
'
];
const
queryMock
=
jest
.
fn
().
mockResolvedValue
();
createWrapperWithApollo
(
queryMock
,
{
props
:
{
filters
:
{
[
filterName
]:
filterValues
}
}
});
expect
(
queryMock
.
mock
.
calls
[
0
][
0
]).
toMatchObject
({
[
filterName
]:
normalizedFilterValues
,
});
},
);
});
});
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