diff options
Diffstat (limited to 'spec/frontend/admin/users/components')
3 files changed, 22 insertions, 18 deletions
diff --git a/spec/frontend/admin/users/components/actions/actions_spec.js b/spec/frontend/admin/users/components/actions/actions_spec.js index fd05b08a3fb..67dcf5c6149 100644 --- a/spec/frontend/admin/users/components/actions/actions_spec.js +++ b/spec/frontend/admin/users/components/actions/actions_spec.js @@ -5,6 +5,7 @@ import { nextTick } from 'vue'; import Actions from '~/admin/users/components/actions'; import SharedDeleteAction from '~/admin/users/components/actions/shared/shared_delete_action.vue'; import { capitalizeFirstCharacter } from '~/lib/utils/text_utility'; +import { OBSTACLE_TYPES } from '~/vue_shared/components/user_deletion_obstacles/constants'; import { CONFIRMATION_ACTIONS, DELETE_ACTIONS } from '../../constants'; import { paths } from '../../mock_data'; @@ -46,7 +47,10 @@ describe('Action components', () => { }); describe('DELETE_ACTION_COMPONENTS', () => { - const oncallSchedules = [{ name: 'schedule1' }, { name: 'schedule2' }]; + const userDeletionObstacles = [ + { name: 'schedule1', type: OBSTACLE_TYPES.oncallSchedules }, + { name: 'policy1', type: OBSTACLE_TYPES.escalationPolicies }, + ]; it.each(DELETE_ACTIONS.map((action) => [action, paths[action]]))( 'renders a dropdown item for "%s"', @@ -56,7 +60,7 @@ describe('Action components', () => { props: { username: 'John Doe', paths, - oncallSchedules, + userDeletionObstacles, }, stubs: { SharedDeleteAction }, }); @@ -69,8 +73,8 @@ describe('Action components', () => { expect(sharedAction.attributes('data-delete-user-url')).toBe(expectedPath); expect(sharedAction.attributes('data-gl-modal-action')).toBe(kebabCase(action)); expect(sharedAction.attributes('data-username')).toBe('John Doe'); - expect(sharedAction.attributes('data-oncall-schedules')).toBe( - JSON.stringify(oncallSchedules), + expect(sharedAction.attributes('data-user-deletion-obstacles')).toBe( + JSON.stringify(userDeletionObstacles), ); expect(findDropdownItem().exists()).toBe(true); }, diff --git a/spec/frontend/admin/users/components/modals/__snapshots__/delete_user_modal_spec.js.snap b/spec/frontend/admin/users/components/modals/__snapshots__/delete_user_modal_spec.js.snap index 5e367891337..472158a9b10 100644 --- a/spec/frontend/admin/users/components/modals/__snapshots__/delete_user_modal_spec.js.snap +++ b/spec/frontend/admin/users/components/modals/__snapshots__/delete_user_modal_spec.js.snap @@ -8,8 +8,8 @@ exports[`User Operation confirmation modal renders modal with form included 1`] /> </p> - <oncall-schedules-list-stub - schedules="schedule1,schedule2" + <user-deletion-obstacles-list-stub + obstacles="schedule1,policy1" username="username" /> diff --git a/spec/frontend/admin/users/components/modals/delete_user_modal_spec.js b/spec/frontend/admin/users/components/modals/delete_user_modal_spec.js index fee74764645..82307c9e3b3 100644 --- a/spec/frontend/admin/users/components/modals/delete_user_modal_spec.js +++ b/spec/frontend/admin/users/components/modals/delete_user_modal_spec.js @@ -1,7 +1,7 @@ import { GlButton, GlFormInput } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import DeleteUserModal from '~/admin/users/components/modals/delete_user_modal.vue'; -import OncallSchedulesList from '~/vue_shared/components/oncall_schedules_list.vue'; +import UserDeletionObstaclesList from '~/vue_shared/components/user_deletion_obstacles/user_deletion_obstacles_list.vue'; import ModalStub from './stubs/modal_stub'; const TEST_DELETE_USER_URL = 'delete-url'; @@ -25,7 +25,7 @@ describe('User Operation confirmation modal', () => { const getUsername = () => findUsernameInput().attributes('value'); const getMethodParam = () => new FormData(findForm().element).get('_method'); const getFormAction = () => findForm().attributes('action'); - const findOnCallSchedulesList = () => wrapper.findComponent(OncallSchedulesList); + const findUserDeletionObstaclesList = () => wrapper.findComponent(UserDeletionObstaclesList); const setUsername = (username) => { findUsernameInput().vm.$emit('input', username); @@ -33,7 +33,7 @@ describe('User Operation confirmation modal', () => { const username = 'username'; const badUsername = 'bad_username'; - const oncallSchedules = '["schedule1", "schedule2"]'; + const userDeletionObstacles = '["schedule1", "policy1"]'; const createComponent = (props = {}) => { wrapper = shallowMount(DeleteUserModal, { @@ -46,7 +46,7 @@ describe('User Operation confirmation modal', () => { deleteUserUrl: TEST_DELETE_USER_URL, blockUserUrl: TEST_BLOCK_USER_URL, csrfToken: TEST_CSRF, - oncallSchedules, + userDeletionObstacles, ...props, }, stubs: { @@ -150,18 +150,18 @@ describe('User Operation confirmation modal', () => { }); }); - describe('Related oncall-schedules list', () => { - it('does NOT render the list when user has no related schedules', () => { - createComponent({ oncallSchedules: '[]' }); - expect(findOnCallSchedulesList().exists()).toBe(false); + describe('Related user-deletion-obstacles list', () => { + it('does NOT render the list when user has no related obstacles', () => { + createComponent({ userDeletionObstacles: '[]' }); + expect(findUserDeletionObstaclesList().exists()).toBe(false); }); - it('renders the list when user has related schedules', () => { + it('renders the list when user has related obstalces', () => { createComponent(); - const schedules = findOnCallSchedulesList(); - expect(schedules.exists()).toBe(true); - expect(schedules.props('schedules')).toEqual(JSON.parse(oncallSchedules)); + const obstacles = findUserDeletionObstaclesList(); + expect(obstacles.exists()).toBe(true); + expect(obstacles.props('obstacles')).toEqual(JSON.parse(userDeletionObstacles)); }); }); }); |