debian-mirror-gitlab/spec/frontend/sidebar/components/assignees/sidebar_participant_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
1.8 KiB
JavaScript
Raw Normal View History

2022-05-07 20:08:51 +05:30
import { GlAvatarLabeled, GlIcon } from '@gitlab/ui';
2021-04-29 21:17:54 +05:30
import { shallowMount } from '@vue/test-utils';
2023-05-27 22:25:52 +05:30
import { TYPE_ISSUE, TYPE_MERGE_REQUEST } from '~/issues/constants';
2021-04-29 21:17:54 +05:30
import SidebarParticipant from '~/sidebar/components/assignees/sidebar_participant.vue';
const user = {
name: 'John Doe',
username: 'johndoe',
webUrl: '/link',
avatarUrl: '/avatar',
};
describe('Sidebar participant component', () => {
let wrapper;
const findAvatar = () => wrapper.findComponent(GlAvatarLabeled);
2022-05-07 20:08:51 +05:30
const findIcon = () => wrapper.findComponent(GlIcon);
2021-04-29 21:17:54 +05:30
2023-04-23 21:23:45 +05:30
const createComponent = ({ status = null, issuableType = TYPE_ISSUE, canMerge = false } = {}) => {
2021-04-29 21:17:54 +05:30
wrapper = shallowMount(SidebarParticipant, {
propsData: {
user: {
...user,
2022-05-07 20:08:51 +05:30
canMerge,
2021-04-29 21:17:54 +05:30
status,
},
2022-05-07 20:08:51 +05:30
issuableType,
},
stubs: {
GlAvatarLabeled,
2021-04-29 21:17:54 +05:30
},
});
};
2022-05-07 20:08:51 +05:30
it('does not show `Busy` status when user is not busy', () => {
2021-04-29 21:17:54 +05:30
createComponent();
expect(findAvatar().props('label')).toBe(user.name);
2023-06-20 00:43:36 +05:30
expect(wrapper.text()).not.toContain('Busy');
2021-04-29 21:17:54 +05:30
});
2022-05-07 20:08:51 +05:30
it('shows `Busy` status when user is busy', () => {
createComponent({ status: { availability: 'BUSY' } });
2021-04-29 21:17:54 +05:30
2023-06-20 00:43:36 +05:30
expect(wrapper.text()).toContain('Busy');
2021-04-29 21:17:54 +05:30
});
2022-05-07 20:08:51 +05:30
it('does not render a warning icon', () => {
createComponent();
expect(findIcon().exists()).toBe(false);
});
describe('when on merge request sidebar', () => {
it('when project member cannot merge', () => {
2023-05-27 22:25:52 +05:30
createComponent({ issuableType: TYPE_MERGE_REQUEST });
2022-05-07 20:08:51 +05:30
expect(findIcon().exists()).toBe(true);
});
it('when project member can merge', () => {
2023-05-27 22:25:52 +05:30
createComponent({ issuableType: TYPE_MERGE_REQUEST, canMerge: true });
2022-05-07 20:08:51 +05:30
expect(findIcon().exists()).toBe(false);
});
});
2021-04-29 21:17:54 +05:30
});