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
56653aa5
Commit
56653aa5
authored
Aug 26, 2021
by
Alexander Turinske
Committed by
Natalia Tepluhina
Aug 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update network policy request
parent
1ba7aa96
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
11 deletions
+42
-11
ee/app/assets/javascripts/threat_monitoring/components/policies/policies_list.vue
...s/threat_monitoring/components/policies/policies_list.vue
+3
-1
ee/spec/frontend/threat_monitoring/components/policies/policies_list_spec.js
...reat_monitoring/components/policies/policies_list_spec.js
+39
-10
No files found.
ee/app/assets/javascripts/threat_monitoring/components/policies/policies_list.vue
View file @
56653aa5
...
...
@@ -81,7 +81,9 @@ export default {
},
error
:
createPolicyFetchError
,
skip
()
{
return
this
.
isLoadingEnvironments
||
!
this
.
shouldShowNetworkPolicies
;
return
(
!
this
.
hasEnvironment
||
this
.
isLoadingEnvironments
||
!
this
.
shouldShowNetworkPolicies
);
},
},
scanExecutionPolicies
:
{
...
...
ee/spec/frontend/threat_monitoring/components/policies/policies_list_spec.js
View file @
56653aa5
...
...
@@ -32,9 +32,10 @@ const environments = [
global_id
:
'
gid://gitlab/Environment/3
'
,
},
];
const
networkPoliciesSpy
=
networkPolicies
(
mockNetworkPoliciesResponse
);
const
scanExecutionPoliciesSpy
=
scanExecutionPolicies
(
mockScanExecutionPoliciesResponse
);
const
defaultRequestHandlers
=
{
networkPolicies
:
networkPolicies
(
mockNetworkPoliciesResponse
)
,
networkPolicies
:
networkPolicies
Spy
,
scanExecutionPolicies
:
scanExecutionPoliciesSpy
,
};
const
pendingHandler
=
jest
.
fn
(()
=>
new
Promise
(()
=>
{}));
...
...
@@ -45,13 +46,19 @@ describe('PoliciesList component', () => {
let
requestHandlers
;
const
factory
=
(
mountFn
=
mountExtended
)
=>
(
options
=
{})
=>
{
const
{
state
=
{},
handlers
,
...
wrapperOptions
}
=
options
;
store
=
createStore
();
const
{
state
,
handlers
,
...
wrapperOptions
}
=
options
;
Object
.
assign
(
store
.
state
.
networkPolicies
,
{
...
state
,
store
.
replaceState
({
...
store
.
state
,
threatMonitoring
:
{
...
store
.
state
.
threatMonitoring
,
environments
,
currentEnvironmentId
:
environments
[
0
].
id
,
...
state
.
threatMonitoring
,
},
});
store
.
state
.
threatMonitoring
.
environments
=
environments
;
store
.
state
.
threatMonitoring
.
currentEnvironmentId
=
environments
[
0
].
id
;
requestHandlers
=
{
...
defaultRequestHandlers
,
...
handlers
,
...
...
@@ -260,8 +267,7 @@ describe('PoliciesList component', () => {
describe
(
'
with allEnvironments enabled
'
,
()
=>
{
beforeEach
(()
=>
{
mountWrapper
();
wrapper
.
vm
.
$store
.
state
.
threatMonitoring
.
allEnvironments
=
true
;
mountWrapper
({
state
:
{
threatMonitoring
:
{
allEnvironments
:
true
}
}
});
});
it
(
'
renders environments column
'
,
()
=>
{
...
...
@@ -312,7 +318,26 @@ describe('PoliciesList component', () => {
});
});
describe
(
'
given no environement
'
,
()
=>
{
describe
(
'
given loading environment
'
,
()
=>
{
beforeEach
(()
=>
{
mountWrapper
({
propsData
:
{
hasEnvironment
:
true
,
},
state
:
{
threatMonitoring
:
{
isLoadingEnvironments
:
true
,
},
},
});
});
it
(
'
does not make a request for network policies
'
,
()
=>
{
expect
(
networkPoliciesSpy
).
not
.
toHaveBeenCalled
();
});
});
describe
(
'
given no environments
'
,
()
=>
{
beforeEach
(()
=>
{
mountWrapper
({
propsData
:
{
...
...
@@ -321,8 +346,12 @@ describe('PoliciesList component', () => {
});
});
it
(
'
does not make a request for network policies
'
,
()
=>
{
expect
(
networkPoliciesSpy
).
not
.
toHaveBeenCalled
();
});
it
(
'
does not render default network policies
'
,
()
=>
{
expect
(
findPolicyStatusCells
()).
toHaveLength
(
3
);
expect
(
findPolicyStatusCells
()).
toHaveLength
(
1
);
});
});
});
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