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
33576731
Commit
33576731
authored
Mar 04, 2021
by
Tristan Read
Committed by
Enrique Alcántara
Mar 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update on-call rotation time interval restrictions
parent
83b0a4b7
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
185 additions
and
142 deletions
+185
-142
ee/app/assets/javascripts/oncall_schedules/components/rotations/components/add_edit_rotation_form.vue
...omponents/rotations/components/add_edit_rotation_form.vue
+18
-9
ee/app/assets/javascripts/oncall_schedules/components/rotations/components/add_edit_rotation_modal.vue
...mponents/rotations/components/add_edit_rotation_modal.vue
+36
-23
ee/app/assets/javascripts/oncall_schedules/components/schedule/components/rotations_list_section.vue
...components/schedule/components/rotations_list_section.vue
+1
-0
ee/app/assets/javascripts/oncall_schedules/graphql/fragments/oncall_schedule_rotation.fragment.graphql
...aphql/fragments/oncall_schedule_rotation.fragment.graphql
+4
-0
ee/spec/frontend/oncall_schedule/mocks/apollo_mock.js
ee/spec/frontend/oncall_schedule/mocks/apollo_mock.js
+10
-0
ee/spec/frontend/oncall_schedule/mocks/mock_rotation.json
ee/spec/frontend/oncall_schedule/mocks/mock_rotation.json
+16
-0
ee/spec/frontend/oncall_schedule/rotations/components/add_edit_rotation_form_spec.js
...edule/rotations/components/add_edit_rotation_form_spec.js
+96
-108
ee/spec/frontend/oncall_schedule/rotations/components/add_edit_rotation_modal_spec.js
...dule/rotations/components/add_edit_rotation_modal_spec.js
+4
-2
No files found.
ee/app/assets/javascripts/oncall_schedules/components/rotations/components/add_edit_rotation_form.vue
View file @
33576731
...
@@ -101,7 +101,6 @@ export default {
...
@@ -101,7 +101,6 @@ export default {
return
{
return
{
participantsArr
:
[],
participantsArr
:
[],
endDateEnabled
:
false
,
endDateEnabled
:
false
,
restrictToTimeEnabled
:
false
,
};
};
},
},
methods
:
{
methods
:
{
...
@@ -295,15 +294,21 @@ export default {
...
@@ -295,15 +294,21 @@ export default {
</gl-card>
</gl-card>
<gl-toggle
<gl-toggle
v-model=
"restrictToTimeEnabled
"
:value=
"form.isRestrictedToTime
"
data-testid=
"restricted-to-toggle"
data-testid=
"restricted-to-toggle"
:label=
"$options.i18n.fields.restrictToTime.enableToggle"
:label=
"$options.i18n.fields.restrictToTime.enableToggle"
label-position=
"left"
label-position=
"left"
class=
"gl-mt-5"
class=
"gl-mt-5"
@
change=
"
$emit('update-rotation-form', {
type: 'isRestrictedToTime',
value: !form.isRestrictedToTime,
})
"
/>
/>
<gl-card
<gl-card
v-if=
"
restrictToTimeEnabled
"
v-if=
"
form.isRestrictedToTime
"
data-testid=
"restricted-to-time"
data-testid=
"restricted-to-time"
class=
"gl-mt-5 gl-border-gray-400 gl-bg-gray-10"
class=
"gl-mt-5 gl-border-gray-400 gl-bg-gray-10"
>
>
...
@@ -317,15 +322,17 @@ export default {
...
@@ -317,15 +322,17 @@ export default {
<span>
{{ __('From') }}
</span>
<span>
{{ __('From') }}
</span>
<gl-dropdown
<gl-dropdown
data-testid=
"restricted-from"
data-testid=
"restricted-from"
:text=
"format24HourTimeStringFromInt(form.restrictedTo.
from
)"
:text=
"format24HourTimeStringFromInt(form.restrictedTo.
startTime
)"
class=
"gl-px-3"
class=
"gl-px-3"
>
>
<gl-dropdown-item
<gl-dropdown-item
v-for=
"time in $options.HOURS_IN_DAY"
v-for=
"time in $options.HOURS_IN_DAY"
:key=
"time"
:key=
"time"
:is-checked=
"form.restrictedTo.
from
=== time"
:is-checked=
"form.restrictedTo.
startTime
=== time"
is-check-item
is-check-item
@
click=
"$emit('update-rotation-form', { type: 'restrictedTo.from', value: time })"
@
click=
"
$emit('update-rotation-form', { type: 'restrictedTo.startTime', value: time })
"
>
>
<span
class=
"gl-white-space-nowrap"
>
<span
class=
"gl-white-space-nowrap"
>
{{ format24HourTimeStringFromInt(time) }}
</span
{{ format24HourTimeStringFromInt(time) }}
</span
...
@@ -335,15 +342,17 @@ export default {
...
@@ -335,15 +342,17 @@ export default {
<span>
{{ __('To') }}
</span>
<span>
{{ __('To') }}
</span>
<gl-dropdown
<gl-dropdown
data-testid=
"restricted-to"
data-testid=
"restricted-to"
:text=
"format24HourTimeStringFromInt(form.restrictedTo.
to
)"
:text=
"format24HourTimeStringFromInt(form.restrictedTo.
endTime
)"
class=
"gl-px-3"
class=
"gl-px-3"
>
>
<gl-dropdown-item
<gl-dropdown-item
v-for=
"time in $options.HOURS_IN_DAY"
v-for=
"time in $options.HOURS_IN_DAY"
:key=
"time"
:key=
"time"
:is-checked=
"form.restrictedTo.
to
=== time"
:is-checked=
"form.restrictedTo.
endTime
=== time"
is-check-item
is-check-item
@
click=
"$emit('update-rotation-form', { type: 'restrictedTo.to', value: time })"
@
click=
"
$emit('update-rotation-form', { type: 'restrictedTo.endTime', value: time })
"
>
>
<span
class=
"gl-white-space-nowrap"
>
<span
class=
"gl-white-space-nowrap"
>
{{ format24HourTimeStringFromInt(time) }}
</span
{{ format24HourTimeStringFromInt(time) }}
</span
...
...
ee/app/assets/javascripts/oncall_schedules/components/rotations/components/add_edit_rotation_modal.vue
View file @
33576731
<
script
>
<
script
>
import
{
GlModal
,
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
GlModal
,
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
set
}
from
'
lodash
'
;
import
{
cloneDeep
,
set
}
from
'
lodash
'
;
import
{
LENGTH_ENUM
}
from
'
ee/oncall_schedules/constants
'
;
import
{
LENGTH_ENUM
}
from
'
ee/oncall_schedules/constants
'
;
import
createOncallScheduleRotationMutation
from
'
ee/oncall_schedules/graphql/mutations/create_oncall_schedule_rotation.mutation.graphql
'
;
import
createOncallScheduleRotationMutation
from
'
ee/oncall_schedules/graphql/mutations/create_oncall_schedule_rotation.mutation.graphql
'
;
import
updateOncallScheduleRotationMutation
from
'
ee/oncall_schedules/graphql/mutations/update_oncall_schedule_rotation.mutation.graphql
'
;
import
updateOncallScheduleRotationMutation
from
'
ee/oncall_schedules/graphql/mutations/update_oncall_schedule_rotation.mutation.graphql
'
;
...
@@ -21,9 +21,30 @@ export const i18n = {
...
@@ -21,9 +21,30 @@ export const i18n = {
cancel
:
__
(
'
Cancel
'
),
cancel
:
__
(
'
Cancel
'
),
};
};
export
const
formEmptyState
=
{
name
:
''
,
participants
:
[],
rotationLength
:
{
length
:
1
,
unit
:
LENGTH_ENUM
.
days
,
},
startsAt
:
{
date
:
null
,
time
:
0
,
},
endsAt
:
{
date
:
null
,
time
:
0
,
},
isRestrictedToTime
:
false
,
restrictedTo
:
{
startTime
:
0
,
endTime
:
0
,
},
};
export
default
{
export
default
{
i18n
,
i18n
,
LENGTH_ENUM
,
components
:
{
components
:
{
GlModal
,
GlModal
,
GlAlert
,
GlAlert
,
...
@@ -67,26 +88,7 @@ export default {
...
@@ -67,26 +88,7 @@ export default {
participants
:
[],
participants
:
[],
loading
:
false
,
loading
:
false
,
ptSearchTerm
:
''
,
ptSearchTerm
:
''
,
form
:
{
form
:
cloneDeep
(
formEmptyState
),
name
:
''
,
participants
:
[],
rotationLength
:
{
length
:
1
,
unit
:
this
.
$options
.
LENGTH_ENUM
.
days
,
},
startsAt
:
{
date
:
null
,
time
:
0
,
},
endsAt
:
{
date
:
null
,
time
:
0
,
},
restrictedTo
:
{
from
:
0
,
to
:
0
,
},
},
error
:
''
,
error
:
''
,
validationState
:
{
validationState
:
{
name
:
true
,
name
:
true
,
...
@@ -134,7 +136,7 @@ export default {
...
@@ -134,7 +136,7 @@ export default {
endsAt
:
{
date
:
endDate
,
time
:
endTime
},
endsAt
:
{
date
:
endDate
,
time
:
endTime
},
}
=
this
.
form
;
}
=
this
.
form
;
return
{
const
variables
=
{
projectPath
:
this
.
projectPath
,
projectPath
:
this
.
projectPath
,
scheduleIid
:
this
.
schedule
.
iid
,
scheduleIid
:
this
.
schedule
.
iid
,
name
,
name
,
...
@@ -154,6 +156,13 @@ export default {
...
@@ -154,6 +156,13 @@ export default {
},
},
participants
:
getParticipantsForSave
(
participants
),
participants
:
getParticipantsForSave
(
participants
),
};
};
if
(
this
.
form
.
isRestrictedToTime
)
{
variables
.
activePeriod
=
{
startTime
:
format24HourTimeStringFromInt
(
this
.
form
.
restrictedTo
.
startTime
),
endTime
:
format24HourTimeStringFromInt
(
this
.
form
.
restrictedTo
.
endTime
),
};
}
return
variables
;
},
},
title
()
{
title
()
{
return
this
.
isEditMode
?
this
.
$options
.
i18n
.
editRotation
:
this
.
$options
.
i18n
.
addRotation
;
return
this
.
isEditMode
?
this
.
$options
.
i18n
.
editRotation
:
this
.
$options
.
i18n
.
addRotation
;
...
@@ -273,6 +282,9 @@ export default {
...
@@ -273,6 +282,9 @@ export default {
this
.
validationState
.
endsAt
=
this
.
isEndDateValid
;
this
.
validationState
.
endsAt
=
this
.
isEndDateValid
;
}
}
},
},
afterCloseModal
()
{
this
.
form
=
cloneDeep
(
formEmptyState
);
},
},
},
};
};
</
script
>
</
script
>
...
@@ -286,6 +298,7 @@ export default {
...
@@ -286,6 +298,7 @@ export default {
:action-cancel=
"actionsProps.cancel"
:action-cancel=
"actionsProps.cancel"
modal-class=
"rotations-modal"
modal-class=
"rotations-modal"
@
primary.prevent=
"isEditMode ? editRotation() : createRotation()"
@
primary.prevent=
"isEditMode ? editRotation() : createRotation()"
@
hide=
"afterCloseModal"
>
>
<gl-alert
v-if=
"error"
variant=
"danger"
@
dismiss=
"error = ''"
>
<gl-alert
v-if=
"error"
variant=
"danger"
@
dismiss=
"error = ''"
>
{{
error
||
$options
.
i18n
.
errorMsg
}}
{{
error
||
$options
.
i18n
.
errorMsg
}}
...
...
ee/app/assets/javascripts/oncall_schedules/components/schedule/components/rotations_list_section.vue
View file @
33576731
...
@@ -135,6 +135,7 @@ export default {
...
@@ -135,6 +135,7 @@ export default {
:title=
"$options.i18n.editRotationLabel"
:title=
"$options.i18n.editRotationLabel"
icon=
"pencil"
icon=
"pencil"
:aria-label=
"$options.i18n.editRotationLabel"
:aria-label=
"$options.i18n.editRotationLabel"
@
click=
"setRotationToUpdate(rotation)"
/>
/>
<gl-button
<gl-button
v-gl-modal=
"$options.deleteRotationModalId"
v-gl-modal=
"$options.deleteRotationModalId"
...
...
ee/app/assets/javascripts/oncall_schedules/graphql/fragments/oncall_schedule_rotation.fragment.graphql
View file @
33576731
...
@@ -7,6 +7,10 @@ fragment OnCallRotation on IncidentManagementOncallRotation {
...
@@ -7,6 +7,10 @@ fragment OnCallRotation on IncidentManagementOncallRotation {
endsAt
endsAt
length
length
lengthUnit
lengthUnit
activePeriod
{
startTime
endTime
}
participants
{
participants
{
nodes
{
nodes
{
...
OnCallParticipant
...
OnCallParticipant
...
...
ee/spec/frontend/oncall_schedule/mocks/apollo_mock.js
View file @
33576731
...
@@ -10,6 +10,7 @@ export const participants = [
...
@@ -10,6 +10,7 @@ export const participants = [
name
:
'
test
'
,
name
:
'
test
'
,
avatar
:
''
,
avatar
:
''
,
avatarUrl
:
''
,
avatarUrl
:
''
,
webUrl
:
''
,
},
},
{
{
id
:
'
2
'
,
id
:
'
2
'
,
...
@@ -17,6 +18,7 @@ export const participants = [
...
@@ -17,6 +18,7 @@ export const participants = [
name
:
'
hello
'
,
name
:
'
hello
'
,
avatar
:
''
,
avatar
:
''
,
avatarUrl
:
''
,
avatarUrl
:
''
,
webUrl
:
''
,
},
},
];
];
...
@@ -142,6 +144,10 @@ export const createRotationResponse = {
...
@@ -142,6 +144,10 @@ export const createRotationResponse = {
endsAt
:
'
2021-03-17T12:00:00Z
'
,
endsAt
:
'
2021-03-17T12:00:00Z
'
,
length
:
5
,
length
:
5
,
lengthUnit
:
'
WEEKS
'
,
lengthUnit
:
'
WEEKS
'
,
activePeriod
:
{
startTime
:
'
02:00
'
,
endTime
:
'
10:00
'
,
},
participants
:
{
participants
:
{
nodes
:
[
nodes
:
[
{
{
...
@@ -176,6 +182,10 @@ export const createRotationResponseWithErrors = {
...
@@ -176,6 +182,10 @@ export const createRotationResponseWithErrors = {
endsAt
:
'
2021-03-17T12:00:00Z
'
,
endsAt
:
'
2021-03-17T12:00:00Z
'
,
length
:
5
,
length
:
5
,
lengthUnit
:
'
WEEKS
'
,
lengthUnit
:
'
WEEKS
'
,
activePeriod
:
{
startTime
:
'
02:00
'
,
endTime
:
'
10:00
'
,
},
participants
:
{
participants
:
{
nodes
:
[
nodes
:
[
{
{
...
...
ee/spec/frontend/oncall_schedule/mocks/mock_rotation.json
View file @
33576731
...
@@ -5,6 +5,10 @@
...
@@ -5,6 +5,10 @@
"endsAt"
:
"2021-03-13T10:04:56.333Z"
,
"endsAt"
:
"2021-03-13T10:04:56.333Z"
,
"length"
:
1
,
"length"
:
1
,
"lengthUnit"
:
"WEEKS"
,
"lengthUnit"
:
"WEEKS"
,
"activePeriod"
:
{
"startTime"
:
"02:00"
,
"endTime"
:
"10:00"
},
"participants"
:
{
"participants"
:
{
"nodes"
:
[
"nodes"
:
[
{
{
...
@@ -58,6 +62,10 @@
...
@@ -58,6 +62,10 @@
"endsAt"
:
"2021-03-13T10:04:56.333Z"
,
"endsAt"
:
"2021-03-13T10:04:56.333Z"
,
"length"
:
1
,
"length"
:
1
,
"lengthUnit"
:
"WEEKS"
,
"lengthUnit"
:
"WEEKS"
,
"activePeriod"
:
{
"startTime"
:
"02:00"
,
"endTime"
:
"10:00"
},
"participants"
:
{
"participants"
:
{
"nodes"
:
[
"nodes"
:
[
{
{
...
@@ -107,6 +115,10 @@
...
@@ -107,6 +115,10 @@
"endsAt"
:
"2021-01-10T10:04:56.333Z"
,
"endsAt"
:
"2021-01-10T10:04:56.333Z"
,
"length"
:
1
,
"length"
:
1
,
"lengthUnit"
:
"WEEKS"
,
"lengthUnit"
:
"WEEKS"
,
"activePeriod"
:
{
"startTime"
:
"02:00"
,
"endTime"
:
"10:00"
},
"participants"
:
{
"participants"
:
{
"nodes"
:
[
"nodes"
:
[
{
{
...
@@ -156,6 +168,10 @@
...
@@ -156,6 +168,10 @@
"endsAt"
:
"2021-01-11T10:04:56.333Z"
,
"endsAt"
:
"2021-01-11T10:04:56.333Z"
,
"length"
:
1
,
"length"
:
1
,
"lengthUnit"
:
"WEEKS"
,
"lengthUnit"
:
"WEEKS"
,
"activePeriod"
:
{
"startTime"
:
"02:00"
,
"endTime"
:
"10:00"
},
"participants"
:
{
"participants"
:
{
"nodes"
:
[
"nodes"
:
[
{
{
...
...
ee/spec/frontend/oncall_schedule/rotations/components/add_edit_rotation_form_spec.js
View file @
33576731
import
{
GlDropdownItem
,
GlTokenSelector
,
GlFormGroup
,
GlToggle
}
from
'
@gitlab/ui
'
;
import
{
GlDropdownItem
,
GlTokenSelector
,
GlFormGroup
,
GlToggle
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
cloneDeep
,
merge
}
from
'
lodash
'
;
import
AddEditRotationForm
from
'
ee/oncall_schedules/components/rotations/components/add_edit_rotation_form.vue
'
;
import
AddEditRotationForm
from
'
ee/oncall_schedules/components/rotations/components/add_edit_rotation_form.vue
'
;
import
{
formEmptyState
}
from
'
ee/oncall_schedules/components/rotations/components/add_edit_rotation_modal.vue
'
;
import
{
LENGTH_ENUM
}
from
'
ee/oncall_schedules/constants
'
;
import
{
LENGTH_ENUM
}
from
'
ee/oncall_schedules/constants
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
{
participants
,
getOncallSchedulesQueryResponse
}
from
'
../../mocks/apollo_mock
'
;
import
{
participants
,
getOncallSchedulesQueryResponse
}
from
'
../../mocks/apollo_mock
'
;
const
projectPath
=
'
group/project
'
;
const
projectPath
=
'
group/project
'
;
...
@@ -19,47 +20,26 @@ describe('AddEditRotationForm', () => {
...
@@ -19,47 +20,26 @@ describe('AddEditRotationForm', () => {
...
data
,
...
data
,
};
};
},
},
propsData
:
{
propsData
:
merge
(
...
props
,
{
schedule
,
schedule
,
isLoading
:
false
,
isLoading
:
false
,
validationState
:
{
validationState
:
{
name
:
true
,
name
:
true
,
participants
:
false
,
participants
:
false
,
startsAt
:
false
,
startsAt
:
false
,
},
participants
,
form
:
{
name
:
''
,
participants
:
[],
rotationLength
:
{
length
:
1
,
unit
:
LENGTH_ENUM
.
hours
,
},
startsAt
:
{
date
:
null
,
time
:
0
,
},
endsAt
:
{
date
:
null
,
time
:
0
,
},
restrictedTo
:
{
from
:
0
,
to
:
0
,
},
},
participants
,
form
:
cloneDeep
(
formEmptyState
),
},
},
},
props
,
),
provide
:
{
provide
:
{
projectPath
,
projectPath
,
},
},
});
});
};
};
beforeEach
(()
=>
{
createComponent
();
});
afterEach
(()
=>
{
afterEach
(()
=>
{
if
(
wrapper
)
{
if
(
wrapper
)
{
wrapper
.
destroy
();
wrapper
.
destroy
();
...
@@ -75,7 +55,6 @@ describe('AddEditRotationForm', () => {
...
@@ -75,7 +55,6 @@ describe('AddEditRotationForm', () => {
const
findRotationFormGroups
=
()
=>
wrapper
.
findAllComponents
(
GlFormGroup
);
const
findRotationFormGroups
=
()
=>
wrapper
.
findAllComponents
(
GlFormGroup
);
const
findStartsOnTimeOptions
=
()
=>
findRotationStartTime
().
findAllComponents
(
GlDropdownItem
);
const
findStartsOnTimeOptions
=
()
=>
findRotationStartTime
().
findAllComponents
(
GlDropdownItem
);
const
findEndsOnTimeOptions
=
()
=>
findRotationEndTime
().
findAllComponents
(
GlDropdownItem
);
const
findEndsOnTimeOptions
=
()
=>
findRotationEndTime
().
findAllComponents
(
GlDropdownItem
);
const
findRestrictedToTime
=
()
=>
wrapper
.
find
(
'
[data-testid="restricted-to-time"]
'
);
const
findRestrictedToToggle
=
()
=>
wrapper
.
find
(
'
[data-testid="restricted-to-toggle"]
'
);
const
findRestrictedToToggle
=
()
=>
wrapper
.
find
(
'
[data-testid="restricted-to-toggle"]
'
);
const
findRestrictedFromOptions
=
()
=>
const
findRestrictedFromOptions
=
()
=>
wrapper
.
find
(
'
[data-testid="restricted-from"]
'
).
findAllComponents
(
GlDropdownItem
);
wrapper
.
find
(
'
[data-testid="restricted-from"]
'
).
findAllComponents
(
GlDropdownItem
);
...
@@ -83,6 +62,10 @@ describe('AddEditRotationForm', () => {
...
@@ -83,6 +62,10 @@ describe('AddEditRotationForm', () => {
wrapper
.
find
(
'
[data-testid="restricted-to"]
'
).
findAllComponents
(
GlDropdownItem
);
wrapper
.
find
(
'
[data-testid="restricted-to"]
'
).
findAllComponents
(
GlDropdownItem
);
describe
(
'
Rotation form validation
'
,
()
=>
{
describe
(
'
Rotation form validation
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
();
});
it
.
each
`
it
.
each
`
index | type | validationState | value
index | type | validationState | value
${
0
}
|
${
'
name
'
}
|
${
true
}
|
${
'
true
'
}
${
0
}
|
${
'
name
'
}
|
${
true
}
|
${
'
true
'
}
...
@@ -99,12 +82,14 @@ describe('AddEditRotationForm', () => {
...
@@ -99,12 +82,14 @@ describe('AddEditRotationForm', () => {
describe
(
'
Rotation length and start time
'
,
()
=>
{
describe
(
'
Rotation length and start time
'
,
()
=>
{
it
(
'
renders the rotation length value
'
,
async
()
=>
{
it
(
'
renders the rotation length value
'
,
async
()
=>
{
createComponent
();
const
rotationLength
=
findRotationLength
();
const
rotationLength
=
findRotationLength
();
expect
(
rotationLength
.
exists
()).
toBe
(
true
);
expect
(
rotationLength
.
exists
()).
toBe
(
true
);
expect
(
rotationLength
.
attributes
(
'
value
'
)).
toBe
(
'
1
'
);
expect
(
rotationLength
.
attributes
(
'
value
'
)).
toBe
(
'
1
'
);
});
});
it
(
'
renders the rotation starts on datepicker
'
,
async
()
=>
{
it
(
'
renders the rotation starts on datepicker
'
,
async
()
=>
{
createComponent
();
const
startsOn
=
findRotationStartTime
();
const
startsOn
=
findRotationStartTime
();
expect
(
startsOn
.
exists
()).
toBe
(
true
);
expect
(
startsOn
.
exists
()).
toBe
(
true
);
expect
(
startsOn
.
attributes
(
'
text
'
)).
toBe
(
'
00:00
'
);
expect
(
startsOn
.
attributes
(
'
text
'
)).
toBe
(
'
00:00
'
);
...
@@ -113,8 +98,8 @@ describe('AddEditRotationForm', () => {
...
@@ -113,8 +98,8 @@ describe('AddEditRotationForm', () => {
it
(
'
should emit an event with selected value on time selection
'
,
async
()
=>
{
it
(
'
should emit an event with selected value on time selection
'
,
async
()
=>
{
const
option
=
3
;
const
option
=
3
;
createComponent
();
findStartsOnTimeOptions
().
at
(
option
).
vm
.
$emit
(
'
click
'
);
findStartsOnTimeOptions
().
at
(
option
).
vm
.
$emit
(
'
click
'
);
await
wrapper
.
vm
.
$nextTick
();
const
emittedEvent
=
wrapper
.
emitted
(
'
update-rotation-form
'
);
const
emittedEvent
=
wrapper
.
emitted
(
'
update-rotation-form
'
);
expect
(
emittedEvent
).
toHaveLength
(
1
);
expect
(
emittedEvent
).
toHaveLength
(
1
);
expect
(
emittedEvent
[
0
][
0
]).
toEqual
({
type
:
'
startsAt.time
'
,
value
:
option
});
expect
(
emittedEvent
[
0
][
0
]).
toEqual
({
type
:
'
startsAt.time
'
,
value
:
option
});
...
@@ -122,14 +107,16 @@ describe('AddEditRotationForm', () => {
...
@@ -122,14 +107,16 @@ describe('AddEditRotationForm', () => {
it
(
'
should add a checkmark to a selected start time
'
,
async
()
=>
{
it
(
'
should add a checkmark to a selected start time
'
,
async
()
=>
{
const
time
=
7
;
const
time
=
7
;
wrapper
.
setProps
({
createComponent
({
form
:
{
props
:
{
startsAt
:
{
form
:
{
time
,
startsAt
:
{
},
time
,
rotationLength
:
{
},
length
:
1
,
rotationLength
:
{
unit
:
LENGTH_ENUM
.
hours
,
length
:
1
,
unit
:
LENGTH_ENUM
.
hours
,
},
},
},
},
},
});
});
...
@@ -140,9 +127,9 @@ describe('AddEditRotationForm', () => {
...
@@ -140,9 +127,9 @@ describe('AddEditRotationForm', () => {
describe
(
'
Rotation end time
'
,
()
=>
{
describe
(
'
Rotation end time
'
,
()
=>
{
it
(
'
toggles end time visibility
'
,
async
()
=>
{
it
(
'
toggles end time visibility
'
,
async
()
=>
{
createComponent
();
const
toggle
=
findEndDateToggle
().
vm
;
const
toggle
=
findEndDateToggle
().
vm
;
toggle
.
$emit
(
'
change
'
,
false
);
toggle
.
$emit
(
'
change
'
,
false
);
await
wrapper
.
vm
.
$nextTick
();
expect
(
findRotationEndsContainer
().
exists
()).
toBe
(
false
);
expect
(
findRotationEndsContainer
().
exists
()).
toBe
(
false
);
toggle
.
$emit
(
'
change
'
,
true
);
toggle
.
$emit
(
'
change
'
,
true
);
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
...
@@ -150,97 +137,102 @@ describe('AddEditRotationForm', () => {
...
@@ -150,97 +137,102 @@ describe('AddEditRotationForm', () => {
});
});
it
(
'
should emit an event with selected value on time selection
'
,
async
()
=>
{
it
(
'
should emit an event with selected value on time selection
'
,
async
()
=>
{
createComponent
();
findEndDateToggle
().
vm
.
$emit
(
'
change
'
,
true
);
findEndDateToggle
().
vm
.
$emit
(
'
change
'
,
true
);
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
const
option
=
3
;
const
option
=
3
;
findEndsOnTimeOptions
().
at
(
option
).
vm
.
$emit
(
'
click
'
);
findEndsOnTimeOptions
().
at
(
option
).
vm
.
$emit
(
'
click
'
);
await
wrapper
.
vm
.
$nextTick
();
const
emittedEvent
=
wrapper
.
emitted
(
'
update-rotation-form
'
);
const
emittedEvent
=
wrapper
.
emitted
(
'
update-rotation-form
'
);
expect
(
emittedEvent
).
toHaveLength
(
1
);
expect
(
emittedEvent
).
toHaveLength
(
1
);
expect
(
emittedEvent
[
0
][
0
]).
toEqual
({
type
:
'
endsAt.time
'
,
value
:
option
});
expect
(
emittedEvent
[
0
][
0
]).
toEqual
({
type
:
'
endsAt.time
'
,
value
:
option
});
});
});
it
(
'
should add a checkmark to a selected end time
'
,
async
()
=>
{
it
(
'
should add a checkmark to a selected end time
'
,
async
()
=>
{
findEndDateToggle
().
vm
.
$emit
(
'
change
'
,
true
);
const
time
=
5
;
const
time
=
5
;
wrapper
.
setProps
({
createComponent
({
form
:
{
props
:
{
endsAt
:
{
form
:
{
time
,
endsAt
:
{
},
time
,
startsAt
:
{
},
time
:
0
,
startsAt
:
{
},
time
:
0
,
rotationLength
:
{
},
length
:
1
,
rotationLength
:
{
unit
:
LENGTH_ENUM
.
hours
,
length
:
1
,
unit
:
LENGTH_ENUM
.
hours
,
},
},
},
},
},
});
});
findEndDateToggle
().
vm
.
$emit
(
'
change
'
,
true
);
await
wrapper
.
vm
.
$nextTick
();
await
wrapper
.
vm
.
$nextTick
();
expect
(
findEndsOnTimeOptions
().
at
(
time
).
props
(
'
isChecked
'
)).
toBe
(
true
);
expect
(
findEndsOnTimeOptions
().
at
(
time
).
props
(
'
isChecked
'
)).
toBe
(
true
);
});
});
});
});
describe
(
'
Rotation restricted to time
'
,
()
=>
{
describe
(
'
Rotation restricted to time
'
,
()
=>
{
it
(
'
toggles restricted to time visibility
'
,
async
()
=>
{
it
(
'
toggle state depends on isRestrictedToTime
'
,
async
()
=>
{
createComponent
();
expect
(
findRestrictedToToggle
().
props
(
'
value
'
)).
toBe
(
false
);
createComponent
({
props
:
{
form
:
{
...
formEmptyState
,
isRestrictedToTime
:
true
}
}
});
expect
(
findRestrictedToToggle
().
props
(
'
value
'
)).
toBe
(
true
);
});
it
(
'
toggles end time visibility on
'
,
async
()
=>
{
createComponent
();
const
toggle
=
findRestrictedToToggle
().
vm
;
const
toggle
=
findRestrictedToToggle
().
vm
;
toggle
.
$emit
(
'
change
'
,
false
);
await
wrapper
.
vm
.
$nextTick
();
expect
(
findRestrictedToTime
().
exists
()).
toBe
(
false
);
toggle
.
$emit
(
'
change
'
,
true
);
toggle
.
$emit
(
'
change
'
,
true
);
await
wrapper
.
vm
.
$nextTick
();
const
emittedEvent
=
wrapper
.
emitted
(
'
update-rotation-form
'
);
expect
(
findRestrictedToTime
().
exists
()).
toBe
(
true
);
expect
(
emittedEvent
).
toHaveLength
(
1
);
expect
(
emittedEvent
[
0
][
0
]).
toEqual
({
type
:
'
isRestrictedToTime
'
,
value
:
true
});
});
});
it
(
'
should emit an event with selected value on restricted FROM time selection
'
,
async
()
=>
{
it
(
'
toggles end time visibility off
'
,
async
()
=>
{
findRestrictedToToggle
().
vm
.
$emit
(
'
change
'
,
true
);
createComponent
({
props
:
{
form
:
{
...
formEmptyState
,
isRestrictedToTime
:
true
}
}
});
await
wrapper
.
vm
.
$nextTick
();
const
toggle
=
findRestrictedToToggle
().
vm
;
const
timeFrom
=
5
;
toggle
.
$emit
(
'
change
'
,
false
);
const
timeTo
=
22
;
findRestrictedFromOptions
().
at
(
timeFrom
).
vm
.
$emit
(
'
click
'
);
findRestrictedToOptions
().
at
(
timeTo
).
vm
.
$emit
(
'
click
'
);
await
wrapper
.
vm
.
$nextTick
();
const
emittedEvent
=
wrapper
.
emitted
(
'
update-rotation-form
'
);
const
emittedEvent
=
wrapper
.
emitted
(
'
update-rotation-form
'
);
expect
(
emittedEvent
).
toHaveLength
(
2
);
expect
(
emittedEvent
).
toHaveLength
(
1
);
expect
(
emittedEvent
[
0
][
0
]).
toEqual
({
type
:
'
restrictedTo.from
'
,
value
:
timeFrom
+
1
});
expect
(
emittedEvent
[
0
][
0
]).
toEqual
({
type
:
'
isRestrictedToTime
'
,
value
:
false
});
expect
(
emittedEvent
[
1
][
0
]).
toEqual
({
type
:
'
restrictedTo.to
'
,
value
:
timeTo
+
1
});
});
});
it
(
'
should add a checkmark to a selected restricted FROM time
'
,
async
()
=>
{
describe
(
'
when a rotation restriction is selected
'
,
()
=>
{
findRestrictedToToggle
().
vm
.
$emit
(
'
change
'
,
true
);
const
timeFrom
=
5
;
const
timeFrom
=
5
;
const
timeTo
=
22
;
const
timeTo
=
22
;
wrapper
.
setProps
({
it
(
'
should emit an event with selected value on restricted FROM time selection
'
,
async
()
=>
{
form
:
{
createComponent
({
props
:
{
form
:
{
...
formEmptyState
,
isRestrictedToTime
:
true
}
}
});
endsAt
:
{
findRestrictedFromOptions
().
at
(
timeFrom
).
vm
.
$emit
(
'
click
'
);
time
:
0
,
findRestrictedToOptions
().
at
(
timeTo
).
vm
.
$emit
(
'
click
'
);
},
const
emittedEvent
=
wrapper
.
emitted
(
'
update-rotation-form
'
);
startsAt
:
{
expect
(
emittedEvent
).
toHaveLength
(
2
);
time
:
0
,
expect
(
emittedEvent
[
0
][
0
]).
toEqual
({
type
:
'
restrictedTo.startTime
'
,
value
:
timeFrom
+
1
});
},
expect
(
emittedEvent
[
1
][
0
]).
toEqual
({
type
:
'
restrictedTo.endTime
'
,
value
:
timeTo
+
1
});
restrictedTo
:
{
});
from
:
timeFrom
,
to
:
timeTo
,
it
(
'
should add a checkmark to a selected restricted FROM time
'
,
async
()
=>
{
},
createComponent
({
rotationLength
:
{
props
:
{
length
:
1
,
form
:
{
unit
:
LENGTH_ENUM
.
hours
,
...
formEmptyState
,
isRestrictedToTime
:
true
,
restrictedTo
:
{
startTime
:
timeFrom
,
endTime
:
timeTo
},
},
},
},
},
});
expect
(
findRestrictedFromOptions
()
.
at
(
timeFrom
-
1
)
.
props
(
'
isChecked
'
),
).
toBe
(
true
);
expect
(
findRestrictedToOptions
()
.
at
(
timeTo
-
1
)
.
props
(
'
isChecked
'
),
).
toBe
(
true
);
});
});
await
wrapper
.
vm
.
$nextTick
();
expect
(
findRestrictedFromOptions
()
.
at
(
timeFrom
-
1
)
.
props
(
'
isChecked
'
),
).
toBe
(
true
);
expect
(
findRestrictedToOptions
()
.
at
(
timeTo
-
1
)
.
props
(
'
isChecked
'
),
).
toBe
(
true
);
});
});
});
});
...
@@ -260,8 +252,6 @@ describe('AddEditRotationForm', () => {
...
@@ -260,8 +252,6 @@ describe('AddEditRotationForm', () => {
tokenSelector
.
vm
.
$emit
(
'
blur
'
);
tokenSelector
.
vm
.
$emit
(
'
blur
'
);
tokenSelector
.
vm
.
$emit
(
'
focus
'
);
tokenSelector
.
vm
.
$emit
(
'
focus
'
);
await
waitForPromises
();
expect
(
tokenSelector
.
props
(
'
dropdownItems
'
)).
toMatchObject
(
participants
);
expect
(
tokenSelector
.
props
(
'
dropdownItems
'
)).
toMatchObject
(
participants
);
expect
(
tokenSelector
.
props
(
'
hideDropdownWithNoItems
'
)).
toBe
(
false
);
expect
(
tokenSelector
.
props
(
'
hideDropdownWithNoItems
'
)).
toBe
(
false
);
});
});
...
@@ -276,8 +266,6 @@ describe('AddEditRotationForm', () => {
...
@@ -276,8 +266,6 @@ describe('AddEditRotationForm', () => {
const
tokenSelector
=
findUserSelector
();
const
tokenSelector
=
findUserSelector
();
tokenSelector
.
vm
.
$emit
(
'
blur
'
);
tokenSelector
.
vm
.
$emit
(
'
blur
'
);
await
wrapper
.
vm
.
$nextTick
();
expect
(
tokenSelector
.
props
(
'
hideDropdownWithNoItems
'
)).
toBe
(
false
);
expect
(
tokenSelector
.
props
(
'
hideDropdownWithNoItems
'
)).
toBe
(
false
);
});
});
});
});
...
...
ee/spec/frontend/oncall_schedule/rotations/components/add_edit_rotation_modal_spec.js
View file @
33576731
import
{
Gl
Modal
,
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
Gl
Alert
,
GlModal
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
createLocalVue
,
shallowMount
}
from
'
@vue/test-utils
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
AddEditRotationForm
from
'
ee/oncall_schedules/components/rotations/components/add_edit_rotation_form.vue
'
;
import
AddEditRotationForm
from
'
ee/oncall_schedules/components/rotations/components/add_edit_rotation_form.vue
'
;
import
AddEditRotationModal
,
{
import
AddEditRotationModal
,
{
...
@@ -18,6 +18,7 @@ import {
...
@@ -18,6 +18,7 @@ import {
createRotationResponse
,
createRotationResponse
,
createRotationResponseWithErrors
,
createRotationResponseWithErrors
,
}
from
'
../../mocks/apollo_mock
'
;
}
from
'
../../mocks/apollo_mock
'
;
import
mockRotation
from
'
../../mocks/mock_rotation.json
'
;
jest
.
mock
(
'
~/flash
'
);
jest
.
mock
(
'
~/flash
'
);
...
@@ -102,6 +103,7 @@ describe('AddEditRotationModal', () => {
...
@@ -102,6 +103,7 @@ describe('AddEditRotationModal', () => {
propsData
:
{
propsData
:
{
modalId
:
addRotationModalId
,
modalId
:
addRotationModalId
,
schedule
,
schedule
,
rotation
:
mockRotation
[
0
],
},
},
apolloProvider
:
fakeApollo
,
apolloProvider
:
fakeApollo
,
data
()
{
data
()
{
...
...
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