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
33320f0a
Commit
33320f0a
authored
Nov 19, 2021
by
Kyle Edwards
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update with review feedback
parent
c32ae520
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
115 deletions
+4
-115
app/assets/javascripts/vue_shared/components/chronic_duration_input.vue
...ascripts/vue_shared/components/chronic_duration_input.vue
+2
-1
spec/frontend/vue_shared/components/chronic_duration_input_spec.js
...tend/vue_shared/components/chronic_duration_input_spec.js
+2
-114
No files found.
app/assets/javascripts/vue_shared/components/chronic_duration_input.vue
View file @
33320f0a
<
script
>
<
script
>
import
*
as
Sentry
from
'
@sentry/browser
'
;
import
{
GlFormInput
}
from
'
@gitlab/ui
'
;
import
{
GlFormInput
}
from
'
@gitlab/ui
'
;
import
{
import
{
DurationParseError
,
DurationParseError
,
...
@@ -74,7 +75,7 @@ export default {
...
@@ -74,7 +75,7 @@ export default {
if
(
e
instanceof
DurationParseError
)
{
if
(
e
instanceof
DurationParseError
)
{
this
.
isValueValid
=
false
;
this
.
isValueValid
=
false
;
}
else
{
}
else
{
throw
e
;
Sentry
.
captureException
(
e
)
;
}
}
}
}
this
.
emitEvents
(
true
);
this
.
emitEvents
(
true
);
...
...
spec/frontend/vue_shared/components/chronic_duration_input_spec.js
View file @
33320f0a
...
@@ -244,56 +244,6 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -244,56 +244,6 @@ describe('vue_shared/components/chronic_duration_input', () => {
});
});
});
});
describe
(
'
when integerRequired is true
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
value
:
null
,
integerRequired
:
true
});
});
it
(
'
emits valid when input is integer
'
,
async
()
=>
{
textElement
.
value
=
'
2hr20min
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
emitted
(
'
change
'
)).
toEqual
([[
MOCK_VALUE
]]);
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
[{
valid
:
null
,
feedback
:
''
}],
[{
valid
:
true
,
feedback
:
''
}],
]);
expect
(
textElement
.
validity
.
valid
).
toBe
(
true
);
expect
(
textElement
.
validity
.
customError
).
toBe
(
false
);
expect
(
textElement
.
validationMessage
).
toBe
(
''
);
expect
(
hiddenElement
.
validity
.
valid
).
toBe
(
true
);
expect
(
hiddenElement
.
validity
.
customError
).
toBe
(
false
);
expect
(
hiddenElement
.
validationMessage
).
toBe
(
''
);
});
it
(
'
emits invalid when input is decimal
'
,
async
()
=>
{
textElement
.
value
=
'
1.5s
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
emitted
(
'
change
'
)).
toBeUndefined
();
expect
(
wrapper
.
emitted
(
'
valid
'
)).
toEqual
([
[{
valid
:
null
,
feedback
:
''
}],
[
{
valid
:
false
,
feedback
:
ChronicDurationInput
.
i18n
.
INVALID_DECIMAL_FEEDBACK
,
},
],
]);
expect
(
textElement
.
validity
.
valid
).
toBe
(
false
);
expect
(
textElement
.
validity
.
customError
).
toBe
(
true
);
expect
(
textElement
.
validationMessage
).
toBe
(
ChronicDurationInput
.
i18n
.
INVALID_DECIMAL_FEEDBACK
,
);
expect
(
hiddenElement
.
validity
.
valid
).
toBe
(
false
);
expect
(
hiddenElement
.
validity
.
customError
).
toBe
(
true
);
// Hidden elements do not have validationMessage
expect
(
hiddenElement
.
validationMessage
).
toBe
(
''
);
});
});
describe
(
'
when integerRequired is unspecified
'
,
()
=>
{
describe
(
'
when integerRequired is unspecified
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
({
value
:
null
});
createComponent
({
value
:
null
});
...
@@ -365,7 +315,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -365,7 +315,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
});
});
it
(
'
passes updated prop via v-model
'
,
async
()
=>
{
it
(
'
passes updated prop via v-model
'
,
async
()
=>
{
wrapper
.
vm
.
value
=
MOCK_VALUE
;
wrapper
.
setData
({
value
:
MOCK_VALUE
})
;
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
expect
(
textElement
.
value
).
toBe
(
'
2 hrs 20 mins
'
);
expect
(
textElement
.
value
).
toBe
(
'
2 hrs 20 mins
'
);
...
@@ -379,7 +329,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -379,7 +329,7 @@ describe('vue_shared/components/chronic_duration_input', () => {
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
vm
.
value
).
toBe
(
MOCK_VALUE
);
expect
(
wrapper
.
findComponent
(
ChronicDurationInput
).
props
(
'
value
'
)
).
toBe
(
MOCK_VALUE
);
expect
(
textElement
.
value
).
toBe
(
'
2hr20min
'
);
expect
(
textElement
.
value
).
toBe
(
'
2hr20min
'
);
expect
(
hiddenElement
.
value
).
toBe
(
MOCK_VALUE
.
toString
());
expect
(
hiddenElement
.
value
).
toBe
(
MOCK_VALUE
.
toString
());
});
});
...
@@ -437,66 +387,4 @@ describe('vue_shared/components/chronic_duration_input', () => {
...
@@ -437,66 +387,4 @@ describe('vue_shared/components/chronic_duration_input', () => {
expect
(
iter
.
next
()).
toEqual
({
value
:
undefined
,
done
:
true
});
expect
(
iter
.
next
()).
toEqual
({
value
:
undefined
,
done
:
true
});
});
});
});
});
describe
(
'
extra attributes
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
id
:
'
myInput
'
,
disabled
:
true
});
});
it
(
'
passes extra attributes to text input
'
,
()
=>
{
expect
(
textElement
.
id
).
toBe
(
'
myInput
'
);
expect
(
textElement
.
disabled
).
toBe
(
true
);
});
it
(
'
does not pass extra attributes to hidden input
'
,
()
=>
{
expect
(
hiddenElement
.
id
).
toBe
(
''
);
expect
(
hiddenElement
.
disabled
).
toBe
(
false
);
});
});
describe
(
'
lazy
'
,
()
=>
{
describe
(
'
when lazy is true
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
lazy
:
true
});
});
it
(
'
emits change on field change
'
,
async
()
=>
{
textElement
.
value
=
'
2h20m
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
change
'
));
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
emitted
(
'
change
'
)).
toEqual
([[
MOCK_VALUE
]]);
});
it
(
'
does not emit change on field input
'
,
async
()
=>
{
textElement
.
value
=
'
2h20m
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
emitted
(
'
change
'
)).
toBeUndefined
();
});
});
describe
(
'
when lazy is false
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
lazy
:
false
});
});
it
(
'
emits change on field change
'
,
async
()
=>
{
textElement
.
value
=
'
2h20m
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
change
'
));
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
emitted
(
'
change
'
)).
toEqual
([[
MOCK_VALUE
]]);
});
it
(
'
emits change on field input
'
,
async
()
=>
{
textElement
.
value
=
'
2h20m
'
;
textElement
.
dispatchEvent
(
new
Event
(
'
input
'
));
await
wrapper
.
vm
.
$nextTick
();
expect
(
wrapper
.
emitted
(
'
change
'
)).
toEqual
([[
MOCK_VALUE
]]);
});
});
});
});
});
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