debian-mirror-gitlab/spec/frontend/vue_mr_widget/components/states/mr_widget_unresolved_discussions_spec.js

65 lines
2 KiB
JavaScript
Raw Normal View History

2020-10-24 23:57:45 +05:30
import { mount } from '@vue/test-utils';
2020-06-23 00:09:42 +05:30
import { TEST_HOST } from 'helpers/test_constants';
2020-10-24 23:57:45 +05:30
import notesEventHub from '~/notes/event_hub';
2021-03-11 19:13:27 +05:30
import UnresolvedDiscussions from '~/vue_merge_request_widget/components/states/unresolved_discussions.vue';
2020-10-24 23:57:45 +05:30
function createComponent({ path = '' } = {}) {
return mount(UnresolvedDiscussions, {
propsData: {
mr: {
createIssueToResolveDiscussionsPath: path,
},
},
});
}
2017-08-17 22:00:37 +05:30
2018-05-09 12:01:36 +05:30
describe('UnresolvedDiscussions', () => {
2020-10-24 23:57:45 +05:30
let wrapper;
beforeEach(() => {
wrapper = createComponent();
});
2017-08-17 22:00:37 +05:30
2018-10-15 14:42:47 +05:30
afterEach(() => {
2020-10-24 23:57:45 +05:30
wrapper.destroy();
});
it('triggers the correct notes event when the jump to first unresolved discussion button is clicked', () => {
jest.spyOn(notesEventHub, '$emit');
wrapper.find('[data-testid="jump-to-first"]').trigger('click');
expect(notesEventHub.$emit).toHaveBeenCalledWith('jumpToFirstUnresolvedDiscussion');
2017-08-17 22:00:37 +05:30
});
2019-09-30 21:07:59 +05:30
describe('with threads path', () => {
2017-08-17 22:00:37 +05:30
beforeEach(() => {
2020-10-24 23:57:45 +05:30
wrapper = createComponent({ path: TEST_HOST });
});
afterEach(() => {
wrapper.destroy();
2017-08-17 22:00:37 +05:30
});
it('should have correct elements', () => {
2021-06-08 01:23:25 +05:30
expect(wrapper.element.innerText).toContain(`Merge blocked: all threads must be resolved.`);
2018-12-13 13:39:08 +05:30
2020-10-24 23:57:45 +05:30
expect(wrapper.element.innerText).toContain('Jump to first unresolved thread');
2021-11-11 11:23:49 +05:30
expect(wrapper.element.innerText).toContain('Create issue to resolve all threads');
2020-10-24 23:57:45 +05:30
expect(wrapper.element.querySelector('.js-create-issue').getAttribute('href')).toEqual(
TEST_HOST,
);
2017-08-17 22:00:37 +05:30
});
2018-10-15 14:42:47 +05:30
});
2017-08-17 22:00:37 +05:30
2019-09-30 21:07:59 +05:30
describe('without threads path', () => {
2018-10-15 14:42:47 +05:30
it('should not show create issue link if user cannot create issue', () => {
2021-06-08 01:23:25 +05:30
expect(wrapper.element.innerText).toContain(`Merge blocked: all threads must be resolved.`);
2018-12-13 13:39:08 +05:30
2020-10-24 23:57:45 +05:30
expect(wrapper.element.innerText).toContain('Jump to first unresolved thread');
2021-11-11 11:23:49 +05:30
expect(wrapper.element.innerText).not.toContain('Create issue to resolve all threads');
2020-10-24 23:57:45 +05:30
expect(wrapper.element.querySelector('.js-create-issue')).toEqual(null);
2017-08-17 22:00:37 +05:30
});
});
});