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
88396383
Commit
88396383
authored
Apr 02, 2020
by
pburdette
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply code review suggestions
Apply recomended code review suggestions to clean up code.
parent
e483d560
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
48 deletions
+30
-48
app/assets/javascripts/ci_variable_list/store/getters.js
app/assets/javascripts/ci_variable_list/store/getters.js
+6
-9
app/assets/javascripts/ci_variable_list/store/utils.js
app/assets/javascripts/ci_variable_list/store/utils.js
+0
-11
spec/frontend/ci_variable_list/components/ci_enviroments_dropdown_spec.js
..._variable_list/components/ci_enviroments_dropdown_spec.js
+23
-18
spec/frontend/ci_variable_list/store/getters_spec.js
spec/frontend/ci_variable_list/store/getters_spec.js
+1
-1
spec/frontend/ci_variable_list/store/utils_spec.js
spec/frontend/ci_variable_list/store/utils_spec.js
+0
-9
No files found.
app/assets/javascripts/ci_variable_list/store/getters.js
View file @
88396383
import
{
extractEnvironmentScopes
}
from
'
./utils
'
;
/* eslint-disable import/prefer-default-export */
// Disabling import/prefer-default-export can be
// removed once a second getter is added to this file
import
{
uniq
}
from
'
lodash
'
;
export
const
joinedEnvironments
=
state
=>
{
if
(
state
.
variables
)
{
const
joined
=
state
.
environments
.
concat
(
extractEnvironmentScopes
(
state
.
variables
));
return
[...
new
Set
(
joined
)].
sort
();
}
return
null
;
const
scopesFromVariables
=
(
state
.
variables
||
[]).
map
(
variable
=>
variable
.
environment_scope
);
return
uniq
(
state
.
environments
.
concat
(
scopesFromVariables
)).
sort
();
};
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export
default
()
=>
{};
app/assets/javascripts/ci_variable_list/store/utils.js
View file @
88396383
...
...
@@ -41,14 +41,3 @@ export const prepareDataForApi = (variable, destroy = false) => {
};
export
const
prepareEnvironments
=
environments
=>
environments
.
map
(
e
=>
e
.
name
);
/**
* Extract environment_scope from any variables that were created using
* wildcard environment scope
* @param {Array} variables - Array of variable objects
* @returns {Array} - Array of variable enviroment scopes
*/
export
const
extractEnvironmentScopes
=
variables
=>
{
return
[...
new
Set
(
variables
.
map
(
variable
=>
variable
.
environment_scope
))];
};
spec/frontend/ci_variable_list/components/ci_enviroments_dropdown_spec.js
View file @
88396383
...
...
@@ -30,12 +30,9 @@ describe('Ci environments dropdown', () => {
const
findDropdownItemByIndex
=
index
=>
wrapper
.
findAll
(
GlDropdownItem
).
at
(
index
);
const
findActiveIconByIndex
=
index
=>
wrapper
.
findAll
(
GlIcon
).
at
(
index
);
beforeEach
(()
=>
{
createComponent
(
'
prod
'
);
});
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
describe
(
'
No enviroments found
'
,
()
=>
{
...
...
@@ -53,14 +50,23 @@ describe('Ci environments dropdown', () => {
});
});
describe
(
'
Enviroments found
'
,
()
=>
{
it
(
'
renders all enviroments when search term is empty
'
,
()
=>
{
describe
(
'
Search term is empty
'
,
()
=>
{
beforeEach
(
()
=>
{
createComponent
(
''
);
});
it
(
'
renders all enviroments when search term is empty
'
,
()
=>
{
expect
(
findAllDropdownItems
()).
toHaveLength
(
3
);
expect
(
findDropdownItemByIndex
(
0
).
text
()).
toBe
(
'
dev
'
);
expect
(
findDropdownItemByIndex
(
1
).
text
()).
toBe
(
'
prod
'
);
expect
(
findDropdownItemByIndex
(
2
).
text
()).
toBe
(
'
staging
'
);
});
});
describe
(
'
Enviroments found
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
(
'
prod
'
);
});
it
(
'
renders only the enviroment searched for
'
,
()
=>
{
expect
(
findAllDropdownItems
()).
toHaveLength
(
1
);
...
...
@@ -78,10 +84,8 @@ describe('Ci environments dropdown', () => {
});
it
(
'
should display active checkmark if active
'
,
()
=>
{
createComponent
(
'
dev
'
);
expect
(
findActiveIconByIndex
(
0
).
classes
(
'
invisible
'
)).
toBe
(
false
);
});
});
describe
(
'
Custom events
'
,
()
=>
{
it
(
'
should emit selectEnvironment if an environment is clicked
'
,
()
=>
{
...
...
@@ -95,4 +99,5 @@ describe('Ci environments dropdown', () => {
expect
(
wrapper
.
emitted
(
'
createClicked
'
)).
toEqual
([[
'
newscope
'
]]);
});
});
});
});
spec/frontend/ci_variable_list/store/getters_spec.js
View file @
88396383
...
...
@@ -3,7 +3,7 @@ import mockData from '../services/mock_data';
describe
(
'
Ci variable getters
'
,
()
=>
{
describe
(
'
joinedEnvironments
'
,
()
=>
{
it
(
'
should
return "on" when isShowingLabels is true
'
,
()
=>
{
it
(
'
should
join fetched enviroments with variable environment scopes
'
,
()
=>
{
const
state
=
{
environments
:
[
'
All (default)
'
,
'
staging
'
,
'
deployment
'
,
'
prod
'
],
variables
:
mockData
.
mockVariableScopes
,
...
...
spec/frontend/ci_variable_list/store/utils_spec.js
View file @
88396383
...
...
@@ -2,7 +2,6 @@ import {
prepareDataForDisplay
,
prepareEnvironments
,
prepareDataForApi
,
extractEnvironmentScopes
,
}
from
'
~/ci_variable_list/store/utils
'
;
import
mockData
from
'
../services/mock_data
'
;
...
...
@@ -47,12 +46,4 @@ describe('CI variables store utils', () => {
it
(
'
prepares environments for display
'
,
()
=>
{
expect
(
prepareEnvironments
(
mockData
.
mockEnvironments
)).
toStrictEqual
([
'
staging
'
,
'
production
'
]);
});
it
(
'
returns variable environment scopes with no duplicates
'
,
()
=>
{
expect
(
extractEnvironmentScopes
(
mockData
.
mockVariableScopes
)).
toStrictEqual
([
'
All (default)
'
,
'
staging
'
,
'
production
'
,
]);
});
});
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