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
57570cb7
Commit
57570cb7
authored
Dec 04, 2020
by
Nicolò Maria Mezzopera
Committed by
Olena Horal-Koretska
Dec 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename expiration textarea to expiration input
- source - tests - wiring
parent
e43b258a
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
99 additions
and
87 deletions
+99
-87
app/assets/javascripts/registry/settings/components/expiration_input.vue
...scripts/registry/settings/components/expiration_input.vue
+7
-7
app/assets/javascripts/registry/settings/components/expiration_run_text.vue
...ipts/registry/settings/components/expiration_run_text.vue
+16
-1
app/assets/javascripts/registry/settings/components/expiration_toggle.vue
...cripts/registry/settings/components/expiration_toggle.vue
+6
-9
app/assets/javascripts/registry/settings/components/settings_form.vue
...avascripts/registry/settings/components/settings_form.vue
+11
-7
app/assets/javascripts/registry/settings/constants.js
app/assets/javascripts/registry/settings/constants.js
+5
-5
locale/gitlab.pot
locale/gitlab.pot
+6
-3
spec/features/projects/settings/registry_settings_spec.rb
spec/features/projects/settings/registry_settings_spec.rb
+1
-1
spec/frontend/registry/settings/components/__snapshots__/settings_form_spec.js.snap
...tings/components/__snapshots__/settings_form_spec.js.snap
+4
-4
spec/frontend/registry/settings/components/expiration_input_spec.js
...end/registry/settings/components/expiration_input_spec.js
+11
-11
spec/frontend/registry/settings/components/expiration_run_text_spec.js
.../registry/settings/components/expiration_run_text_spec.js
+15
-19
spec/frontend/registry/settings/components/expiration_toggle_spec.js
...nd/registry/settings/components/expiration_toggle_spec.js
+5
-8
spec/frontend/registry/settings/components/settings_form_spec.js
...ontend/registry/settings/components/settings_form_spec.js
+12
-12
No files found.
app/assets/javascripts/registry/settings/components/expiration_
textarea
.vue
→
app/assets/javascripts/registry/settings/components/expiration_
input
.vue
View file @
57570cb7
<
script
>
<
script
>
import
{
GlFormGroup
,
GlForm
Textarea
,
GlSprintf
,
GlLink
}
from
'
@gitlab/ui
'
;
import
{
GlFormGroup
,
GlForm
Input
,
GlSprintf
,
GlLink
}
from
'
@gitlab/ui
'
;
import
{
NAME_REGEX_LENGTH
,
TEXT_AREA_INVALID_FEEDBACK
}
from
'
../constants
'
;
import
{
NAME_REGEX_LENGTH
,
TEXT_AREA_INVALID_FEEDBACK
}
from
'
../constants
'
;
export
default
{
export
default
{
components
:
{
components
:
{
GlFormGroup
,
GlFormGroup
,
GlForm
Textarea
,
GlForm
Input
,
GlSprintf
,
GlSprintf
,
GlLink
,
GlLink
,
},
},
...
@@ -48,7 +48,7 @@ export default {
...
@@ -48,7 +48,7 @@ export default {
textAreaLengthErrorMessage
()
{
textAreaLengthErrorMessage
()
{
return
this
.
isInputValid
(
this
.
value
)
?
''
:
TEXT_AREA_INVALID_FEEDBACK
;
return
this
.
isInputValid
(
this
.
value
)
?
''
:
TEXT_AREA_INVALID_FEEDBACK
;
},
},
textArea
Validation
()
{
input
Validation
()
{
const
nameRegexErrors
=
this
.
error
||
this
.
textAreaLengthErrorMessage
;
const
nameRegexErrors
=
this
.
error
||
this
.
textAreaLengthErrorMessage
;
return
{
return
{
state
:
nameRegexErrors
===
null
?
null
:
!
nameRegexErrors
,
state
:
nameRegexErrors
===
null
?
null
:
!
nameRegexErrors
,
...
@@ -77,8 +77,8 @@ export default {
...
@@ -77,8 +77,8 @@ export default {
<gl-form-group
<gl-form-group
:id=
"`$
{name}-form-group`"
:id=
"`$
{name}-form-group`"
:label-for="name"
:label-for="name"
:state="
textArea
Validation.state"
:state="
input
Validation.state"
:invalid-feedback="
textArea
Validation.message"
:invalid-feedback="
input
Validation.message"
>
>
<template
#label
>
<template
#label
>
<span
data-testid=
"label"
>
<span
data-testid=
"label"
>
...
@@ -89,11 +89,11 @@ export default {
...
@@ -89,11 +89,11 @@ export default {
</gl-sprintf>
</gl-sprintf>
</span>
</span>
</template>
</template>
<gl-form-
textarea
<gl-form-
input
:id=
"name"
:id=
"name"
v-model=
"internalValue"
v-model=
"internalValue"
:placeholder=
"placeholder"
:placeholder=
"placeholder"
:state=
"
textArea
Validation.state"
:state=
"
input
Validation.state"
:disabled=
"disabled"
:disabled=
"disabled"
trim
trim
/>
/>
...
...
app/assets/javascripts/registry/settings/components/expiration_run_text.vue
View file @
57570cb7
...
@@ -13,6 +13,16 @@ export default {
...
@@ -13,6 +13,16 @@ export default {
required
:
false
,
required
:
false
,
default
:
NOT_SCHEDULED_POLICY_TEXT
,
default
:
NOT_SCHEDULED_POLICY_TEXT
,
},
},
enabled
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
computed
:
{
parsedValue
()
{
return
this
.
enabled
?
this
.
value
:
NOT_SCHEDULED_POLICY_TEXT
;
},
},
},
i18n
:
{
i18n
:
{
NEXT_CLEANUP_LABEL
,
NEXT_CLEANUP_LABEL
,
...
@@ -26,6 +36,11 @@ export default {
...
@@ -26,6 +36,11 @@ export default {
:label=
"$options.i18n.NEXT_CLEANUP_LABEL"
:label=
"$options.i18n.NEXT_CLEANUP_LABEL"
label-for=
"expiration-policy-info-text"
label-for=
"expiration-policy-info-text"
>
>
<gl-form-input
id=
"expiration-policy-info-text"
class=
"gl-pl-0!"
plaintext
:value=
"value"
/>
<gl-form-input
id=
"expiration-policy-info-text"
class=
"gl-pl-0!"
plaintext
:value=
"parsedValue"
/>
</gl-form-group>
</gl-form-group>
</
template
>
</
template
>
app/assets/javascripts/registry/settings/components/expiration_toggle.vue
View file @
57570cb7
<
script
>
<
script
>
import
{
GlFormGroup
,
GlToggle
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
GlFormGroup
,
GlToggle
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
{
ENABLED_T
EXT
,
DISABLED_TEXT
,
ENABLE
_TOGGLE_DESCRIPTION
}
from
'
../constants
'
;
import
{
ENABLED_T
OGGLE_DESCRIPTION
,
DISABLED
_TOGGLE_DESCRIPTION
}
from
'
../constants
'
;
export
default
{
export
default
{
components
:
{
components
:
{
...
@@ -20,9 +20,6 @@ export default {
...
@@ -20,9 +20,6 @@ export default {
default
:
false
,
default
:
false
,
},
},
},
},
i18n
:
{
ENABLE_TOGGLE_DESCRIPTION
,
},
computed
:
{
computed
:
{
enabled
:
{
enabled
:
{
get
()
{
get
()
{
...
@@ -32,8 +29,8 @@ export default {
...
@@ -32,8 +29,8 @@ export default {
this
.
$emit
(
'
input
'
,
value
);
this
.
$emit
(
'
input
'
,
value
);
},
},
},
},
toggle
Status
Text
()
{
toggleText
()
{
return
this
.
enabled
?
ENABLED_T
EXT
:
DISABLED_TEXT
;
return
this
.
enabled
?
ENABLED_T
OGGLE_DESCRIPTION
:
DISABLED_TOGGLE_DESCRIPTION
;
},
},
},
},
};
};
...
@@ -44,9 +41,9 @@ export default {
...
@@ -44,9 +41,9 @@ export default {
<div
class=
"gl-display-flex"
>
<div
class=
"gl-display-flex"
>
<gl-toggle
id=
"expiration-policy-toggle"
v-model=
"enabled"
:disabled=
"disabled"
/>
<gl-toggle
id=
"expiration-policy-toggle"
v-model=
"enabled"
:disabled=
"disabled"
/>
<span
class=
"gl-ml-5 gl-line-height-24"
data-testid=
"description"
>
<span
class=
"gl-ml-5 gl-line-height-24"
data-testid=
"description"
>
<gl-sprintf
:message=
"
$options.i18n.ENABLE_TOGGLE_DESCRIPTION
"
>
<gl-sprintf
:message=
"
toggleText
"
>
<template
#
toggleStatus
>
<template
#
strong
="
{content}"
>
<strong>
{{
toggleStatusTex
t
}}
</strong>
<strong>
{{
conten
t
}}
</strong>
</
template
>
</
template
>
</gl-sprintf>
</gl-sprintf>
</span>
</span>
...
...
app/assets/javascripts/registry/settings/components/settings_form.vue
View file @
57570cb7
...
@@ -25,7 +25,7 @@ import { formOptionsGenerator } from '~/registry/shared/utils';
...
@@ -25,7 +25,7 @@ import { formOptionsGenerator } from '~/registry/shared/utils';
import
updateContainerExpirationPolicyMutation
from
'
~/registry/settings/graphql/mutations/update_container_expiration_policy.graphql
'
;
import
updateContainerExpirationPolicyMutation
from
'
~/registry/settings/graphql/mutations/update_container_expiration_policy.graphql
'
;
import
{
updateContainerExpirationPolicy
}
from
'
~/registry/settings/graphql/utils/cache_update
'
;
import
{
updateContainerExpirationPolicy
}
from
'
~/registry/settings/graphql/utils/cache_update
'
;
import
ExpirationDropdown
from
'
./expiration_dropdown.vue
'
;
import
ExpirationDropdown
from
'
./expiration_dropdown.vue
'
;
import
Expiration
Textarea
from
'
./expiration_textarea
.vue
'
;
import
Expiration
Input
from
'
./expiration_input
.vue
'
;
import
ExpirationToggle
from
'
./expiration_toggle.vue
'
;
import
ExpirationToggle
from
'
./expiration_toggle.vue
'
;
import
ExpirationRunText
from
'
./expiration_run_text.vue
'
;
import
ExpirationRunText
from
'
./expiration_run_text.vue
'
;
...
@@ -35,7 +35,7 @@ export default {
...
@@ -35,7 +35,7 @@ export default {
GlButton
,
GlButton
,
GlSprintf
,
GlSprintf
,
ExpirationDropdown
,
ExpirationDropdown
,
Expiration
Textarea
,
Expiration
Input
,
ExpirationToggle
,
ExpirationToggle
,
ExpirationRunText
,
ExpirationRunText
,
},
},
...
@@ -202,7 +202,11 @@ export default {
...
@@ -202,7 +202,11 @@ export default {
data-testid=
"cadence-dropdown"
data-testid=
"cadence-dropdown"
@
input=
"onModelChange($event, 'cadence')"
@
input=
"onModelChange($event, 'cadence')"
/>
/>
<expiration-run-text
:value=
"prefilledForm.nextRunAt"
class=
"gl-mb-0!"
/>
<expiration-run-text
:value=
"prefilledForm.nextRunAt"
:enabled=
"prefilledForm.enabled"
class=
"gl-mb-0!"
/>
</div>
</div>
<gl-card
class=
"gl-mt-7"
>
<gl-card
class=
"gl-mt-7"
>
<template
#header
>
<template
#header
>
...
@@ -229,14 +233,14 @@ export default {
...
@@ -229,14 +233,14 @@ export default {
data-testid=
"keep-n-dropdown"
data-testid=
"keep-n-dropdown"
@
input=
"onModelChange($event, 'keepN')"
@
input=
"onModelChange($event, 'keepN')"
/>
/>
<expiration-
textarea
<expiration-
input
v-model=
"prefilledForm.nameRegexKeep"
v-model=
"prefilledForm.nameRegexKeep"
:error=
"apiErrors.nameRegexKeep"
:error=
"apiErrors.nameRegexKeep"
:disabled=
"isFieldDisabled"
:disabled=
"isFieldDisabled"
:label=
"$options.i18n.NAME_REGEX_KEEP_LABEL"
:label=
"$options.i18n.NAME_REGEX_KEEP_LABEL"
:description=
"$options.i18n.NAME_REGEX_KEEP_DESCRIPTION"
:description=
"$options.i18n.NAME_REGEX_KEEP_DESCRIPTION"
name=
"keep-regex"
name=
"keep-regex"
data-testid=
"keep-regex-
textarea
"
data-testid=
"keep-regex-
input
"
@
input=
"onModelChange($event, 'nameRegexKeep')"
@
input=
"onModelChange($event, 'nameRegexKeep')"
@
validation=
"setLocalErrors($event, 'nameRegexKeep')"
@
validation=
"setLocalErrors($event, 'nameRegexKeep')"
/>
/>
...
@@ -268,7 +272,7 @@ export default {
...
@@ -268,7 +272,7 @@ export default {
data-testid=
"older-than-dropdown"
data-testid=
"older-than-dropdown"
@
input=
"onModelChange($event, 'olderThan')"
@
input=
"onModelChange($event, 'olderThan')"
/>
/>
<expiration-
textarea
<expiration-
input
v-model=
"prefilledForm.nameRegex"
v-model=
"prefilledForm.nameRegex"
:error=
"apiErrors.nameRegex"
:error=
"apiErrors.nameRegex"
:disabled=
"isFieldDisabled"
:disabled=
"isFieldDisabled"
...
@@ -276,7 +280,7 @@ export default {
...
@@ -276,7 +280,7 @@ export default {
:placeholder=
"$options.i18n.NAME_REGEX_PLACEHOLDER"
:placeholder=
"$options.i18n.NAME_REGEX_PLACEHOLDER"
:description=
"$options.i18n.NAME_REGEX_DESCRIPTION"
:description=
"$options.i18n.NAME_REGEX_DESCRIPTION"
name=
"remove-regex"
name=
"remove-regex"
data-testid=
"remove-regex-
textarea
"
data-testid=
"remove-regex-
input
"
@
input=
"onModelChange($event, 'nameRegex')"
@
input=
"onModelChange($event, 'nameRegex')"
@
validation=
"setLocalErrors($event, 'nameRegex')"
@
validation=
"setLocalErrors($event, 'nameRegex')"
/>
/>
...
...
app/assets/javascripts/registry/settings/constants.js
View file @
57570cb7
...
@@ -37,11 +37,11 @@ export const NAME_REGEX_DESCRIPTION = s__(
...
@@ -37,11 +37,11 @@ export const NAME_REGEX_DESCRIPTION = s__(
'
ContainerRegistry|Tags with names that match this regex pattern are removed. %{linkStart}More information%{linkEnd}
'
,
'
ContainerRegistry|Tags with names that match this regex pattern are removed. %{linkStart}More information%{linkEnd}
'
,
);
);
export
const
ENABLED_T
EXT
=
__
(
'
Enabled
'
);
export
const
ENABLED_T
OGGLE_DESCRIPTION
=
s__
(
export
const
DISABLED_TEXT
=
__
(
'
Disabled
'
);
'
ContainerRegistry|%{strongStart}Enabled%{strongEnd} - Tags that match the rules on this page are automatically scheduled for deletion.
'
,
);
export
const
ENABLE
_TOGGLE_DESCRIPTION
=
s__
(
export
const
DISABLED
_TOGGLE_DESCRIPTION
=
s__
(
'
ContainerRegistry|%{
toggleStatus} - Tags that match the rules on this page are automatically scheduled for deletion
.
'
,
'
ContainerRegistry|%{
strongStart}Disabled%{strongEnd} - Tags will not be automatically deleted
.
'
,
);
);
export
const
CADENCE_LABEL
=
s__
(
'
ContainerRegistry|Run cleanup:
'
);
export
const
CADENCE_LABEL
=
s__
(
'
ContainerRegistry|Run cleanup:
'
);
...
...
locale/gitlab.pot
View file @
57570cb7
...
@@ -7273,13 +7273,16 @@ msgstr[1] ""
...
@@ -7273,13 +7273,16 @@ msgstr[1] ""
msgid "ContainerRegistry|%{imageName} tags"
msgid "ContainerRegistry|%{imageName} tags"
msgstr ""
msgstr ""
msgid "ContainerRegistry|%{
title} was successfully scheduled for deletion
"
msgid "ContainerRegistry|%{
strongStart}Disabled%{strongEnd} - Tags will not be automatically deleted.
"
msgstr ""
msgstr ""
msgid "ContainerRegistry|%{toggleStatus} - Tags matching the patterns defined below will be scheduled for deletion"
msgid "ContainerRegistry|%{strongStart}Enabled%{strongEnd} - Tags that match the rules on this page are automatically scheduled for deletion."
msgstr ""
msgid "ContainerRegistry|%{title} was successfully scheduled for deletion"
msgstr ""
msgstr ""
msgid "ContainerRegistry|%{toggleStatus} - Tags
that match the rules on this page are automatically scheduled for deletion.
"
msgid "ContainerRegistry|%{toggleStatus} - Tags
matching the patterns defined below will be scheduled for deletion
"
msgstr ""
msgstr ""
msgid "ContainerRegistry|Build an image"
msgid "ContainerRegistry|Build an image"
...
...
spec/features/projects/settings/registry_settings_spec.rb
View file @
57570cb7
...
@@ -84,7 +84,7 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
...
@@ -84,7 +84,7 @@ RSpec.describe 'Project > Settings > CI/CD > Container registry tag expiration p
within
'#js-registry-policies'
do
within
'#js-registry-policies'
do
case
result
case
result
when
:available_section
when
:available_section
expect
(
find
(
'[data-testid="enable-toggle"]'
)).
to
have_content
(
'
Tags that match the rules on this page are automatically scheduled for deletion
.'
)
expect
(
find
(
'[data-testid="enable-toggle"]'
)).
to
have_content
(
'
Disabled - Tags will not be automatically deleted
.'
)
when
:disabled_message
when
:disabled_message
expect
(
find
(
'.gl-alert-title'
)).
to
have_content
(
'Cleanup policy for tags is disabled'
)
expect
(
find
(
'.gl-alert-title'
)).
to
have_content
(
'Cleanup policy for tags is disabled'
)
end
end
...
...
spec/frontend/registry/settings/components/__snapshots__/settings_form_spec.js.snap
View file @
57570cb7
...
@@ -30,8 +30,8 @@ exports[`Settings Form Keep N matches snapshot 1`] = `
...
@@ -30,8 +30,8 @@ exports[`Settings Form Keep N matches snapshot 1`] = `
`;
`;
exports[`Settings Form Keep Regex matches snapshot 1`] = `
exports[`Settings Form Keep Regex matches snapshot 1`] = `
<expiration-
textarea
-stub
<expiration-
input
-stub
data-testid="keep-regex-
textarea
"
data-testid="keep-regex-
input
"
description="Tags with names that match this regex pattern are kept. %{linkStart}More information%{linkEnd}"
description="Tags with names that match this regex pattern are kept. %{linkStart}More information%{linkEnd}"
error=""
error=""
label="Keep tags matching:"
label="Keep tags matching:"
...
@@ -52,8 +52,8 @@ exports[`Settings Form OlderThan matches snapshot 1`] = `
...
@@ -52,8 +52,8 @@ exports[`Settings Form OlderThan matches snapshot 1`] = `
`;
`;
exports[`Settings Form Remove regex matches snapshot 1`] = `
exports[`Settings Form Remove regex matches snapshot 1`] = `
<expiration-
textarea
-stub
<expiration-
input
-stub
data-testid="remove-regex-
textarea
"
data-testid="remove-regex-
input
"
description="Tags with names that match this regex pattern are removed. %{linkStart}More information%{linkEnd}"
description="Tags with names that match this regex pattern are removed. %{linkStart}More information%{linkEnd}"
error=""
error=""
label="Remove tags matching:"
label="Remove tags matching:"
...
...
spec/frontend/registry/settings/components/expiration_
textarea
_spec.js
→
spec/frontend/registry/settings/components/expiration_
input
_spec.js
View file @
57570cb7
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlSprintf
,
GlForm
Textarea
,
GlLink
}
from
'
@gitlab/ui
'
;
import
{
GlSprintf
,
GlForm
Input
,
GlLink
}
from
'
@gitlab/ui
'
;
import
{
GlFormGroup
}
from
'
jest/registry/shared/stubs
'
;
import
{
GlFormGroup
}
from
'
jest/registry/shared/stubs
'
;
import
component
from
'
~/registry/settings/components/expiration_
textarea
.vue
'
;
import
component
from
'
~/registry/settings/components/expiration_
input
.vue
'
;
import
{
NAME_REGEX_LENGTH
}
from
'
~/registry/shared/constants
'
;
import
{
NAME_REGEX_LENGTH
}
from
'
~/registry/shared/constants
'
;
describe
(
'
Expiration
Textarea
'
,
()
=>
{
describe
(
'
Expiration
Input
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
const
defaultProps
=
{
const
defaultProps
=
{
...
@@ -16,7 +16,7 @@ describe('ExpirationTextarea', () => {
...
@@ -16,7 +16,7 @@ describe('ExpirationTextarea', () => {
const
tagsRegexHelpPagePath
=
'
fooPath
'
;
const
tagsRegexHelpPagePath
=
'
fooPath
'
;
const
find
TextArea
=
()
=>
wrapper
.
find
(
GlFormTextarea
);
const
find
Input
=
()
=>
wrapper
.
find
(
GlFormInput
);
const
findFormGroup
=
()
=>
wrapper
.
find
(
GlFormGroup
);
const
findFormGroup
=
()
=>
wrapper
.
find
(
GlFormGroup
);
const
findLabel
=
()
=>
wrapper
.
find
(
'
[data-testid="label"]
'
);
const
findLabel
=
()
=>
wrapper
.
find
(
'
[data-testid="label"]
'
);
const
findDescription
=
()
=>
wrapper
.
find
(
'
[data-testid="description"]
'
);
const
findDescription
=
()
=>
wrapper
.
find
(
'
[data-testid="description"]
'
);
...
@@ -53,7 +53,7 @@ describe('ExpirationTextarea', () => {
...
@@ -53,7 +53,7 @@ describe('ExpirationTextarea', () => {
it
(
'
has a textarea component
'
,
()
=>
{
it
(
'
has a textarea component
'
,
()
=>
{
mountComponent
();
mountComponent
();
expect
(
find
TextArea
().
exists
()).
toBe
(
true
);
expect
(
find
Input
().
exists
()).
toBe
(
true
);
});
});
it
(
'
has a description
'
,
()
=>
{
it
(
'
has a description
'
,
()
=>
{
...
@@ -78,7 +78,7 @@ describe('ExpirationTextarea', () => {
...
@@ -78,7 +78,7 @@ describe('ExpirationTextarea', () => {
mountComponent
({
value
,
disabled
});
mountComponent
({
value
,
disabled
});
expect
(
find
TextArea
().
attributes
()).
toMatchObject
({
expect
(
find
Input
().
attributes
()).
toMatchObject
({
id
:
defaultProps
.
name
,
id
:
defaultProps
.
name
,
value
,
value
,
placeholder
:
defaultProps
.
placeholder
,
placeholder
:
defaultProps
.
placeholder
,
...
@@ -92,7 +92,7 @@ describe('ExpirationTextarea', () => {
...
@@ -92,7 +92,7 @@ describe('ExpirationTextarea', () => {
mountComponent
();
mountComponent
();
find
TextArea
().
vm
.
$emit
(
'
input
'
,
emittedValue
);
find
Input
().
vm
.
$emit
(
'
input
'
,
emittedValue
);
expect
(
wrapper
.
emitted
(
'
input
'
)).
toEqual
([[
emittedValue
]]);
expect
(
wrapper
.
emitted
(
'
input
'
)).
toEqual
([[
emittedValue
]]);
});
});
});
});
...
@@ -141,12 +141,12 @@ describe('ExpirationTextarea', () => {
...
@@ -141,12 +141,12 @@ describe('ExpirationTextarea', () => {
// since the component has no state we both emit the event and set the prop
// since the component has no state we both emit the event and set the prop
mountComponent
({
value
:
invalidString
});
mountComponent
({
value
:
invalidString
});
find
TextArea
().
vm
.
$emit
(
'
input
'
,
invalidString
);
find
Input
().
vm
.
$emit
(
'
input
'
,
invalidString
);
});
});
it
(
'
textAreaValidation state is false
'
,
()
=>
{
it
(
'
textAreaValidation state is false
'
,
()
=>
{
expect
(
findFormGroup
().
props
(
'
state
'
)).
toBe
(
false
);
expect
(
findFormGroup
().
props
(
'
state
'
)).
toBe
(
false
);
expect
(
find
TextArea
().
attributes
(
'
state
'
)).
toBeUndefined
();
expect
(
find
Input
().
attributes
(
'
state
'
)).
toBeUndefined
();
});
});
it
(
'
emits the @validation event with false payload
'
,
()
=>
{
it
(
'
emits the @validation event with false payload
'
,
()
=>
{
...
@@ -157,10 +157,10 @@ describe('ExpirationTextarea', () => {
...
@@ -157,10 +157,10 @@ describe('ExpirationTextarea', () => {
it
(
`when user input is less than
${
NAME_REGEX_LENGTH
}
state is "true"`
,
()
=>
{
it
(
`when user input is less than
${
NAME_REGEX_LENGTH
}
state is "true"`
,
()
=>
{
mountComponent
();
mountComponent
();
find
TextArea
().
vm
.
$emit
(
'
input
'
,
'
foo
'
);
find
Input
().
vm
.
$emit
(
'
input
'
,
'
foo
'
);
expect
(
findFormGroup
().
props
(
'
state
'
)).
toBe
(
true
);
expect
(
findFormGroup
().
props
(
'
state
'
)).
toBe
(
true
);
expect
(
find
TextArea
().
attributes
(
'
state
'
)).
toBe
(
'
true
'
);
expect
(
find
Input
().
attributes
(
'
state
'
)).
toBe
(
'
true
'
);
expect
(
wrapper
.
emitted
(
'
validation
'
)).
toEqual
([[
true
]]);
expect
(
wrapper
.
emitted
(
'
validation
'
)).
toEqual
([[
true
]]);
});
});
});
});
...
...
spec/frontend/registry/settings/components/expiration_run_text_spec.js
View file @
57570cb7
...
@@ -28,19 +28,12 @@ describe('ExpirationToggle', () => {
...
@@ -28,19 +28,12 @@ describe('ExpirationToggle', () => {
describe
(
'
structure
'
,
()
=>
{
describe
(
'
structure
'
,
()
=>
{
it
(
'
has an input component
'
,
()
=>
{
it
(
'
has an input component
'
,
()
=>
{
mountComponent
();
mountComponent
();
expect
(
findInput
().
exists
()).
toBe
(
true
);
expect
(
findInput
().
exists
()).
toBe
(
true
);
});
});
});
});
describe
(
'
model
'
,
()
=>
{
describe
(
'
model
'
,
()
=>
{
it
(
'
assigns the right props to the input component
'
,
()
=>
{
mountComponent
({
value
,
disabled
:
true
});
expect
(
findInput
().
attributes
()).
toMatchObject
({
value
,
});
});
it
(
'
assigns the right props to the form-group component
'
,
()
=>
{
it
(
'
assigns the right props to the form-group component
'
,
()
=>
{
mountComponent
();
mountComponent
();
...
@@ -51,16 +44,19 @@ describe('ExpirationToggle', () => {
...
@@ -51,16 +44,19 @@ describe('ExpirationToggle', () => {
});
});
describe
(
'
formattedValue
'
,
()
=>
{
describe
(
'
formattedValue
'
,
()
=>
{
it
(
'
displays the values when it exists
'
,
()
=>
{
it
.
each
`
mountComponent
({
value
});
valueProp | enabled | expected
${
value
}
|
${
true
}
|
${
value
}
expect
(
findInput
().
attributes
(
'
value
'
)).
toBe
(
value
);
${
value
}
|
${
false
}
|
${
NOT_SCHEDULED_POLICY_TEXT
}
});
${
undefined
}
|
${
false
}
|
${
NOT_SCHEDULED_POLICY_TEXT
}
${
undefined
}
|
${
true
}
|
${
NOT_SCHEDULED_POLICY_TEXT
}
it
(
'
displays a placeholder when no value is present
'
,
()
=>
{
`
(
mountComponent
();
'
when value is $valueProp and enabled is $enabled the input value is $expected
'
,
({
valueProp
,
enabled
,
expected
})
=>
{
expect
(
findInput
().
attributes
(
'
value
'
)).
toBe
(
NOT_SCHEDULED_POLICY_TEXT
);
mountComponent
({
value
:
valueProp
,
enabled
});
});
expect
(
findInput
().
attributes
(
'
value
'
)).
toBe
(
expected
);
},
);
});
});
});
});
spec/frontend/registry/settings/components/expiration_toggle_spec.js
View file @
57570cb7
...
@@ -3,9 +3,8 @@ import { GlToggle, GlSprintf } from '@gitlab/ui';
...
@@ -3,9 +3,8 @@ import { GlToggle, GlSprintf } from '@gitlab/ui';
import
{
GlFormGroup
}
from
'
jest/registry/shared/stubs
'
;
import
{
GlFormGroup
}
from
'
jest/registry/shared/stubs
'
;
import
component
from
'
~/registry/settings/components/expiration_toggle.vue
'
;
import
component
from
'
~/registry/settings/components/expiration_toggle.vue
'
;
import
{
import
{
ENABLE_TOGGLE_DESCRIPTION
,
ENABLED_TOGGLE_DESCRIPTION
,
ENABLED_TEXT
,
DISABLED_TOGGLE_DESCRIPTION
,
DISABLED_TEXT
,
}
from
'
~/registry/settings/constants
'
;
}
from
'
~/registry/settings/constants
'
;
describe
(
'
ExpirationToggle
'
,
()
=>
{
describe
(
'
ExpirationToggle
'
,
()
=>
{
...
@@ -39,9 +38,7 @@ describe('ExpirationToggle', () => {
...
@@ -39,9 +38,7 @@ describe('ExpirationToggle', () => {
it
(
'
has a description
'
,
()
=>
{
it
(
'
has a description
'
,
()
=>
{
mountComponent
();
mountComponent
();
expect
(
findDescription
().
text
()).
toContain
(
expect
(
findDescription
().
exists
()).
toBe
(
true
);
ENABLE_TOGGLE_DESCRIPTION
.
replace
(
'
%{toggleStatus}
'
,
''
),
);
});
});
});
});
...
@@ -68,13 +65,13 @@ describe('ExpirationToggle', () => {
...
@@ -68,13 +65,13 @@ describe('ExpirationToggle', () => {
it
(
'
says enabled when the toggle is on
'
,
()
=>
{
it
(
'
says enabled when the toggle is on
'
,
()
=>
{
mountComponent
({
value
:
true
});
mountComponent
({
value
:
true
});
expect
(
findDescription
().
text
()).
to
Contain
(
ENABLED_TEXT
);
expect
(
findDescription
().
text
()).
to
MatchInterpolatedText
(
ENABLED_TOGGLE_DESCRIPTION
);
});
});
it
(
'
says disabled when the toggle is off
'
,
()
=>
{
it
(
'
says disabled when the toggle is off
'
,
()
=>
{
mountComponent
({
value
:
false
});
mountComponent
({
value
:
false
});
expect
(
findDescription
().
text
()).
to
Contain
(
DISABLED_TEXT
);
expect
(
findDescription
().
text
()).
to
MatchInterpolatedText
(
DISABLED_TOGGLE_DESCRIPTION
);
});
});
});
});
});
});
spec/frontend/registry/settings/components/settings_form_spec.js
View file @
57570cb7
...
@@ -44,9 +44,9 @@ describe('Settings Form', () => {
...
@@ -44,9 +44,9 @@ describe('Settings Form', () => {
const
findEnableToggle
=
()
=>
wrapper
.
find
(
'
[data-testid="enable-toggle"]
'
);
const
findEnableToggle
=
()
=>
wrapper
.
find
(
'
[data-testid="enable-toggle"]
'
);
const
findCadenceDropdown
=
()
=>
wrapper
.
find
(
'
[data-testid="cadence-dropdown"]
'
);
const
findCadenceDropdown
=
()
=>
wrapper
.
find
(
'
[data-testid="cadence-dropdown"]
'
);
const
findKeepNDropdown
=
()
=>
wrapper
.
find
(
'
[data-testid="keep-n-dropdown"]
'
);
const
findKeepNDropdown
=
()
=>
wrapper
.
find
(
'
[data-testid="keep-n-dropdown"]
'
);
const
findKeepRegex
Textarea
=
()
=>
wrapper
.
find
(
'
[data-testid="keep-regex-textarea
"]
'
);
const
findKeepRegex
Input
=
()
=>
wrapper
.
find
(
'
[data-testid="keep-regex-input
"]
'
);
const
findOlderThanDropdown
=
()
=>
wrapper
.
find
(
'
[data-testid="older-than-dropdown"]
'
);
const
findOlderThanDropdown
=
()
=>
wrapper
.
find
(
'
[data-testid="older-than-dropdown"]
'
);
const
findRemoveRegex
Textarea
=
()
=>
wrapper
.
find
(
'
[data-testid="remove-regex-textarea
"]
'
);
const
findRemoveRegex
Input
=
()
=>
wrapper
.
find
(
'
[data-testid="remove-regex-input
"]
'
);
const
mountComponent
=
({
const
mountComponent
=
({
props
=
defaultProps
,
props
=
defaultProps
,
...
@@ -119,9 +119,9 @@ describe('Settings Form', () => {
...
@@ -119,9 +119,9 @@ describe('Settings Form', () => {
${
'
enabled
'
}
|
${
findEnableToggle
}
|
${
'
Enable
'
}
|
${
'
toggle
'
}
|
${
false
}
${
'
enabled
'
}
|
${
findEnableToggle
}
|
${
'
Enable
'
}
|
${
'
toggle
'
}
|
${
false
}
${
'
cadence
'
}
|
${
findCadenceDropdown
}
|
${
'
Cadence
'
}
|
${
'
dropdown
'
}
|
${
'
EVERY_DAY
'
}
${
'
cadence
'
}
|
${
findCadenceDropdown
}
|
${
'
Cadence
'
}
|
${
'
dropdown
'
}
|
${
'
EVERY_DAY
'
}
${
'
keepN
'
}
|
${
findKeepNDropdown
}
|
${
'
Keep N
'
}
|
${
'
dropdown
'
}
|
${
'
TEN_TAGS
'
}
${
'
keepN
'
}
|
${
findKeepNDropdown
}
|
${
'
Keep N
'
}
|
${
'
dropdown
'
}
|
${
'
TEN_TAGS
'
}
${
'
nameRegexKeep
'
}
|
${
findKeepRegex
Textarea
}
|
${
'
Keep Regex
'
}
|
${
'
textarea
'
}
|
${
''
}
${
'
nameRegexKeep
'
}
|
${
findKeepRegex
Input
}
|
${
'
Keep Regex
'
}
|
${
'
textarea
'
}
|
${
''
}
${
'
olderThan
'
}
|
${
findOlderThanDropdown
}
|
${
'
OlderThan
'
}
|
${
'
dropdown
'
}
|
${
'
NINETY_DAYS
'
}
${
'
olderThan
'
}
|
${
findOlderThanDropdown
}
|
${
'
OlderThan
'
}
|
${
'
dropdown
'
}
|
${
'
NINETY_DAYS
'
}
${
'
nameRegex
'
}
|
${
findRemoveRegex
Textarea
}
|
${
'
Remove regex
'
}
|
${
'
textarea
'
}
|
${
''
}
${
'
nameRegex
'
}
|
${
findRemoveRegex
Input
}
|
${
'
Remove regex
'
}
|
${
'
textarea
'
}
|
${
''
}
`
(
'
$fieldName
'
,
({
model
,
finder
,
type
,
defaultValue
})
=>
{
`
(
'
$fieldName
'
,
({
model
,
finder
,
type
,
defaultValue
})
=>
{
it
(
'
matches snapshot
'
,
()
=>
{
it
(
'
matches snapshot
'
,
()
=>
{
mountComponent
();
mountComponent
();
...
@@ -240,8 +240,8 @@ describe('Settings Form', () => {
...
@@ -240,8 +240,8 @@ describe('Settings Form', () => {
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
expect
(
findKeepRegex
Textarea
().
props
(
'
error
'
)).
toBe
(
''
);
expect
(
findKeepRegex
Input
().
props
(
'
error
'
)).
toBe
(
''
);
expect
(
findRemoveRegex
Textarea
().
props
(
'
error
'
)).
toBe
(
''
);
expect
(
findRemoveRegex
Input
().
props
(
'
error
'
)).
toBe
(
''
);
expect
(
findSaveButton
().
props
(
'
disabled
'
)).
toBe
(
false
);
expect
(
findSaveButton
().
props
(
'
disabled
'
)).
toBe
(
false
);
});
});
});
});
...
@@ -338,7 +338,7 @@ describe('Settings Form', () => {
...
@@ -338,7 +338,7 @@ describe('Settings Form', () => {
await
waitForPromises
();
await
waitForPromises
();
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
expect
(
findKeepRegex
Textarea
().
props
(
'
error
'
)).
toEqual
(
'
baz
'
);
expect
(
findKeepRegex
Input
().
props
(
'
error
'
)).
toEqual
(
'
baz
'
);
});
});
});
});
});
});
...
...
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