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
4075c2e6
Commit
4075c2e6
authored
Aug 04, 2020
by
Fernando
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests
* Add mutations, actions unit tests
parent
3b13c2b5
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
171 additions
and
7 deletions
+171
-7
ee/app/assets/javascripts/security_configuration/modules/configuration/actions.js
...s/security_configuration/modules/configuration/actions.js
+2
-4
ee/app/assets/javascripts/security_configuration/modules/configuration/index.js
...pts/security_configuration/modules/configuration/index.js
+10
-0
ee/app/assets/javascripts/security_configuration/modules/configuration/mutation_types.js
...ity_configuration/modules/configuration/mutation_types.js
+1
-1
ee/app/assets/javascripts/security_configuration/modules/configuration/mutations.js
...security_configuration/modules/configuration/mutations.js
+1
-1
ee/app/assets/javascripts/security_configuration/modules/configuration/state.js
...pts/security_configuration/modules/configuration/state.js
+1
-1
ee/spec/frontend/security_configuration/modules/configuration/actions_spec.js
...urity_configuration/modules/configuration/actions_spec.js
+114
-0
ee/spec/frontend/security_configuration/modules/configuration/mutation_spec.js
...rity_configuration/modules/configuration/mutation_spec.js
+42
-0
No files found.
ee/app/assets/javascripts/security_configuration/modules/configuration/actions.js
View file @
4075c2e6
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
__
}
from
'
~/locale
'
;
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
*
as
types
from
'
./mutation_types
'
;
import
*
as
types
from
'
./mutation_types
'
;
export
const
setSecurityConfigurationEndpoint
=
({
commit
},
endpoint
)
=>
export
const
setSecurityConfigurationEndpoint
=
({
commit
},
endpoint
)
=>
commit
(
types
.
SET_SECURITY_CONFIGURATION_ENDPOINT
,
endpoint
);
commit
(
types
.
SET_SECURITY_CONFIGURATION_ENDPOINT
,
endpoint
);
export
const
fetchSecurityConfiguration
=
({
commit
,
state
})
=>
{
export
const
fetchSecurityConfiguration
=
({
commit
,
state
})
=>
{
if
(
!
state
.
securityConfigurationPath
)
{
if
(
!
state
.
securityConfigurationPath
)
{
return
commit
(
types
.
RECEIVE_SECURITY_CONFIGURATION_ERROR
);
return
commit
(
types
.
RECEIVE_SECURITY_CONFIGURATION_ERROR
);
...
...
ee/app/assets/javascripts/security_configuration/modules/configuration/index.js
0 → 100644
View file @
4075c2e6
import
state
from
'
./state
'
;
import
mutations
from
'
./mutations
'
;
import
*
as
actions
from
'
./actions
'
;
export
default
{
namespaced
:
true
,
state
,
mutations
,
actions
,
};
ee/app/assets/javascripts/security_configuration/modules/configuration/mutation_types.js
View file @
4075c2e6
ee/app/assets/javascripts/security_configuration/modules/configuration/mutations.js
View file @
4075c2e6
...
@@ -9,7 +9,7 @@ export default {
...
@@ -9,7 +9,7 @@ export default {
},
},
[
types
.
RECEIVE_SECURITY_CONFIGURATION_SUCCESS
](
state
,
payload
)
{
[
types
.
RECEIVE_SECURITY_CONFIGURATION_SUCCESS
](
state
,
payload
)
{
state
.
isLoading
=
false
;
state
.
isLoading
=
false
;
state
.
pipelineJobs
=
payload
;
state
.
configuration
=
payload
;
},
},
[
types
.
RECEIVE_SECURITY_CONFIGURATION_ERROR
](
state
)
{
[
types
.
RECEIVE_SECURITY_CONFIGURATION_ERROR
](
state
)
{
state
.
isLoading
=
false
;
state
.
isLoading
=
false
;
...
...
ee/app/assets/javascripts/security_configuration/modules/configuration/state.js
View file @
4075c2e6
...
@@ -3,5 +3,5 @@ export default () => ({
...
@@ -3,5 +3,5 @@ export default () => ({
initialized
:
false
,
initialized
:
false
,
isLoading
:
false
,
isLoading
:
false
,
errorLoading
:
false
,
errorLoading
:
false
,
configuration
:
[]
,
configuration
:
{}
,
});
});
ee/spec/frontend/security_configuration/modules/configuration/actions_spec.js
0 → 100644
View file @
4075c2e6
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
createState
from
'
ee/security_configuration/modules/configuration/state
'
;
import
*
as
types
from
'
ee/security_configuration/modules/configuration/mutation_types
'
;
import
*
as
actions
from
'
ee/security_configuration/modules/configuration/actions
'
;
describe
(
'
security configuration module actions
'
,
()
=>
{
let
state
;
beforeEach
(()
=>
{
state
=
createState
();
});
describe
(
'
setSecurityConfigurationEndpoint
'
,
()
=>
{
const
securityConfigurationPath
=
123
;
it
(
'
should commit the SET_SECURITY_CONFIGURATION_ENDPOINT mutation
'
,
()
=>
{
testAction
(
actions
.
setSecurityConfigurationEndpoint
,
securityConfigurationPath
,
state
,
[
{
type
:
types
.
SET_SECURITY_CONFIGURATION_ENDPOINT
,
payload
:
securityConfigurationPath
,
},
],
[],
);
});
});
describe
(
'
fetchSecurityConfiguration
'
,
()
=>
{
let
mock
;
const
configuration
=
{};
beforeEach
(()
=>
{
state
.
securityConfigurationPath
=
`
${
TEST_HOST
}
/-/security/configuration.json`
;
mock
=
new
MockAdapter
(
axios
);
});
afterEach
(()
=>
{
mock
.
restore
();
});
describe
(
'
on success
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
state
.
securityConfigurationPath
).
replyOnce
(
200
,
configuration
);
});
it
(
'
should commit the request and success mutations
'
,
()
=>
{
testAction
(
actions
.
fetchSecurityConfiguration
,
{},
state
,
[
{
type
:
types
.
REQUEST_SECURITY_CONFIGURATION
},
{
type
:
types
.
RECEIVE_SECURITY_CONFIGURATION_SUCCESS
,
payload
:
configuration
,
},
],
[],
);
});
});
describe
(
'
without securityConfigurationPath set
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
state
.
securityConfigurationPath
).
replyOnce
(
200
,
configuration
);
});
it
(
'
should commit RECEIVE_SECURITY_CONFIGURATION_ERROR mutation
'
,
()
=>
{
state
.
securityConfigurationPath
=
''
;
testAction
(
actions
.
fetchSecurityConfiguration
,
{},
state
,
[
{
type
:
types
.
RECEIVE_SECURITY_CONFIGURATION_ERROR
,
},
],
[],
);
});
});
describe
(
'
with server error
'
,
()
=>
{
beforeEach
(()
=>
{
mock
.
onGet
(
state
.
securityConfigurationPath
).
replyOnce
(
404
);
});
it
(
'
should commit REQUEST_SECURITY_CONFIGURATION and RECEIVE_SECURITY_CONFIGURATION_ERRORmutation
'
,
()
=>
{
testAction
(
actions
.
fetchSecurityConfiguration
,
{},
state
,
[
{
type
:
types
.
REQUEST_SECURITY_CONFIGURATION
},
{
type
:
types
.
RECEIVE_SECURITY_CONFIGURATION_ERROR
,
},
],
[],
);
});
});
});
});
ee/spec/frontend/security_configuration/modules/configuration/mutation_spec.js
0 → 100644
View file @
4075c2e6
import
*
as
types
from
'
ee/security_configuration/modules/configuration/mutation_types
'
;
import
mutations
from
'
ee/security_configuration/modules/configuration/mutations
'
;
describe
(
'
security configuration module mutations
'
,
()
=>
{
let
state
;
beforeEach
(()
=>
{
state
=
{};
});
describe
(
'
SET_SECURITY_CONFIGURATION_ENDPOINT
'
,
()
=>
{
const
securityConfigurationPath
=
123
;
it
(
`should set the securityConfigurationPath to
${
securityConfigurationPath
}
`
,
()
=>
{
mutations
[
types
.
SET_SECURITY_CONFIGURATION_ENDPOINT
](
state
,
securityConfigurationPath
);
expect
(
state
.
securityConfigurationPath
).
toBe
(
securityConfigurationPath
);
});
});
describe
(
'
REQUEST_SECURITY_CONFIGURATION
'
,
()
=>
{
it
(
'
should set the isLoading to true
'
,
()
=>
{
mutations
[
types
.
REQUEST_SECURITY_CONFIGURATION
](
state
);
expect
(
state
.
isLoading
).
toBe
(
true
);
});
});
describe
(
'
RECEIVE_SECURITY_CONFIGURATION_SUCCESS
'
,
()
=>
{
it
(
'
should set the isLoading to false and configuration to the response object
'
,
()
=>
{
const
configuration
=
{};
mutations
[
types
.
RECEIVE_SECURITY_CONFIGURATION_SUCCESS
](
state
,
configuration
);
expect
(
state
.
isLoading
).
toBe
(
false
);
expect
(
state
.
configuration
).
toBe
(
configuration
);
});
});
describe
(
'
RECEIVE_SECURITY_CONFIGURATION_ERROR
'
,
()
=>
{
it
(
'
should set the isLoading to false
'
,
()
=>
{
mutations
[
types
.
RECEIVE_SECURITY_CONFIGURATION_ERROR
](
state
);
expect
(
state
.
isLoading
).
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