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
e5e8441a
Commit
e5e8441a
authored
Jan 08, 2021
by
David O'Regan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(feedback): apply merge feedback
fix(feedback): apply merge feedback
parent
f10e7bcf
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
439 additions
and
25 deletions
+439
-25
config/known_invalid_graphql_queries.yml
config/known_invalid_graphql_queries.yml
+1
-0
ee/app/assets/javascripts/oncall_schedules/components/rotations/components/delete_rotation_modal.vue
...components/rotations/components/delete_rotation_modal.vue
+118
-0
ee/app/assets/javascripts/oncall_schedules/components/schedule/components/rotations_list_section.vue
...components/schedule/components/rotations_list_section.vue
+21
-2
ee/app/assets/javascripts/oncall_schedules/constants.js
ee/app/assets/javascripts/oncall_schedules/constants.js
+1
-0
ee/app/assets/javascripts/oncall_schedules/graphql/mutations/destroy_oncall_rotation.mutation.graphql
...raphql/mutations/destroy_oncall_rotation.mutation.graphql
+10
-0
ee/app/assets/javascripts/oncall_schedules/utils/cache_updates.js
...ssets/javascripts/oncall_schedules/utils/cache_updates.js
+35
-0
ee/app/assets/javascripts/oncall_schedules/utils/error_messages.js
...sets/javascripts/oncall_schedules/utils/error_messages.js
+4
-0
ee/spec/frontend/oncall_schedule/add_edit_schedule_form_spec.js
...c/frontend/oncall_schedule/add_edit_schedule_form_spec.js
+0
-1
ee/spec/frontend/oncall_schedule/delete_schedule_modal_spec.js
...ec/frontend/oncall_schedule/delete_schedule_modal_spec.js
+0
-6
ee/spec/frontend/oncall_schedule/mocks/apollo_mock.js
ee/spec/frontend/oncall_schedule/mocks/apollo_mock.js
+26
-0
ee/spec/frontend/oncall_schedule/oncall_schedule_spec.js
ee/spec/frontend/oncall_schedule/oncall_schedule_spec.js
+2
-3
ee/spec/frontend/oncall_schedule/rotations/components/__snapshots__/delete_rotation_modal_spec.js.snap
...mponents/__snapshots__/delete_rotation_modal_spec.js.snap
+20
-0
ee/spec/frontend/oncall_schedule/rotations/components/add_edit_rotation_modal_spec.js
...dule/rotations/components/add_edit_rotation_modal_spec.js
+0
-1
ee/spec/frontend/oncall_schedule/rotations/components/delete_rotation_modal_spec.js
...hedule/rotations/components/delete_rotation_modal_spec.js
+182
-0
ee/spec/frontend/oncall_schedule/rotations/components/rotation_assignee_spec.js
...l_schedule/rotations/components/rotation_assignee_spec.js
+2
-3
ee/spec/frontend/oncall_schedule/schedule/components/__snapshots__/rotations_list_section_spec.js.snap
...ponents/__snapshots__/rotations_list_section_spec.js.snap
+5
-0
ee/spec/frontend/oncall_schedule/schedule/components/current_day_indicator_spec.js
...chedule/schedule/components/current_day_indicator_spec.js
+2
-3
ee/spec/frontend/oncall_schedule/schedule/components/rotations_list_section_spec.js
...hedule/schedule/components/rotations_list_section_spec.js
+2
-3
ee/spec/frontend/oncall_schedule/schedule/components/schedule_timeline_section_spec.js
...ule/schedule/components/schedule_timeline_section_spec.js
+2
-3
locale/gitlab.pot
locale/gitlab.pot
+6
-0
No files found.
config/known_invalid_graphql_queries.yml
View file @
e5e8441a
...
@@ -2,3 +2,4 @@
...
@@ -2,3 +2,4 @@
filenames
:
filenames
:
-
ee/app/assets/javascripts/on_demand_scans/graphql/dast_scan_create.mutation.graphql
-
ee/app/assets/javascripts/on_demand_scans/graphql/dast_scan_create.mutation.graphql
-
ee/app/assets/javascripts/oncall_schedules/graphql/mutations/update_oncall_schedule_rotation.mutation.graphql
-
ee/app/assets/javascripts/oncall_schedules/graphql/mutations/update_oncall_schedule_rotation.mutation.graphql
-
ee/app/assets/javascripts/oncall_schedules/graphql/mutations/destroy_oncall_rotation.mutation.graphql
ee/app/assets/javascripts/oncall_schedules/components/rotations/components/delete_rotation_modal.vue
0 → 100644
View file @
e5e8441a
<
script
>
import
{
isEmpty
}
from
'
lodash
'
;
import
{
GlSprintf
,
GlModal
,
GlAlert
}
from
'
@gitlab/ui
'
;
import
destroyOncallRotationMutation
from
'
ee/oncall_schedules/graphql/mutations/destroy_oncall_rotation.mutation.graphql
'
;
import
getOncallSchedulesQuery
from
'
ee/oncall_schedules/graphql/queries/get_oncall_schedules.query.graphql
'
;
import
{
updateStoreAfterRotationDelete
}
from
'
ee/oncall_schedules/utils/cache_updates
'
;
import
{
s__
,
__
}
from
'
~/locale
'
;
export
const
i18n
=
{
deleteRotation
:
s__
(
'
OnCallSchedules|Delete rotation
'
),
deleteRotationMessage
:
s__
(
'
OnCallSchedules|Are you sure you want to delete the "%{deleteRotation}" rotation? This action cannot be undone.
'
,
),
cancel
:
__
(
'
Cancel
'
),
};
export
default
{
i18n
,
components
:
{
GlSprintf
,
GlModal
,
GlAlert
,
},
inject
:
[
'
projectPath
'
],
props
:
{
rotation
:
{
type
:
Object
,
required
:
true
,
validator
:
(
rotation
)
=>
isEmpty
(
rotation
)
||
[
rotation
.
id
,
rotation
.
name
,
rotation
.
startsAt
].
every
(
Boolean
),
},
modalId
:
{
type
:
String
,
required
:
true
,
},
},
data
()
{
return
{
loading
:
false
,
error
:
''
,
};
},
computed
:
{
primaryProps
()
{
return
{
text
:
this
.
$options
.
i18n
.
deleteRotation
,
attributes
:
[{
category
:
'
primary
'
},
{
variant
:
'
danger
'
},
{
loading
:
this
.
loading
}],
};
},
cancelProps
()
{
return
{
text
:
this
.
$options
.
i18n
.
cancel
,
};
},
rotationDeleteModalTestId
()
{
return
`delete-rotation-modal-
${
this
.
rotation
.
id
}
`
;
},
},
methods
:
{
deleteRotation
()
{
const
{
projectPath
,
rotation
:
{
id
},
}
=
this
;
this
.
loading
=
true
;
this
.
$apollo
.
mutate
({
mutation
:
destroyOncallRotationMutation
,
variables
:
{
iid
:
id
,
projectPath
,
},
update
(
store
,
{
data
})
{
updateStoreAfterRotationDelete
(
store
,
getOncallSchedulesQuery
,
data
,
{
projectPath
});
},
})
.
then
(({
data
:
{
oncallRotationDestroy
}
=
{}
}
=
{})
=>
{
const
error
=
oncallRotationDestroy
.
errors
[
0
];
if
(
error
)
{
throw
error
;
}
this
.
$refs
.
deleteRotationModal
.
hide
();
})
.
catch
((
error
)
=>
{
this
.
error
=
error
;
})
.
finally
(()
=>
{
this
.
loading
=
false
;
});
},
hideErrorAlert
()
{
this
.
error
=
''
;
},
},
};
</
script
>
<
template
>
<gl-modal
ref=
"deleteRotationModal"
:modal-id=
"modalId"
size=
"sm"
:data-testid=
"rotationDeleteModalTestId"
:title=
"$options.i18n.deleteRotation"
:action-primary=
"primaryProps"
:action-cancel=
"cancelProps"
@
primary.prevent=
"deleteRotation"
@
cancel=
"$emit('set-rotation-to-update',
{})"
>
<gl-alert
v-if=
"error"
variant=
"danger"
class=
"gl-mt-n3 gl-mb-3"
@
dismiss=
"hideErrorAlert"
>
{{
error
||
$options
.
i18n
.
errorMsg
}}
</gl-alert>
<gl-sprintf
:message=
"$options.i18n.deleteRotationMessage"
>
<template
#deleteRotation
>
{{
rotation
.
name
}}
</
template
>
</gl-sprintf>
</gl-modal>
</template>
ee/app/assets/javascripts/oncall_schedules/components/schedule/components/rotations_list_section.vue
View file @
e5e8441a
...
@@ -3,7 +3,8 @@ import { GlButtonGroup, GlButton, GlTooltipDirective, GlModalDirective } from '@
...
@@ -3,7 +3,8 @@ import { GlButtonGroup, GlButton, GlTooltipDirective, GlModalDirective } from '@
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
}
from
'
~/locale
'
;
import
CurrentDayIndicator
from
'
./current_day_indicator.vue
'
;
import
CurrentDayIndicator
from
'
./current_day_indicator.vue
'
;
import
RotationAssignee
from
'
../../rotations/components/rotation_assignee.vue
'
;
import
RotationAssignee
from
'
../../rotations/components/rotation_assignee.vue
'
;
import
{
editRotationModalId
}
from
'
../../../constants
'
;
import
DeleteRotationModal
from
'
../../rotations/components/delete_rotation_modal.vue
'
;
import
{
editRotationModalId
,
deleteRotationModalId
}
from
'
../../../constants
'
;
export
const
i18n
=
{
export
const
i18n
=
{
editRotationLabel
:
s__
(
'
OnCallSchedules|Edit rotation
'
),
editRotationLabel
:
s__
(
'
OnCallSchedules|Edit rotation
'
),
...
@@ -13,11 +14,13 @@ export const i18n = {
...
@@ -13,11 +14,13 @@ export const i18n = {
export
default
{
export
default
{
i18n
,
i18n
,
editRotationModalId
,
editRotationModalId
,
deleteRotationModalId
,
components
:
{
components
:
{
GlButtonGroup
,
GlButtonGroup
,
GlButton
,
GlButton
,
CurrentDayIndicator
,
CurrentDayIndicator
,
RotationAssignee
,
RotationAssignee
,
DeleteRotationModal
,
},
},
directives
:
{
directives
:
{
GlModal
:
GlModalDirective
,
GlModal
:
GlModalDirective
,
...
@@ -37,6 +40,16 @@ export default {
...
@@ -37,6 +40,16 @@ export default {
required
:
true
,
required
:
true
,
},
},
},
},
data
()
{
return
{
rotationToUpdate
:
{},
};
},
methods
:
{
setRotationToUpdate
(
rotation
)
{
this
.
rotationToUpdate
=
rotation
;
},
},
};
};
</
script
>
</
script
>
...
@@ -61,12 +74,13 @@ export default {
...
@@ -61,12 +74,13 @@ export default {
:aria-label=
"$options.i18n.editRotationLabel"
:aria-label=
"$options.i18n.editRotationLabel"
/>
/>
<gl-button
<gl-button
v-gl-modal=
"$options.
edit
RotationModalId"
v-gl-modal=
"$options.
delete
RotationModalId"
v-gl-tooltip
v-gl-tooltip
category=
"tertiary"
category=
"tertiary"
:title=
"$options.i18n.deleteRotationLabel"
:title=
"$options.i18n.deleteRotationLabel"
icon=
"remove"
icon=
"remove"
:aria-label=
"$options.i18n.deleteRotationLabel"
:aria-label=
"$options.i18n.deleteRotationLabel"
@
click=
"setRotationToUpdate(rotation)"
/>
/>
</gl-button-group>
</gl-button-group>
</span>
</span>
...
@@ -85,5 +99,10 @@ export default {
...
@@ -85,5 +99,10 @@ export default {
/>
/>
</span>
</span>
</div>
</div>
<delete-rotation-modal
:rotation=
"rotationToUpdate"
:modal-id=
"$options.deleteRotationModalId"
@
set-rotation-to-update=
"setRotationToUpdate"
/>
</div>
</div>
</
template
>
</
template
>
ee/app/assets/javascripts/oncall_schedules/constants.js
View file @
e5e8441a
...
@@ -23,3 +23,4 @@ export const PRESET_DEFAULTS = {
...
@@ -23,3 +23,4 @@ export const PRESET_DEFAULTS = {
export
const
addRotationModalId
=
'
addRotationModal
'
;
export
const
addRotationModalId
=
'
addRotationModal
'
;
export
const
editRotationModalId
=
'
editRotationModal
'
;
export
const
editRotationModalId
=
'
editRotationModal
'
;
export
const
deleteRotationModalId
=
'
deleteRotationModal
'
;
ee/app/assets/javascripts/oncall_schedules/graphql/mutations/destroy_oncall_rotation.mutation.graphql
0 → 100644
View file @
e5e8441a
#import "../fragments/oncall_schedule_rotation.fragment.graphql"
mutation
oncallRotationDestroy
(
$iid
:
String
!,
$projectPath
:
ID
!)
{
oncallRotationDestroy
(
input
:
{
iid
:
$iid
,
projectPath
:
$projectPath
})
{
errors
oncallRotation
{
...
OnCallRotation
}
}
}
ee/app/assets/javascripts/oncall_schedules/utils/cache_updates.js
View file @
e5e8441a
...
@@ -5,6 +5,7 @@ import {
...
@@ -5,6 +5,7 @@ import {
DELETE_SCHEDULE_ERROR
,
DELETE_SCHEDULE_ERROR
,
UPDATE_SCHEDULE_ERROR
,
UPDATE_SCHEDULE_ERROR
,
UPDATE_ROTATION_ERROR
,
UPDATE_ROTATION_ERROR
,
DELETE_ROTATION_ERROR
,
}
from
'
./error_messages
'
;
}
from
'
./error_messages
'
;
const
addScheduleToStore
=
(
store
,
query
,
{
oncallSchedule
:
schedule
},
variables
)
=>
{
const
addScheduleToStore
=
(
store
,
query
,
{
oncallSchedule
:
schedule
},
variables
)
=>
{
...
@@ -138,6 +139,32 @@ const updateRotationFromStore = (store, query, { oncallRotationUpdate }, schedul
...
@@ -138,6 +139,32 @@ const updateRotationFromStore = (store, query, { oncallRotationUpdate }, schedul
});
});
};
};
const
deleteRotationFromStore
=
(
store
,
query
,
{
oncallRotationDestroy
},
variables
)
=>
{
const
rotation
=
oncallRotationDestroy
?.
oncallRotation
;
if
(
!
rotation
)
{
return
;
}
const
sourceData
=
store
.
readQuery
({
query
,
variables
,
});
// TODO: This needs the rotation backend to be fully integrated to work, for the moment we will place-hold it. https://gitlab.com/gitlab-org/gitlab/-/issues/262863
const
data
=
produce
(
sourceData
,
(
draftData
)
=>
{
// eslint-disable-next-line no-param-reassign
draftData
.
project
.
incidentManagementOncallSchedules
.
nodes
[
0
].
rotations
=
[
rotation
].
filter
(
({
id
})
=>
id
!==
rotation
.
id
,
);
});
store
.
writeQuery
({
query
,
variables
,
data
,
});
};
const
onError
=
(
data
,
message
)
=>
{
const
onError
=
(
data
,
message
)
=>
{
createFlash
({
message
});
createFlash
({
message
});
throw
new
Error
(
data
.
errors
);
throw
new
Error
(
data
.
errors
);
...
@@ -180,3 +207,11 @@ export const updateStoreAfterRotationEdit = (store, query, data, scheduleId, var
...
@@ -180,3 +207,11 @@ export const updateStoreAfterRotationEdit = (store, query, data, scheduleId, var
updateRotationFromStore
(
store
,
query
,
data
,
scheduleId
,
variables
);
updateRotationFromStore
(
store
,
query
,
data
,
scheduleId
,
variables
);
}
}
};
};
export
const
updateStoreAfterRotationDelete
=
(
store
,
query
,
data
,
variables
)
=>
{
if
(
hasErrors
(
data
))
{
onError
(
data
,
DELETE_ROTATION_ERROR
);
}
else
{
deleteRotationFromStore
(
store
,
query
,
data
,
variables
);
}
};
ee/app/assets/javascripts/oncall_schedules/utils/error_messages.js
View file @
e5e8441a
...
@@ -11,3 +11,7 @@ export const UPDATE_SCHEDULE_ERROR = s__(
...
@@ -11,3 +11,7 @@ export const UPDATE_SCHEDULE_ERROR = s__(
export
const
UPDATE_ROTATION_ERROR
=
s__
(
export
const
UPDATE_ROTATION_ERROR
=
s__
(
'
OnCallSchedules|The rotation could not be updated. Please try again.
'
,
'
OnCallSchedules|The rotation could not be updated. Please try again.
'
,
);
);
export
const
DELETE_ROTATION_ERROR
=
s__
(
'
OnCallSchedules|The rotation could not be deleted. Please try again.
'
,
);
ee/spec/frontend/oncall_schedule/add_edit_schedule_form_spec.js
View file @
e5e8441a
...
@@ -47,7 +47,6 @@ describe('AddEditScheduleForm', () => {
...
@@ -47,7 +47,6 @@ describe('AddEditScheduleForm', () => {
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
const
findTimezoneDropdown
=
()
=>
wrapper
.
find
(
GlDropdown
);
const
findTimezoneDropdown
=
()
=>
wrapper
.
find
(
GlDropdown
);
...
...
ee/spec/frontend/oncall_schedule/delete_schedule_modal_spec.js
View file @
e5e8441a
...
@@ -22,8 +22,6 @@ const mockHideModal = jest.fn();
...
@@ -22,8 +22,6 @@ const mockHideModal = jest.fn();
const
schedule
=
const
schedule
=
getOncallSchedulesQueryResponse
.
data
.
project
.
incidentManagementOncallSchedules
.
nodes
[
0
];
getOncallSchedulesQueryResponse
.
data
.
project
.
incidentManagementOncallSchedules
.
nodes
[
0
];
localVue
.
use
(
VueApollo
);
describe
(
'
DeleteScheduleModal
'
,
()
=>
{
describe
(
'
DeleteScheduleModal
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
let
fakeApollo
;
let
fakeApollo
;
...
@@ -40,9 +38,6 @@ describe('DeleteScheduleModal', () => {
...
@@ -40,9 +38,6 @@ describe('DeleteScheduleModal', () => {
}
}
async
function
destroySchedule
(
localWrapper
)
{
async
function
destroySchedule
(
localWrapper
)
{
await
jest
.
runOnlyPendingTimers
();
await
localWrapper
.
vm
.
$nextTick
();
localWrapper
.
find
(
GlModal
).
vm
.
$emit
(
'
primary
'
,
{
preventDefault
:
jest
.
fn
()
});
localWrapper
.
find
(
GlModal
).
vm
.
$emit
(
'
primary
'
,
{
preventDefault
:
jest
.
fn
()
});
}
}
...
@@ -111,7 +106,6 @@ describe('DeleteScheduleModal', () => {
...
@@ -111,7 +106,6 @@ describe('DeleteScheduleModal', () => {
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
it
(
'
renders delete schedule modal layout
'
,
()
=>
{
it
(
'
renders delete schedule modal layout
'
,
()
=>
{
...
...
ee/spec/frontend/oncall_schedule/mocks/apollo_mock.js
View file @
e5e8441a
import
mockRotations
from
'
./mock_rotation.json
'
;
export
const
participants
=
[
export
const
participants
=
[
{
{
id
:
'
1
'
,
id
:
'
1
'
,
...
@@ -165,3 +167,27 @@ export const createRotationResponseWithErrors = {
...
@@ -165,3 +167,27 @@ export const createRotationResponseWithErrors = {
},
},
},
},
};
};
export
const
destroyRotationResponse
=
{
data
:
{
oncallRotationDestroy
:
{
errors
:
[],
oncallRotation
:
{
__typename
:
'
IncidentManagementOncallRotation
'
,
...
mockRotations
[
0
],
},
},
},
};
export
const
destroyRotationResponseWithErrors
=
{
data
:
{
oncallRotationDestroy
:
{
errors
:
[
'
Houston, we have a problem
'
],
oncallRotation
:
{
__typename
:
'
IncidentManagementOncallRotation
'
,
...
mockRotations
[
0
],
},
},
},
};
ee/spec/frontend/oncall_schedule/oncall_schedule_spec.js
View file @
e5e8441a
...
@@ -22,7 +22,7 @@ describe('On-call schedule', () => {
...
@@ -22,7 +22,7 @@ describe('On-call schedule', () => {
const
mockWeeksTimeFrame
=
[
'
31 Dec 2020
'
,
'
7 Jan 2021
'
,
'
14 Jan 2021
'
];
const
mockWeeksTimeFrame
=
[
'
31 Dec 2020
'
,
'
7 Jan 2021
'
,
'
14 Jan 2021
'
];
const
formattedTimezone
=
'
(UTC-09:00) AKST Alaska
'
;
const
formattedTimezone
=
'
(UTC-09:00) AKST Alaska
'
;
function
mount
Component
({
schedule
}
=
{})
{
function
create
Component
({
schedule
}
=
{})
{
wrapper
=
extendedWrapper
(
wrapper
=
extendedWrapper
(
shallowMount
(
OnCallSchedule
,
{
shallowMount
(
OnCallSchedule
,
{
propsData
:
{
propsData
:
{
...
@@ -42,12 +42,11 @@ describe('On-call schedule', () => {
...
@@ -42,12 +42,11 @@ describe('On-call schedule', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
jest
.
spyOn
(
utils
,
'
getTimeframeForWeeksView
'
).
mockReturnValue
(
mockWeeksTimeFrame
);
jest
.
spyOn
(
utils
,
'
getTimeframeForWeeksView
'
).
mockReturnValue
(
mockWeeksTimeFrame
);
jest
.
spyOn
(
commonUtils
,
'
getFormattedTimezone
'
).
mockReturnValue
(
formattedTimezone
);
jest
.
spyOn
(
commonUtils
,
'
getFormattedTimezone
'
).
mockReturnValue
(
formattedTimezone
);
mount
Component
({
schedule
:
mockSchedule
});
create
Component
({
schedule
:
mockSchedule
});
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
const
findScheduleHeader
=
()
=>
wrapper
.
findByTestId
(
'
scheduleHeader
'
);
const
findScheduleHeader
=
()
=>
wrapper
.
findByTestId
(
'
scheduleHeader
'
);
...
...
ee/spec/frontend/oncall_schedule/rotations/components/__snapshots__/delete_rotation_modal_spec.js.snap
0 → 100644
View file @
e5e8441a
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`DeleteRotationModal renders delete rotation modal layout 1`] = `
<gl-modal-stub
actioncancel="[object Object]"
actionprimary="[object Object]"
data-testid="delete-rotation-modal-gid://gitlab/IncidentManagement::OncallRotation/2"
modalclass=""
modalid="deleteRotationModal"
size="sm"
title="Delete rotation"
titletag="h4"
>
<!---->
<gl-sprintf-stub
message="Are you sure you want to delete the \\"%{deleteRotation}\\" rotation? This action cannot be undone."
/>
</gl-modal-stub>
`;
ee/spec/frontend/oncall_schedule/rotations/components/add_edit_rotation_modal_spec.js
View file @
e5e8441a
...
@@ -123,7 +123,6 @@ describe('AddEditRotationModal', () => {
...
@@ -123,7 +123,6 @@ describe('AddEditRotationModal', () => {
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
const
findModal
=
()
=>
wrapper
.
find
(
GlModal
);
const
findModal
=
()
=>
wrapper
.
find
(
GlModal
);
...
...
ee/spec/frontend/oncall_schedule/rotations/components/delete_rotation_modal_spec.js
0 → 100644
View file @
e5e8441a
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
createMockApollo
from
'
jest/helpers/mock_apollo_helper
'
;
import
{
GlModal
,
GlAlert
,
GlSprintf
}
from
'
@gitlab/ui
'
;
import
VueApollo
from
'
vue-apollo
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
getOncallSchedulesQuery
from
'
ee/oncall_schedules/graphql/queries/get_oncall_schedules.query.graphql
'
;
import
destroyOncallRotationMutation
from
'
ee/oncall_schedules/graphql/mutations/destroy_oncall_rotation.mutation.graphql
'
;
import
DeleteRotationModal
,
{
i18n
,
}
from
'
ee/oncall_schedules/components/rotations/components/delete_rotation_modal.vue
'
;
import
{
deleteRotationModalId
}
from
'
ee/oncall_schedules/constants
'
;
import
{
getOncallSchedulesQueryResponse
,
destroyRotationResponse
,
destroyRotationResponseWithErrors
,
}
from
'
../../mocks/apollo_mock
'
;
import
mockRotations
from
'
../../mocks/mock_rotation.json
'
;
const
localVue
=
createLocalVue
();
const
projectPath
=
'
group/project
'
;
const
mutate
=
jest
.
fn
();
const
mockHideModal
=
jest
.
fn
();
const
rotation
=
mockRotations
[
0
];
describe
(
'
DeleteRotationModal
'
,
()
=>
{
let
wrapper
;
let
fakeApollo
;
let
destroyRotationHandler
;
const
findModal
=
()
=>
wrapper
.
find
(
GlModal
);
const
findModalText
=
()
=>
wrapper
.
find
(
GlSprintf
);
const
findAlert
=
()
=>
wrapper
.
find
(
GlAlert
);
async
function
awaitApolloDomMock
()
{
await
wrapper
.
vm
.
$nextTick
();
// kick off the DOM update
await
jest
.
runOnlyPendingTimers
();
// kick off the mocked GQL stuff (promises)
await
wrapper
.
vm
.
$nextTick
();
// kick off the DOM update
}
async
function
destroyRotation
(
localWrapper
)
{
localWrapper
.
find
(
GlModal
).
vm
.
$emit
(
'
primary
'
,
{
preventDefault
:
jest
.
fn
()
});
}
const
createComponent
=
({
data
=
{},
props
=
{}
}
=
{})
=>
{
wrapper
=
shallowMount
(
DeleteRotationModal
,
{
data
()
{
return
{
...
data
,
};
},
propsData
:
{
modalId
:
deleteRotationModalId
,
rotation
,
...
props
,
},
provide
:
{
projectPath
,
},
mocks
:
{
$apollo
:
{
mutate
,
},
},
stubs
:
{
GlSprintf
:
false
},
});
wrapper
.
vm
.
$refs
.
deleteRotationModal
.
hide
=
mockHideModal
;
};
function
createComponentWithApollo
({
destroyHandler
=
jest
.
fn
().
mockResolvedValue
(
destroyRotationResponse
),
}
=
{})
{
localVue
.
use
(
VueApollo
);
destroyRotationHandler
=
destroyHandler
;
const
requestHandlers
=
[
[
getOncallSchedulesQuery
,
jest
.
fn
().
mockResolvedValue
(
getOncallSchedulesQueryResponse
)],
[
destroyOncallRotationMutation
,
destroyRotationHandler
],
];
fakeApollo
=
createMockApollo
(
requestHandlers
);
fakeApollo
.
clients
.
defaultClient
.
cache
.
writeQuery
({
query
:
getOncallSchedulesQuery
,
variables
:
{
projectPath
:
'
group/project
'
,
},
data
:
getOncallSchedulesQueryResponse
.
data
,
});
wrapper
=
shallowMount
(
DeleteRotationModal
,
{
localVue
,
apolloProvider
:
fakeApollo
,
propsData
:
{
rotation
,
modalId
:
deleteRotationModalId
,
},
provide
:
{
projectPath
,
},
});
}
beforeEach
(()
=>
{
createComponent
();
});
afterEach
(()
=>
{
wrapper
.
destroy
();
});
it
(
'
renders delete rotation modal layout
'
,
()
=>
{
expect
(
wrapper
.
element
).
toMatchSnapshot
();
});
describe
(
'
renders delete modal with the correct rotation information
'
,
()
=>
{
it
(
'
renders name of rotation to destroy
'
,
()
=>
{
expect
(
findModalText
().
attributes
(
'
message
'
)).
toBe
(
i18n
.
deleteRotationMessage
);
});
});
describe
(
'
Rotation destroy apollo API call
'
,
()
=>
{
it
(
'
makes a request with `oncallRotationDestroy` to delete a rotation
'
,
()
=>
{
mutate
.
mockResolvedValueOnce
({});
findModal
().
vm
.
$emit
(
'
primary
'
,
{
preventDefault
:
jest
.
fn
()
});
expect
(
mutate
).
toHaveBeenCalledWith
({
mutation
:
expect
.
any
(
Object
),
update
:
expect
.
anything
(),
variables
:
{
iid
:
rotation
.
id
,
projectPath
},
});
});
it
(
'
hides the modal on successful rotation deletion
'
,
async
()
=>
{
mutate
.
mockResolvedValueOnce
({
data
:
{
oncallRotationDestroy
:
{
errors
:
[]
}
}
});
findModal
().
vm
.
$emit
(
'
primary
'
,
{
preventDefault
:
jest
.
fn
()
});
await
waitForPromises
();
expect
(
mockHideModal
).
toHaveBeenCalled
();
});
it
(
'
does not hide the modal on deletion fail and shows the error alert
'
,
async
()
=>
{
const
error
=
'
some error
'
;
mutate
.
mockResolvedValueOnce
({
data
:
{
oncallRotationDestroy
:
{
errors
:
[
error
]
}
}
});
findModal
().
vm
.
$emit
(
'
primary
'
,
{
preventDefault
:
jest
.
fn
()
});
await
waitForPromises
();
const
alert
=
findAlert
();
expect
(
mockHideModal
).
not
.
toHaveBeenCalled
();
expect
(
alert
.
exists
()).
toBe
(
true
);
expect
(
alert
.
text
()).
toContain
(
error
);
});
});
describe
(
'
with mocked Apollo client
'
,
()
=>
{
it
(
'
has the name of the rotation to delete based on getOncallSchedulesQuery
'
,
async
()
=>
{
createComponentWithApollo
();
await
jest
.
runOnlyPendingTimers
();
await
wrapper
.
vm
.
$nextTick
();
expect
(
findModal
().
attributes
(
'
data-testid
'
)).
toBe
(
`delete-rotation-modal-
${
rotation
.
id
}
`
);
});
it
(
'
calls a mutation with correct parameters and destroys a rotation
'
,
async
()
=>
{
createComponentWithApollo
();
await
destroyRotation
(
wrapper
);
expect
(
destroyRotationHandler
).
toHaveBeenCalled
();
});
it
(
'
displays alert if mutation had a recoverable error
'
,
async
()
=>
{
createComponentWithApollo
({
destroyHandler
:
jest
.
fn
().
mockResolvedValue
(
destroyRotationResponseWithErrors
),
});
await
destroyRotation
(
wrapper
);
await
awaitApolloDomMock
();
const
alert
=
findAlert
();
expect
(
alert
.
exists
()).
toBe
(
true
);
expect
(
alert
.
text
()).
toContain
(
'
Houston, we have a problem
'
);
});
});
});
ee/spec/frontend/oncall_schedule/rotations/components/rotation_assignee_spec.js
View file @
e5e8441a
...
@@ -14,7 +14,7 @@ describe('RotationAssignee', () => {
...
@@ -14,7 +14,7 @@ describe('RotationAssignee', () => {
const
findStartsAt
=
()
=>
wrapper
.
findByTestId
(
'
rotation-assignee-starts-at
'
);
const
findStartsAt
=
()
=>
wrapper
.
findByTestId
(
'
rotation-assignee-starts-at
'
);
const
findEndsAt
=
()
=>
wrapper
.
findByTestId
(
'
rotation-assignee-ends-at
'
);
const
findEndsAt
=
()
=>
wrapper
.
findByTestId
(
'
rotation-assignee-ends-at
'
);
function
mount
Component
()
{
function
create
Component
()
{
wrapper
=
extendedWrapper
(
wrapper
=
extendedWrapper
(
shallowMount
(
RotationAssignee
,
{
shallowMount
(
RotationAssignee
,
{
propsData
:
{
propsData
:
{
...
@@ -28,12 +28,11 @@ describe('RotationAssignee', () => {
...
@@ -28,12 +28,11 @@ describe('RotationAssignee', () => {
}
}
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mount
Component
();
create
Component
();
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
describe
(
'
rotation assignee token
'
,
()
=>
{
describe
(
'
rotation assignee token
'
,
()
=>
{
...
...
ee/spec/frontend/oncall_schedule/schedule/components/__snapshots__/rotations_list_section_spec.js.snap
View file @
e5e8441a
...
@@ -78,5 +78,10 @@ exports[`RotationsListSectionComponent renders component layout 1`] = `
...
@@ -78,5 +78,10 @@ exports[`RotationsListSectionComponent renders component layout 1`] = `
/>
/>
</span>
</span>
</div>
</div>
<delete-rotation-modal-stub
modalid="deleteRotationModal"
rotation="[object Object]"
/>
</div>
</div>
`;
`;
ee/spec/frontend/oncall_schedule/schedule/components/current_day_indicator_spec.js
View file @
e5e8441a
...
@@ -12,7 +12,7 @@ describe('CurrentDayIndicator', () => {
...
@@ -12,7 +12,7 @@ describe('CurrentDayIndicator', () => {
// current indicator will be rendered
// current indicator will be rendered
const
mockTimeframeInitialDate
=
new
Date
(
2018
,
0
,
1
);
const
mockTimeframeInitialDate
=
new
Date
(
2018
,
0
,
1
);
function
mount
Component
()
{
function
create
Component
()
{
wrapper
=
shallowMount
(
CurrentDayIndicator
,
{
wrapper
=
shallowMount
(
CurrentDayIndicator
,
{
propsData
:
{
propsData
:
{
presetType
:
PRESET_TYPES
.
WEEKS
,
presetType
:
PRESET_TYPES
.
WEEKS
,
...
@@ -22,13 +22,12 @@ describe('CurrentDayIndicator', () => {
...
@@ -22,13 +22,12 @@ describe('CurrentDayIndicator', () => {
}
}
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mount
Component
();
create
Component
();
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
if
(
wrapper
)
{
if
(
wrapper
)
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
}
}
});
});
...
...
ee/spec/frontend/oncall_schedule/schedule/components/rotations_list_section_spec.js
View file @
e5e8441a
...
@@ -12,7 +12,7 @@ describe('RotationsListSectionComponent', () => {
...
@@ -12,7 +12,7 @@ describe('RotationsListSectionComponent', () => {
const
mockTimeframeInitialDate
=
new
Date
(
2018
,
0
,
1
);
const
mockTimeframeInitialDate
=
new
Date
(
2018
,
0
,
1
);
const
mockTimeframeWeeks
=
getTimeframeForWeeksView
(
mockTimeframeInitialDate
);
const
mockTimeframeWeeks
=
getTimeframeForWeeksView
(
mockTimeframeInitialDate
);
function
mount
Component
({
function
create
Component
({
presetType
=
PRESET_TYPES
.
WEEKS
,
presetType
=
PRESET_TYPES
.
WEEKS
,
timeframe
=
mockTimeframeWeeks
,
timeframe
=
mockTimeframeWeeks
,
}
=
{})
{
}
=
{})
{
...
@@ -29,13 +29,12 @@ describe('RotationsListSectionComponent', () => {
...
@@ -29,13 +29,12 @@ describe('RotationsListSectionComponent', () => {
}
}
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mount
Component
();
create
Component
();
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
if
(
wrapper
)
{
if
(
wrapper
)
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
}
}
});
});
...
...
ee/spec/frontend/oncall_schedule/schedule/components/schedule_timeline_section_spec.js
View file @
e5e8441a
...
@@ -12,7 +12,7 @@ describe('TimelineSectionComponent', () => {
...
@@ -12,7 +12,7 @@ describe('TimelineSectionComponent', () => {
const
schedule
=
const
schedule
=
getOncallSchedulesQueryResponse
.
data
.
project
.
incidentManagementOncallSchedules
.
nodes
[
0
];
getOncallSchedulesQueryResponse
.
data
.
project
.
incidentManagementOncallSchedules
.
nodes
[
0
];
function
mount
Component
({
function
create
Component
({
presetType
=
PRESET_TYPES
.
WEEKS
,
presetType
=
PRESET_TYPES
.
WEEKS
,
timeframe
=
mockTimeframeWeeks
,
timeframe
=
mockTimeframeWeeks
,
}
=
{})
{
}
=
{})
{
...
@@ -26,12 +26,11 @@ describe('TimelineSectionComponent', () => {
...
@@ -26,12 +26,11 @@ describe('TimelineSectionComponent', () => {
}
}
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mountComponent
({}
);
createComponent
(
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
wrapper
=
null
;
});
});
it
(
'
renders component container element with class `timeline-section`
'
,
()
=>
{
it
(
'
renders component container element with class `timeline-section`
'
,
()
=>
{
...
...
locale/gitlab.pot
View file @
e5e8441a
...
@@ -19526,6 +19526,9 @@ msgstr ""
...
@@ -19526,6 +19526,9 @@ msgstr ""
msgid "OnCallSchedules|Add schedule"
msgid "OnCallSchedules|Add schedule"
msgstr ""
msgstr ""
msgid "OnCallSchedules|Are you sure you want to delete the \"%{deleteRotation}\" rotation? This action cannot be undone."
msgstr ""
msgid "OnCallSchedules|Are you sure you want to delete the \"%{deleteSchedule}\" schedule? This action cannot be undone."
msgid "OnCallSchedules|Are you sure you want to delete the \"%{deleteSchedule}\" schedule? This action cannot be undone."
msgstr ""
msgstr ""
...
@@ -19592,6 +19595,9 @@ msgstr ""
...
@@ -19592,6 +19595,9 @@ msgstr ""
msgid "OnCallSchedules|Successfully edited your rotation"
msgid "OnCallSchedules|Successfully edited your rotation"
msgstr ""
msgstr ""
msgid "OnCallSchedules|The rotation could not be deleted. Please try again."
msgstr ""
msgid "OnCallSchedules|The rotation could not be updated. Please try again."
msgid "OnCallSchedules|The rotation could not be updated. Please try again."
msgstr ""
msgstr ""
...
...
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