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
71bfccc6
Commit
71bfccc6
authored
Dec 06, 2019
by
Andrew Fontaine
Committed by
Kushal Pandya
Dec 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port Feature Flags Table Tests to VTU
Using vue test utils instead of raw mounting things for speed.
parent
aef85a4f
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
138 additions
and
127 deletions
+138
-127
ee/app/assets/javascripts/feature_flags/components/configure_feature_flags_modal.vue
...eature_flags/components/configure_feature_flags_modal.vue
+1
-1
ee/app/assets/javascripts/feature_flags/components/environments_dropdown.vue
...cripts/feature_flags/components/environments_dropdown.vue
+1
-1
ee/spec/frontend/feature_flags/components/configure_feature_flags_modal_spec.js
...re_flags/components/configure_feature_flags_modal_spec.js
+3
-2
ee/spec/frontend/feature_flags/components/edit_feature_flag_spec.js
...ontend/feature_flags/components/edit_feature_flag_spec.js
+2
-3
ee/spec/frontend/feature_flags/components/environments_dropdown_spec.js
...nd/feature_flags/components/environments_dropdown_spec.js
+26
-23
ee/spec/frontend/feature_flags/components/feature_flags_spec.js
...c/frontend/feature_flags/components/feature_flags_spec.js
+81
-68
ee/spec/frontend/feature_flags/components/form_spec.js
ee/spec/frontend/feature_flags/components/form_spec.js
+10
-12
ee/spec/frontend/feature_flags/components/new_feature_flag_spec.js
...rontend/feature_flags/components/new_feature_flag_spec.js
+14
-17
No files found.
ee/app/assets/javascripts/feature_flags/components/configure_feature_flags_modal.vue
View file @
71bfccc6
...
@@ -140,7 +140,7 @@ export default {
...
@@ -140,7 +140,7 @@ export default {
v-if=
"canUserRotateToken"
v-if=
"canUserRotateToken"
v-gl-tooltip
.
hover
v-gl-tooltip
.
hover
:title=
"$options.regenerateInstanceIdTooltip"
:title=
"$options.regenerateInstanceIdTooltip"
class=
"input-group-text
js-ff-rotate-token-button
"
class=
"input-group-text"
@
click=
"rotateToken"
@
click=
"rotateToken"
>
>
<icon
name=
"retry"
/>
<icon
name=
"retry"
/>
...
...
ee/app/assets/javascripts/feature_flags/components/environments_dropdown.vue
View file @
71bfccc6
...
@@ -175,7 +175,7 @@ export default {
...
@@ -175,7 +175,7 @@ export default {
<input
<input
type=
"text"
type=
"text"
class=
"
js-env-input form-control pl-4
"
class=
"
form-control pl-4 js-env-input
"
:aria-label=
"placeholder"
:aria-label=
"placeholder"
:value=
"filter"
:value=
"filter"
:placeholder=
"placeholder"
:placeholder=
"placeholder"
...
...
ee/spec/frontend/feature_flags/components/configure_feature_flags_modal_spec.js
View file @
71bfccc6
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
component
from
'
ee/feature_flags/components/configure_feature_flags_modal.vue
'
;
import
component
from
'
ee/feature_flags/components/configure_feature_flags_modal.vue
'
;
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
...
@@ -31,8 +32,8 @@ describe('Configure Feature Flags Modal', () => {
...
@@ -31,8 +32,8 @@ describe('Configure Feature Flags Modal', () => {
describe
(
'
rotate token
'
,
()
=>
{
describe
(
'
rotate token
'
,
()
=>
{
it
(
'
should emit a `token` event on click
'
,
()
=>
{
it
(
'
should emit a `token` event on click
'
,
()
=>
{
wrapper
.
find
(
'
.js-ff-rotate-token-button
'
).
trigger
(
'
click
'
);
wrapper
.
find
(
GlButton
).
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
emitted
(
'
token
'
)).
not
.
toBeEmpty
(
);
expect
(
wrapper
.
emitted
(
'
token
'
)).
toEqual
([[]]
);
});
});
it
(
'
should display an error if there is a rotate error
'
,
()
=>
{
it
(
'
should display an error if there is a rotate error
'
,
()
=>
{
...
...
ee/spec/frontend/feature_flags/components/edit_feature_flag_spec.js
View file @
71bfccc6
...
@@ -77,13 +77,12 @@ describe('Edit feature flag form', () => {
...
@@ -77,13 +77,12 @@ describe('Edit feature flag form', () => {
});
});
describe
(
'
with error
'
,
()
=>
{
describe
(
'
with error
'
,
()
=>
{
it
(
'
should render the error
'
,
done
=>
{
it
(
'
should render the error
'
,
()
=>
{
store
.
dispatch
(
'
edit/receiveUpdateFeatureFlagError
'
,
{
message
:
[
'
The name is required
'
]
});
store
.
dispatch
(
'
edit/receiveUpdateFeatureFlagError
'
,
{
message
:
[
'
The name is required
'
]
});
wrapper
.
vm
.
$nextTick
(()
=>
{
return
wrapper
.
vm
.
$nextTick
(()
=>
{
expect
(
wrapper
.
find
(
'
.alert-danger
'
).
exists
()).
toEqual
(
true
);
expect
(
wrapper
.
find
(
'
.alert-danger
'
).
exists
()).
toEqual
(
true
);
expect
(
wrapper
.
find
(
'
.alert-danger
'
).
text
()).
toContain
(
'
The name is required
'
);
expect
(
wrapper
.
find
(
'
.alert-danger
'
).
text
()).
toContain
(
'
The name is required
'
);
done
();
});
});
});
});
});
});
...
...
ee/spec/frontend/feature_flags/components/environments_dropdown_spec.js
View file @
71bfccc6
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
{
createLocalVue
,
m
ount
}
from
'
@vue/test-utils
'
;
import
{
createLocalVue
,
shallowM
ount
}
from
'
@vue/test-utils
'
;
import
{
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlLoadingIcon
,
GlButton
}
from
'
@gitlab/ui
'
;
import
EnvironmentsDropdown
from
'
ee/feature_flags/components/environments_dropdown.vue
'
;
import
EnvironmentsDropdown
from
'
ee/feature_flags/components/environments_dropdown.vue
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
...
@@ -12,7 +12,7 @@ describe('Feature flags > Environments dropdown ', () => {
...
@@ -12,7 +12,7 @@ describe('Feature flags > Environments dropdown ', () => {
let
mock
;
let
mock
;
const
factory
=
props
=>
{
const
factory
=
props
=>
{
wrapper
=
mount
(
localVue
.
extend
(
EnvironmentsDropdown
)
,
{
wrapper
=
shallowMount
(
EnvironmentsDropdown
,
{
localVue
,
localVue
,
propsData
:
{
propsData
:
{
endpoint
:
`
${
TEST_HOST
}
/environments.json'`
,
endpoint
:
`
${
TEST_HOST
}
/environments.json'`
,
...
@@ -78,20 +78,19 @@ describe('Feature flags > Environments dropdown ', () => {
...
@@ -78,20 +78,19 @@ describe('Feature flags > Environments dropdown ', () => {
expect
(
wrapper
.
vm
.
showSuggestions
).
toEqual
(
true
);
expect
(
wrapper
.
vm
.
showSuggestions
).
toEqual
(
true
);
});
});
it
(
'
emits even when a suggestion is clicked
'
,
()
=>
{
it
(
'
emits event when a suggestion is clicked
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
$emit
'
);
const
button
=
wrapper
.
findAll
(
GlButton
)
.
filter
(
b
=>
b
.
text
()
===
'
production
'
)
.
at
(
0
);
button
.
vm
.
$emit
(
'
click
'
);
wrapper
.
find
(
'
ul button
'
).
trigger
(
'
click
'
);
expect
(
wrapper
.
emitted
(
'
selectEnvironment
'
)).
toEqual
([[
'
production
'
]]);
expect
(
wrapper
.
vm
.
$emit
).
toHaveBeenCalledWith
(
'
selectEnvironment
'
,
'
production
'
);
});
});
});
});
});
});
describe
(
'
on click clear button
'
,
()
=>
{
describe
(
'
on click clear button
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
wrapper
.
find
(
'
.js-clear-search-input
'
).
trigger
(
'
click
'
);
wrapper
.
find
(
GlButton
).
vm
.
$emit
(
'
click
'
);
});
});
it
(
'
resets filter value
'
,
()
=>
{
it
(
'
resets filter value
'
,
()
=>
{
...
@@ -102,6 +101,8 @@ describe('Feature flags > Environments dropdown ', () => {
...
@@ -102,6 +101,8 @@ describe('Feature flags > Environments dropdown ', () => {
expect
(
wrapper
.
vm
.
showSuggestions
).
toEqual
(
false
);
expect
(
wrapper
.
vm
.
showSuggestions
).
toEqual
(
false
);
});
});
});
});
});
});
describe
(
'
on click create button
'
,
()
=>
{
describe
(
'
on click create button
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
...
@@ -115,10 +116,12 @@ describe('Feature flags > Environments dropdown ', () => {
...
@@ -115,10 +116,12 @@ describe('Feature flags > Environments dropdown ', () => {
});
});
it
(
'
emits create event
'
,
()
=>
{
it
(
'
emits create event
'
,
()
=>
{
jest
.
spyOn
(
wrapper
.
vm
,
'
$emit
'
);
wrapper
wrapper
.
find
(
'
.js-create-button
'
).
trigger
(
'
click
'
);
.
findAll
(
GlButton
)
.
at
(
1
)
.
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
vm
.
$emit
).
toHaveBeenCalledWith
(
'
createClicked
'
,
'
production
'
);
expect
(
wrapper
.
emitted
(
'
createClicked
'
)).
toEqual
([[
'
production
'
]]
);
});
});
});
});
});
});
ee/spec/frontend/feature_flags/components/feature_flags_spec.js
View file @
71bfccc6
import
Vue
from
'
vue
'
;
import
{
createLocalVue
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
featureFlagsComponent
from
'
ee/feature_flags/components/feature_flags.vue
'
;
import
{
GlEmptyState
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
FeatureFlagsComponent
from
'
ee/feature_flags/components/feature_flags.vue
'
;
import
{
trimText
}
from
'
helpers/text_helper
'
;
import
FeatureFlagsTable
from
'
ee/feature_flags/components/feature_flags_table.vue
'
;
import
ConfigureFeatureFlagsModal
from
'
ee/feature_flags/components/configure_feature_flags_modal.vue
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
import
NavigationTabs
from
'
~/vue_shared/components/navigation_tabs
'
;
import
TablePagination
from
'
~/vue_shared/components/pagination/table_pagination.vue
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
getRequestData
}
from
'
../mock_data
'
;
import
{
getRequestData
}
from
'
../mock_data
'
;
const
localVue
=
createLocalVue
();
describe
(
'
Feature flags
'
,
()
=>
{
describe
(
'
Feature flags
'
,
()
=>
{
const
mockData
=
{
const
mockData
=
{
endpoint
:
`
${
TEST_HOST
}
/endpoint.json`
,
endpoint
:
`
${
TEST_HOST
}
/endpoint.json`
,
...
@@ -21,23 +26,31 @@ describe('Feature flags', () => {
...
@@ -21,23 +26,31 @@ describe('Feature flags', () => {
newFeatureFlagPath
:
'
feature-flags/new
'
,
newFeatureFlagPath
:
'
feature-flags/new
'
,
};
};
let
FeatureFlagsComponent
;
let
wrapper
;
let
component
;
let
mock
;
let
mock
;
const
factory
=
(
propsData
=
mockData
)
=>
{
wrapper
=
shallowMount
(
FeatureFlagsComponent
,
{
localVue
,
propsData
,
sync
:
false
,
});
};
const
configureButton
=
()
=>
wrapper
.
find
(
'
.js-ff-configure
'
);
const
newButton
=
()
=>
wrapper
.
find
(
'
.js-ff-new
'
);
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
=
new
MockAdapter
(
axios
);
FeatureFlagsComponent
=
Vue
.
extend
(
featureFlagsComponent
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
mock
.
restore
();
mock
.
restore
();
component
.
$
destroy
();
wrapper
.
destroy
();
});
});
describe
(
'
without permissions
'
,
()
=>
{
describe
(
'
without permissions
'
,
()
=>
{
const
props
=
{
const
props
Data
=
{
endpoint
:
`
${
TEST_HOST
}
/endpoint.json`
,
endpoint
:
`
${
TEST_HOST
}
/endpoint.json`
,
csrfToken
:
'
testToken
'
,
csrfToken
:
'
testToken
'
,
errorStateSvgPath
:
'
/assets/illustrations/feature_flag.svg
'
,
errorStateSvgPath
:
'
/assets/illustrations/feature_flag.svg
'
,
...
@@ -54,7 +67,7 @@ describe('Feature flags', () => {
...
@@ -54,7 +67,7 @@ describe('Feature flags', () => {
.
onGet
(
`
${
TEST_HOST
}
/endpoint.json`
,
{
params
:
{
scope
:
'
all
'
,
page
:
'
1
'
}
})
.
onGet
(
`
${
TEST_HOST
}
/endpoint.json`
,
{
params
:
{
scope
:
'
all
'
,
page
:
'
1
'
}
})
.
reply
(
200
,
getRequestData
,
{});
.
reply
(
200
,
getRequestData
,
{});
component
=
mountComponent
(
FeatureFlagsComponent
,
props
);
factory
(
propsData
);
setImmediate
(()
=>
{
setImmediate
(()
=>
{
done
();
done
();
...
@@ -62,11 +75,11 @@ describe('Feature flags', () => {
...
@@ -62,11 +75,11 @@ describe('Feature flags', () => {
});
});
it
(
'
does not render configure button
'
,
()
=>
{
it
(
'
does not render configure button
'
,
()
=>
{
expect
(
co
mponent
.
$el
.
querySelector
(
'
.js-ff-configure
'
)).
toBeNull
(
);
expect
(
co
nfigureButton
().
exists
()).
toBe
(
false
);
});
});
it
(
'
does not render new feature flag button
'
,
()
=>
{
it
(
'
does not render new feature flag button
'
,
()
=>
{
expect
(
component
.
$el
.
querySelector
(
'
.js-ff-new
'
)).
toBeNull
(
);
expect
(
newButton
().
exists
()).
toBe
(
false
);
});
});
});
});
...
@@ -76,19 +89,19 @@ describe('Feature flags', () => {
...
@@ -76,19 +89,19 @@ describe('Feature flags', () => {
.
onGet
(
`
${
TEST_HOST
}
/endpoint.json`
,
{
params
:
{
scope
:
'
all
'
,
page
:
'
1
'
}
})
.
onGet
(
`
${
TEST_HOST
}
/endpoint.json`
,
{
params
:
{
scope
:
'
all
'
,
page
:
'
1
'
}
})
.
replyOnce
(
200
,
getRequestData
,
{});
.
replyOnce
(
200
,
getRequestData
,
{});
component
=
mountComponent
(
FeatureFlagsComponent
,
mockData
);
factory
(
);
const
loadingElement
=
component
.
$el
.
querySelector
(
'
.js-loading-state
'
);
const
loadingElement
=
wrapper
.
find
(
GlLoadingIcon
);
expect
(
loadingElement
).
not
.
toBeNull
();
expect
(
loadingElement
.
exists
()).
toBe
(
true
);
expect
(
loadingElement
.
querySelector
(
'
span
'
).
getAttribute
(
'
aria-label
'
)).
toEqual
(
expect
(
loadingElement
.
props
(
'
label
'
)).
toEqual
(
'
Loading feature flags
'
);
'
Loading feature flags
'
,
);
});
});
});
});
describe
(
'
successful request
'
,
()
=>
{
describe
(
'
successful request
'
,
()
=>
{
describe
(
'
without feature flags
'
,
()
=>
{
describe
(
'
without feature flags
'
,
()
=>
{
let
emptyState
;
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
mock
.
onGet
(
mockData
.
endpoint
,
{
params
:
{
scope
:
'
all
'
,
page
:
'
1
'
}
}).
replyOnce
(
mock
.
onGet
(
mockData
.
endpoint
,
{
params
:
{
scope
:
'
all
'
,
page
:
'
1
'
}
}).
replyOnce
(
200
,
200
,
...
@@ -103,55 +116,48 @@ describe('Feature flags', () => {
...
@@ -103,55 +116,48 @@ describe('Feature flags', () => {
{},
{},
);
);
component
=
mountComponent
(
FeatureFlagsComponent
,
mockData
);
factory
(
);
setImmediate
(()
=>
{
setImmediate
(()
=>
{
emptyState
=
wrapper
.
find
(
GlEmptyState
);
done
();
done
();
});
});
});
});
it
(
'
should render the empty state
'
,
()
=>
{
it
(
'
should render the empty state
'
,
()
=>
{
expect
(
component
.
$el
.
querySelector
(
'
.js-feature-flags-empty-state
'
)).
not
.
toBeNull
(
);
expect
(
wrapper
.
find
(
GlEmptyState
).
exists
()).
toBe
(
true
);
});
});
it
(
'
renders configure button
'
,
()
=>
{
it
(
'
renders configure button
'
,
()
=>
{
expect
(
co
mponent
.
$el
.
querySelector
(
'
.js-ff-configure
'
)).
not
.
toBeNull
(
);
expect
(
co
nfigureButton
().
exists
()).
toBe
(
true
);
});
});
it
(
'
renders new feature flag button
'
,
()
=>
{
it
(
'
renders new feature flag button
'
,
()
=>
{
expect
(
component
.
$el
.
querySelector
(
'
.js-ff-new
'
)).
not
.
toBeNull
(
);
expect
(
newButton
().
exists
()).
toBe
(
true
);
});
});
describe
(
'
in all tab
'
,
()
=>
{
describe
(
'
in all tab
'
,
()
=>
{
it
(
'
renders generic title
'
,
()
=>
{
it
(
'
renders generic title
'
,
()
=>
{
expect
(
expect
(
emptyState
.
props
(
'
title
'
)).
toEqual
(
'
Get started with feature flags
'
);
component
.
$el
.
querySelector
(
'
.js-feature-flags-empty-state h4
'
).
textContent
.
trim
(),
).
toEqual
(
'
Get started with feature flags
'
);
});
});
});
});
describe
(
'
in disabled tab
'
,
()
=>
{
describe
(
'
in disabled tab
'
,
()
=>
{
it
(
'
renders disabled title
'
,
done
=>
{
it
(
'
renders disabled title
'
,
()
=>
{
component
.
scope
=
'
disabled
'
;
wrapper
.
setData
({
scope
:
'
disabled
'
})
;
Vue
.
nextTick
(()
=>
{
return
localVue
.
nextTick
(()
=>
{
expect
(
expect
(
emptyState
.
props
(
'
title
'
)).
toEqual
(
'
There are no inactive feature flags
'
);
component
.
$el
.
querySelector
(
'
.js-feature-flags-empty-state h4
'
).
textContent
.
trim
(),
).
toEqual
(
'
There are no inactive feature flags
'
);
done
();
});
});
});
});
});
});
describe
(
'
in enabled tab
'
,
()
=>
{
describe
(
'
in enabled tab
'
,
()
=>
{
it
(
'
renders enabled title
'
,
done
=>
{
it
(
'
renders enabled title
'
,
()
=>
{
component
.
scope
=
'
enabled
'
;
wrapper
.
setData
({
scope
:
'
enabled
'
})
;
Vue
.
nextTick
(()
=>
{
localVue
.
nextTick
(()
=>
{
expect
(
expect
(
emptyState
.
props
(
'
title
'
)).
toEqual
(
'
There are no active feature flags
'
);
component
.
$el
.
querySelector
(
'
.js-feature-flags-empty-state h4
'
).
textContent
.
trim
(),
).
toEqual
(
'
There are no active feature flags
'
);
done
();
});
});
});
});
});
});
...
@@ -170,51 +176,53 @@ describe('Feature flags', () => {
...
@@ -170,51 +176,53 @@ describe('Feature flags', () => {
'
X-Total-Pages
'
:
'
5
'
,
'
X-Total-Pages
'
:
'
5
'
,
});
});
component
=
mountComponent
(
FeatureFlagsComponent
,
mockData
);
factory
(
);
setImmediate
(()
=>
{
setImmediate
(()
=>
{
done
();
done
();
});
});
});
});
it
(
'
should render a table with feature flags
'
,
()
=>
{
it
(
'
should render a table with feature flags
'
,
()
=>
{
expect
(
component
.
$el
.
querySelectorAll
(
'
.js-feature-flag-table
'
)).
not
.
toBeNull
();
const
table
=
wrapper
.
find
(
FeatureFlagsTable
);
expect
(
component
.
$el
.
querySelector
(
'
.feature-flag-name
'
).
textContent
.
trim
()).
toEqual
(
expect
(
wrapper
.
find
(
FeatureFlagsTable
).
exists
()).
toBe
(
true
);
getRequestData
.
feature_flags
[
0
].
name
,
expect
(
table
.
props
(
'
featureFlags
'
)).
toEqual
(
);
expect
.
arrayContaining
([
expect
.
objectContaining
({
expect
(
component
.
$el
.
querySelector
(
'
.feature-flag-description
'
).
textContent
.
trim
()).
toEqual
(
name
:
getRequestData
.
feature_flags
[
0
].
name
,
getRequestData
.
feature_flags
[
0
].
description
,
description
:
getRequestData
.
feature_flags
[
0
].
description
,
}),
]),
);
);
});
});
it
(
'
renders configure button
'
,
()
=>
{
it
(
'
renders configure button
'
,
()
=>
{
expect
(
co
mponent
.
$el
.
querySelector
(
'
.js-ff-configure
'
)).
not
.
toBeNull
(
);
expect
(
co
nfigureButton
().
exists
()).
toBe
(
true
);
});
});
it
(
'
renders new feature flag button
'
,
()
=>
{
it
(
'
renders new feature flag button
'
,
()
=>
{
expect
(
component
.
$el
.
querySelector
(
'
.js-ff-new
'
)).
not
.
toBeNull
(
);
expect
(
newButton
().
exists
()).
toBe
(
true
);
});
});
describe
(
'
pagination
'
,
()
=>
{
describe
(
'
pagination
'
,
()
=>
{
it
(
'
should render pagination
'
,
()
=>
{
it
(
'
should render pagination
'
,
()
=>
{
expect
(
component
.
$el
.
querySelectorAll
(
'
.gl-pagination
'
)).
not
.
toBeNull
(
);
expect
(
wrapper
.
find
(
TablePagination
).
exists
()).
toBe
(
true
);
});
});
it
(
'
should make an API request when page is clicked
'
,
()
=>
{
it
(
'
should make an API request when page is clicked
'
,
()
=>
{
jest
.
spyOn
(
component
,
'
updateFeatureFlagOptions
'
);
jest
.
spyOn
(
wrapper
.
vm
,
'
updateFeatureFlagOptions
'
);
component
.
$el
.
querySelector
(
'
.gl-pagination li:nth-child(5) .page-link
'
).
click
(
);
wrapper
.
find
(
TablePagination
).
vm
.
change
(
4
);
expect
(
component
.
updateFeatureFlagOptions
).
toHaveBeenCalledWith
({
expect
(
wrapper
.
vm
.
updateFeatureFlagOptions
).
toHaveBeenCalledWith
({
scope
:
'
all
'
,
scope
:
'
all
'
,
page
:
'
4
'
,
page
:
'
4
'
,
});
});
});
});
it
(
'
should make an API request when using tabs
'
,
()
=>
{
it
(
'
should make an API request when using tabs
'
,
()
=>
{
jest
.
spyOn
(
component
,
'
updateFeatureFlagOptions
'
);
jest
.
spyOn
(
wrapper
.
vm
,
'
updateFeatureFlagOptions
'
);
component
.
$el
.
querySelector
(
'
.js-featureflags-tab-enabled
'
).
click
(
);
wrapper
.
find
(
NavigationTabs
).
vm
.
$emit
(
'
onChangeTab
'
,
'
enabled
'
);
expect
(
component
.
updateFeatureFlagOptions
).
toHaveBeenCalledWith
({
expect
(
wrapper
.
vm
.
updateFeatureFlagOptions
).
toHaveBeenCalledWith
({
scope
:
'
enabled
'
,
scope
:
'
enabled
'
,
page
:
'
1
'
,
page
:
'
1
'
,
});
});
...
@@ -227,7 +235,7 @@ describe('Feature flags', () => {
...
@@ -227,7 +235,7 @@ describe('Feature flags', () => {
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
mock
.
onGet
(
mockData
.
endpoint
,
{
params
:
{
scope
:
'
all
'
,
page
:
'
1
'
}
}).
replyOnce
(
500
,
{});
mock
.
onGet
(
mockData
.
endpoint
,
{
params
:
{
scope
:
'
all
'
,
page
:
'
1
'
}
}).
replyOnce
(
500
,
{});
component
=
mountComponent
(
FeatureFlagsComponent
,
mockData
);
factory
(
);
setImmediate
(()
=>
{
setImmediate
(()
=>
{
done
();
done
();
...
@@ -235,23 +243,28 @@ describe('Feature flags', () => {
...
@@ -235,23 +243,28 @@ describe('Feature flags', () => {
});
});
it
(
'
should render error state
'
,
()
=>
{
it
(
'
should render error state
'
,
()
=>
{
expect
(
trimText
(
component
.
$el
.
querySelector
(
'
.empty-state
'
).
textContent
)).
toContain
(
const
emptyState
=
wrapper
.
find
(
GlEmptyState
);
'
There was an error fetching the feature flags. Try again in a few moments or contact your support team.
'
,
expect
(
emptyState
.
props
(
'
title
'
)).
toEqual
(
'
There was an error fetching the feature flags.
'
);
expect
(
emptyState
.
props
(
'
description
'
)).
toEqual
(
'
Try again in a few moments or contact your support team.
'
,
);
);
});
});
it
(
'
renders configure button
'
,
()
=>
{
it
(
'
renders configure button
'
,
()
=>
{
expect
(
co
mponent
.
$el
.
querySelector
(
'
.js-ff-configure
'
)).
not
.
toBeNull
(
);
expect
(
co
nfigureButton
().
exists
()).
toBe
(
true
);
});
});
it
(
'
renders new feature flag button
'
,
()
=>
{
it
(
'
renders new feature flag button
'
,
()
=>
{
expect
(
component
.
$el
.
querySelector
(
'
.js-ff-new
'
)).
not
.
toBeNull
(
);
expect
(
newButton
().
exists
()).
toBe
(
true
);
});
});
});
});
describe
(
'
rotate instance id
'
,
()
=>
{
describe
(
'
rotate instance id
'
,
()
=>
{
beforeEach
(
done
=>
{
beforeEach
(
done
=>
{
component
=
mountComponent
(
FeatureFlagsComponent
,
mockData
);
mock
.
onGet
(
`
${
TEST_HOST
}
/endpoint.json`
,
{
params
:
{
scope
:
'
all
'
,
page
:
'
1
'
}
})
.
reply
(
200
,
getRequestData
,
{});
factory
();
setImmediate
(()
=>
{
setImmediate
(()
=>
{
done
();
done
();
...
@@ -259,9 +272,9 @@ describe('Feature flags', () => {
...
@@ -259,9 +272,9 @@ describe('Feature flags', () => {
});
});
it
(
'
should fire the rotate action when a `token` event is received
'
,
()
=>
{
it
(
'
should fire the rotate action when a `token` event is received
'
,
()
=>
{
const
actionSpy
=
jest
.
spyOn
(
component
,
'
rotateInstanceId
'
);
const
actionSpy
=
jest
.
spyOn
(
wrapper
.
vm
,
'
rotateInstanceId
'
);
const
[
modal
]
=
component
.
$children
;
const
modal
=
wrapper
.
find
(
ConfigureFeatureFlagsModal
)
;
modal
.
$emit
(
'
token
'
);
modal
.
vm
.
$emit
(
'
token
'
);
expect
(
actionSpy
).
toHaveBeenCalled
();
expect
(
actionSpy
).
toHaveBeenCalled
();
});
});
...
...
ee/spec/frontend/feature_flags/components/form_spec.js
View file @
71bfccc6
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
{
createLocalVue
,
m
ount
}
from
'
@vue/test-utils
'
;
import
{
createLocalVue
,
shallowM
ount
}
from
'
@vue/test-utils
'
;
import
{
GlFormTextarea
,
GlFormCheckbox
}
from
'
@gitlab/ui
'
;
import
{
GlFormTextarea
,
GlFormCheckbox
}
from
'
@gitlab/ui
'
;
import
Form
from
'
ee/feature_flags/components/form.vue
'
;
import
Form
from
'
ee/feature_flags/components/form.vue
'
;
import
EnvironmentsDropdown
from
'
ee/feature_flags/components/environments_dropdown.vue
'
;
import
EnvironmentsDropdown
from
'
ee/feature_flags/components/environments_dropdown.vue
'
;
...
@@ -33,7 +33,7 @@ describe('feature flag form', () => {
...
@@ -33,7 +33,7 @@ describe('feature flag form', () => {
const
factory
=
(
props
=
{})
=>
{
const
factory
=
(
props
=
{})
=>
{
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
wrapper
=
mount
(
localVue
.
extend
(
Form
)
,
{
wrapper
=
shallowMount
(
Form
,
{
localVue
,
localVue
,
propsData
:
props
,
propsData
:
props
,
provide
:
{
provide
:
{
...
@@ -183,7 +183,7 @@ describe('feature flag form', () => {
...
@@ -183,7 +183,7 @@ describe('feature flag form', () => {
describe
(
'
deleting an existing scope
'
,
()
=>
{
describe
(
'
deleting an existing scope
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
wrapper
.
find
(
'
.js-delete-scope
'
).
trigger
(
'
click
'
);
wrapper
.
find
(
'
.js-delete-scope
'
).
vm
.
$emit
(
'
click
'
);
});
});
it
(
'
should add `shouldBeDestroyed` key the clicked scope
'
,
()
=>
{
it
(
'
should add `shouldBeDestroyed` key the clicked scope
'
,
()
=>
{
...
@@ -218,7 +218,7 @@ describe('feature flag form', () => {
...
@@ -218,7 +218,7 @@ describe('feature flag form', () => {
],
],
});
});
wrapper
.
find
(
'
.js-delete-scope
'
).
trigger
(
'
click
'
);
wrapper
.
find
(
'
.js-delete-scope
'
).
vm
.
$emit
(
'
click
'
);
expect
(
wrapper
.
vm
.
formScopes
).
toEqual
([]);
expect
(
wrapper
.
vm
.
formScopes
).
toEqual
([]);
});
});
...
@@ -280,7 +280,7 @@ describe('feature flag form', () => {
...
@@ -280,7 +280,7 @@ describe('feature flag form', () => {
.
setSelected
();
.
setSelected
();
};
};
beforeEach
(
done
=>
{
beforeEach
(
()
=>
{
factory
({
factory
({
...
requiredProps
,
...
requiredProps
,
name
:
'
feature_flag_1
'
,
name
:
'
feature_flag_1
'
,
...
@@ -300,10 +300,10 @@ describe('feature flag form', () => {
...
@@ -300,10 +300,10 @@ describe('feature flag form', () => {
],
],
});
});
wrapper
.
vm
.
$nextTick
(
done
,
done
.
fail
);
return
wrapper
.
vm
.
$nextTick
(
);
});
});
it
(
'
should emit handleSubmit with the updated data
'
,
done
=>
{
it
(
'
should emit handleSubmit with the updated data
'
,
()
=>
{
wrapper
.
find
(
'
#feature-flag-name
'
).
setValue
(
'
feature_flag_2
'
);
wrapper
.
find
(
'
#feature-flag-name
'
).
setValue
(
'
feature_flag_2
'
);
wrapper
wrapper
...
@@ -318,7 +318,7 @@ describe('feature flag form', () => {
...
@@ -318,7 +318,7 @@ describe('feature flag form', () => {
wrapper
.
find
(
ToggleButton
).
vm
.
$emit
(
'
change
'
,
true
);
wrapper
.
find
(
ToggleButton
).
vm
.
$emit
(
'
change
'
,
true
);
wrapper
.
vm
return
wrapper
.
vm
.
$nextTick
()
.
$nextTick
()
.
then
(()
=>
{
.
then
(()
=>
{
...
@@ -333,7 +333,7 @@ describe('feature flag form', () => {
...
@@ -333,7 +333,7 @@ describe('feature flag form', () => {
return
wrapper
.
vm
.
$nextTick
();
return
wrapper
.
vm
.
$nextTick
();
})
})
.
then
(()
=>
{
.
then
(()
=>
{
wrapper
.
find
({
ref
:
'
submitButton
'
}).
trigger
(
'
click
'
);
wrapper
.
find
({
ref
:
'
submitButton
'
}).
vm
.
$emit
(
'
click
'
);
const
data
=
wrapper
.
emitted
().
handleSubmit
[
0
][
0
];
const
data
=
wrapper
.
emitted
().
handleSubmit
[
0
][
0
];
...
@@ -373,9 +373,7 @@ describe('feature flag form', () => {
...
@@ -373,9 +373,7 @@ describe('feature flag form', () => {
rolloutUserIds
:
''
,
rolloutUserIds
:
''
,
},
},
]);
]);
})
});
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
});
});
...
...
ee/spec/frontend/feature_flags/components/new_feature_flag_spec.js
View file @
71bfccc6
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
Vue
from
'
vue
'
;
import
{
createLocalVue
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
createLocalVue
,
mount
}
from
'
@vue/test-utils
'
;
import
Form
from
'
ee/feature_flags/components/form.vue
'
;
import
Form
from
'
ee/feature_flags/components/form.vue
'
;
import
newModule
from
'
ee/feature_flags/store/modules/new
'
;
import
newModule
from
'
ee/feature_flags/store/modules/new
'
;
import
NewFeatureFlag
from
'
ee/feature_flags/components/new_feature_flag.vue
'
;
import
NewFeatureFlag
from
'
ee/feature_flags/components/new_feature_flag.vue
'
;
...
@@ -19,7 +18,7 @@ describe('New feature flag form', () => {
...
@@ -19,7 +18,7 @@ describe('New feature flag form', () => {
});
});
const
factory
=
()
=>
{
const
factory
=
()
=>
{
wrapper
=
mount
(
localVue
.
extend
(
NewFeatureFlag
)
,
{
wrapper
=
shallowMount
(
NewFeatureFlag
,
{
localVue
,
localVue
,
propsData
:
{
propsData
:
{
endpoint
:
'
feature_flags.json
'
,
endpoint
:
'
feature_flags.json
'
,
...
@@ -40,12 +39,11 @@ describe('New feature flag form', () => {
...
@@ -40,12 +39,11 @@ describe('New feature flag form', () => {
});
});
describe
(
'
with error
'
,
()
=>
{
describe
(
'
with error
'
,
()
=>
{
it
(
'
should render the error
'
,
done
=>
{
it
(
'
should render the error
'
,
()
=>
{
store
.
dispatch
(
'
new/receiveCreateFeatureFlagError
'
,
{
message
:
[
'
The name is required
'
]
});
store
.
dispatch
(
'
new/receiveCreateFeatureFlagError
'
,
{
message
:
[
'
The name is required
'
]
});
Vue
.
nextTick
(()
=>
{
return
wrapper
.
vm
.
$
nextTick
(()
=>
{
expect
(
wrapper
.
find
(
'
.alert
'
).
exists
()).
toEqual
(
true
);
expect
(
wrapper
.
find
(
'
.alert
'
).
exists
()).
toEqual
(
true
);
expect
(
wrapper
.
find
(
'
.alert
'
).
text
()).
toContain
(
'
The name is required
'
);
expect
(
wrapper
.
find
(
'
.alert
'
).
text
()).
toContain
(
'
The name is required
'
);
done
();
});
});
});
});
});
});
...
@@ -59,17 +57,16 @@ describe('New feature flag form', () => {
...
@@ -59,17 +57,16 @@ describe('New feature flag form', () => {
});
});
it
(
'
should render default * row
'
,
()
=>
{
it
(
'
should render default * row
'
,
()
=>
{
expect
(
wrapper
.
vm
.
scopes
).
toEqual
([
const
defaultScope
=
{
{
id
:
expect
.
any
(
String
),
id
:
expect
.
any
(
String
),
environmentScope
:
'
*
'
,
environmentScope
:
'
*
'
,
active
:
true
,
active
:
true
,
rolloutStrategy
:
ROLLOUT_STRATEGY_ALL_USERS
,
rolloutStrategy
:
ROLLOUT_STRATEGY_ALL_USERS
,
rolloutPercentage
:
DEFAULT_PERCENT_ROLLOUT
,
rolloutPercentage
:
DEFAULT_PERCENT_ROLLOUT
,
rolloutUserIds
:
[],
rolloutUserIds
:
[],
},
};
]);
expect
(
wrapper
.
vm
.
scopes
).
toEqual
([
defaultScope
]);
expect
(
wrapper
.
find
(
'
.js-scope-all
'
).
exists
()).
toEqual
(
tru
e
);
expect
(
wrapper
.
find
(
Form
).
props
(
'
scopes
'
)).
toContainEqual
(
defaultScop
e
);
});
});
});
});
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