2022-07-16 23:28:13 +05:30
|
|
|
import { GlIcon, GlIntersectionObserver } from '@gitlab/ui';
|
2018-03-17 18:26:18 +05:30
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
2021-11-11 11:23:49 +05:30
|
|
|
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
|
2022-06-21 17:19:12 +05:30
|
|
|
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
|
2022-07-16 23:28:13 +05:30
|
|
|
import waitForPromises from 'helpers/wait_for_promises';
|
2023-05-27 22:25:52 +05:30
|
|
|
import { createAlert } from '~/alert';
|
2023-04-23 21:23:45 +05:30
|
|
|
import {
|
|
|
|
IssuableStatusText,
|
|
|
|
STATUS_CLOSED,
|
|
|
|
STATUS_OPEN,
|
|
|
|
STATUS_REOPENED,
|
|
|
|
TYPE_EPIC,
|
|
|
|
TYPE_ISSUE,
|
|
|
|
} from '~/issues/constants';
|
2022-01-26 12:08:38 +05:30
|
|
|
import IssuableApp from '~/issues/show/components/app.vue';
|
|
|
|
import DescriptionComponent from '~/issues/show/components/description.vue';
|
2022-06-21 17:19:12 +05:30
|
|
|
import EditedComponent from '~/issues/show/components/edited.vue';
|
|
|
|
import FormComponent from '~/issues/show/components/form.vue';
|
|
|
|
import TitleComponent from '~/issues/show/components/title.vue';
|
2022-01-26 12:08:38 +05:30
|
|
|
import IncidentTabs from '~/issues/show/components/incidents/incident_tabs.vue';
|
|
|
|
import PinnedLinks from '~/issues/show/components/pinned_links.vue';
|
|
|
|
import eventHub from '~/issues/show/event_hub';
|
2021-03-11 19:13:27 +05:30
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2023-05-27 22:25:52 +05:30
|
|
|
import { HTTP_STATUS_OK, HTTP_STATUS_UNAUTHORIZED } from '~/lib/utils/http_status';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { visitUrl } from '~/lib/utils/url_utility';
|
2020-11-24 15:15:51 +05:30
|
|
|
import {
|
|
|
|
appProps,
|
|
|
|
initialRequest,
|
|
|
|
publishedIncidentUrl,
|
2023-05-27 22:25:52 +05:30
|
|
|
putRequest,
|
2020-11-24 15:15:51 +05:30
|
|
|
secondRequest,
|
|
|
|
zoomMeetingUrl,
|
2021-09-04 01:27:46 +05:30
|
|
|
} from '../mock_data/mock_data';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
jest.mock('~/alert');
|
2023-03-04 22:38:38 +05:30
|
|
|
jest.mock('~/lib/utils/url_utility');
|
|
|
|
jest.mock('~/behaviors/markdown/render_gfm');
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
const REALTIME_REQUEST_STACK = [initialRequest, secondRequest];
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
describe('Issuable output', () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
let axiosMock;
|
2020-06-23 00:09:42 +05:30
|
|
|
let wrapper;
|
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
const findStickyHeader = () => wrapper.findByTestId('issue-sticky-header');
|
|
|
|
const findLockedBadge = () => wrapper.findByTestId('locked');
|
|
|
|
const findConfidentialBadge = () => wrapper.findByTestId('confidential');
|
|
|
|
const findHiddenBadge = () => wrapper.findByTestId('hidden');
|
2022-06-21 17:19:12 +05:30
|
|
|
|
|
|
|
const findTitle = () => wrapper.findComponent(TitleComponent);
|
|
|
|
const findDescription = () => wrapper.findComponent(DescriptionComponent);
|
|
|
|
const findEdited = () => wrapper.findComponent(EditedComponent);
|
|
|
|
const findForm = () => wrapper.findComponent(FormComponent);
|
|
|
|
const findPinnedLinks = () => wrapper.findComponent(PinnedLinks);
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
const createComponent = ({ props = {}, options = {}, data = {} } = {}) => {
|
2022-06-21 17:19:12 +05:30
|
|
|
wrapper = shallowMountExtended(IssuableApp, {
|
2021-11-11 11:23:49 +05:30
|
|
|
directives: {
|
2023-05-27 22:25:52 +05:30
|
|
|
GlTooltip: createMockDirective('gl-tooltip'),
|
2021-11-11 11:23:49 +05:30
|
|
|
},
|
2020-11-24 15:15:51 +05:30
|
|
|
propsData: { ...appProps, ...props },
|
|
|
|
provide: {
|
|
|
|
fullPath: 'gitlab-org/incidents',
|
2021-03-08 18:12:59 +05:30
|
|
|
uploadMetricsFeatureAvailable: false,
|
2020-11-24 15:15:51 +05:30
|
|
|
},
|
|
|
|
stubs: {
|
|
|
|
HighlightBar: true,
|
|
|
|
IncidentTabs: true,
|
|
|
|
},
|
2021-09-04 01:27:46 +05:30
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
...data,
|
|
|
|
};
|
|
|
|
},
|
2020-11-24 15:15:51 +05:30
|
|
|
...options,
|
|
|
|
});
|
2023-05-27 22:25:52 +05:30
|
|
|
|
|
|
|
jest.advanceTimersToNextTimer(2);
|
|
|
|
return waitForPromises();
|
|
|
|
};
|
|
|
|
|
|
|
|
const emitHubEvent = (event) => {
|
|
|
|
eventHub.$emit(event);
|
|
|
|
return waitForPromises();
|
|
|
|
};
|
|
|
|
|
|
|
|
const openForm = () => {
|
|
|
|
return emitHubEvent('open.form');
|
|
|
|
};
|
|
|
|
|
|
|
|
const updateIssuable = () => {
|
|
|
|
return emitHubEvent('update.issuable');
|
|
|
|
};
|
|
|
|
|
|
|
|
const advanceToNextPoll = () => {
|
|
|
|
// We get new data through the HTTP request.
|
|
|
|
jest.advanceTimersToNextTimer();
|
|
|
|
return waitForPromises();
|
2020-11-24 15:15:51 +05:30
|
|
|
};
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
beforeEach(() => {
|
2023-05-27 22:25:52 +05:30
|
|
|
jest.spyOn(eventHub, '$emit');
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
axiosMock = new MockAdapter(axios);
|
|
|
|
const endpoint = '/gitlab-org/gitlab-shell/-/issues/9/realtime_changes/realtime_changes';
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
axiosMock.onGet(endpoint).replyOnce(HTTP_STATUS_OK, REALTIME_REQUEST_STACK[0], {
|
|
|
|
'POLL-INTERVAL': '1',
|
|
|
|
});
|
|
|
|
axiosMock.onGet(endpoint).reply(HTTP_STATUS_OK, REALTIME_REQUEST_STACK[1], {
|
|
|
|
'POLL-INTERVAL': '-1',
|
|
|
|
});
|
|
|
|
axiosMock.onPut().reply(HTTP_STATUS_OK, putRequest);
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
describe('update', () => {
|
|
|
|
beforeEach(async () => {
|
|
|
|
await createComponent();
|
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it('should render a title/description/edited and update title/description/edited on update', async () => {
|
|
|
|
expect(findTitle().props('titleText')).toContain(initialRequest.title_text);
|
|
|
|
expect(findDescription().props('descriptionText')).toContain('this is a description');
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(findEdited().exists()).toBe(true);
|
|
|
|
expect(findEdited().props('updatedByPath')).toMatch(/\/some_user$/);
|
|
|
|
expect(findEdited().props('updatedAt')).toBe(initialRequest.updated_at);
|
|
|
|
expect(findDescription().props().lockVersion).toBe(initialRequest.lock_version);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await advanceToNextPoll();
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(findTitle().props('titleText')).toContain('2');
|
|
|
|
expect(findDescription().props('descriptionText')).toContain('42');
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(findEdited().exists()).toBe(true);
|
|
|
|
expect(findEdited().props('updatedByName')).toBe('Other User');
|
|
|
|
expect(findEdited().props('updatedByPath')).toMatch(/\/other_user$/);
|
|
|
|
expect(findEdited().props('updatedAt')).toBe(secondRequest.updated_at);
|
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
describe('with permissions', () => {
|
|
|
|
beforeEach(async () => {
|
|
|
|
await createComponent();
|
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it('shows actions on `open.form` event', async () => {
|
|
|
|
expect(findForm().exists()).toBe(false);
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await openForm();
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(findForm().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('update formState if form is not open', async () => {
|
|
|
|
const titleValue = initialRequest.title_text;
|
|
|
|
|
|
|
|
expect(findTitle().exists()).toBe(true);
|
|
|
|
expect(findTitle().props('titleText')).toBe(titleValue);
|
|
|
|
|
|
|
|
await advanceToNextPoll();
|
|
|
|
|
|
|
|
// The title component has the new data, so the state was updated
|
|
|
|
expect(findTitle().exists()).toBe(true);
|
|
|
|
expect(findTitle().props('titleText')).toBe(secondRequest.title_text);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not update formState if form is already open', async () => {
|
|
|
|
const titleValue = initialRequest.title_text;
|
|
|
|
|
|
|
|
expect(findTitle().exists()).toBe(true);
|
|
|
|
expect(findTitle().props('titleText')).toBe(titleValue);
|
|
|
|
|
|
|
|
await openForm();
|
|
|
|
|
|
|
|
// Opening the form, the data has not changed
|
|
|
|
expect(findForm().props().formState.title).toBe(titleValue);
|
|
|
|
|
|
|
|
await advanceToNextPoll();
|
|
|
|
|
|
|
|
// We expect the prop value not to have changed after another API call
|
|
|
|
expect(findForm().props().formState.title).toBe(titleValue);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('without permissions', () => {
|
|
|
|
beforeEach(async () => {
|
|
|
|
await createComponent({ props: { canUpdate: false } });
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not show actions if permissions are incorrect', async () => {
|
|
|
|
await openForm();
|
|
|
|
|
|
|
|
expect(findForm().exists()).toBe(false);
|
|
|
|
});
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
describe('Pinned links propagated', () => {
|
|
|
|
it.each`
|
|
|
|
prop | value
|
|
|
|
${'zoomMeetingUrl'} | ${zoomMeetingUrl}
|
|
|
|
${'publishedIncidentUrl'} | ${publishedIncidentUrl}
|
2023-05-27 22:25:52 +05:30
|
|
|
`('sets the $prop correctly on underlying pinned links', async ({ prop, value }) => {
|
|
|
|
await createComponent();
|
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
expect(findPinnedLinks().props(prop)).toBe(value);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
describe('updating an issue', () => {
|
|
|
|
beforeEach(async () => {
|
|
|
|
await createComponent();
|
|
|
|
});
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
it('fetches new data after update', async () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
await advanceToNextPoll();
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await updateIssuable();
|
|
|
|
|
|
|
|
expect(axiosMock.history.put).toHaveLength(1);
|
|
|
|
// The call was made with the new data
|
|
|
|
expect(axiosMock.history.put[0].data.title).toEqual(findTitle().props().title);
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it('closes the form after fetching data', async () => {
|
|
|
|
await updateIssuable();
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
expect(eventHub.$emit).toHaveBeenCalledWith('close.form');
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
it('does not redirect if issue has not moved', async () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
axiosMock.onPut().reply(HTTP_STATUS_OK, {
|
|
|
|
...putRequest,
|
|
|
|
confidential: appProps.isConfidential,
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await updateIssuable();
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
expect(visitUrl).not.toHaveBeenCalled();
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
it('does not redirect if issue has not moved and user has switched tabs', async () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
axiosMock.onPut().reply(HTTP_STATUS_OK, {
|
|
|
|
...putRequest,
|
|
|
|
web_url: '',
|
|
|
|
confidential: appProps.isConfidential,
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await updateIssuable();
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
expect(visitUrl).not.toHaveBeenCalled();
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
it('redirects if returned web_url has changed', async () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
const webUrl = '/testing-issue-move';
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
axiosMock.onPut().reply(HTTP_STATUS_OK, {
|
|
|
|
...putRequest,
|
|
|
|
web_url: webUrl,
|
|
|
|
confidential: appProps.isConfidential,
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await updateIssuable();
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(visitUrl).toHaveBeenCalledWith(webUrl);
|
2018-03-17 18:26:18 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
describe('error when updating', () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
it('closes form', async () => {
|
|
|
|
axiosMock.onPut().reply(HTTP_STATUS_UNAUTHORIZED);
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await updateIssuable();
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
expect(eventHub.$emit).not.toHaveBeenCalledWith('close.form');
|
2023-03-04 22:38:38 +05:30
|
|
|
expect(createAlert).toHaveBeenCalledWith({
|
2023-05-27 22:25:52 +05:30
|
|
|
message: `Error updating issue. Request failed with status code 401`,
|
2023-03-04 22:38:38 +05:30
|
|
|
});
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
2022-04-04 11:22:00 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it('returns the correct error message for issuableType', async () => {
|
|
|
|
axiosMock.onPut().reply(HTTP_STATUS_UNAUTHORIZED);
|
2021-04-17 20:07:23 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await updateIssuable();
|
2019-12-21 20:55:43 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
wrapper.setProps({ issuableType: 'merge request' });
|
2019-12-21 20:55:43 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await updateIssuable();
|
2019-12-21 20:55:43 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(eventHub.$emit).not.toHaveBeenCalledWith('close.form');
|
|
|
|
expect(createAlert).toHaveBeenCalledWith({
|
|
|
|
message: `Error updating merge request. Request failed with status code 401`,
|
|
|
|
});
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
2022-06-21 17:19:12 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it('shows error message from backend if exists', async () => {
|
|
|
|
const msg = 'Custom error message from backend';
|
|
|
|
axiosMock.onPut().reply(HTTP_STATUS_UNAUTHORIZED, { errors: [msg] });
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await updateIssuable();
|
2019-03-02 22:35:43 +05:30
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
expect(createAlert).toHaveBeenCalledWith({
|
2023-05-27 22:25:52 +05:30
|
|
|
message: `Error updating issue. ${msg}`,
|
2023-03-04 22:38:38 +05:30
|
|
|
});
|
2020-05-24 23:13:21 +05:30
|
|
|
});
|
2019-03-02 22:35:43 +05:30
|
|
|
});
|
|
|
|
});
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
describe('Locked warning', () => {
|
|
|
|
beforeEach(async () => {
|
|
|
|
await createComponent();
|
2019-07-31 22:56:46 +05:30
|
|
|
});
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it('shows locked warning if form is open & data is different', async () => {
|
|
|
|
await openForm();
|
|
|
|
await advanceToNextPoll();
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(findForm().props().formState.lockedWarningVisible).toBe(true);
|
|
|
|
expect(findForm().props().formState.lock_version).toBe(1);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('sticky header', () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
beforeEach(async () => {
|
|
|
|
await createComponent();
|
|
|
|
});
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
describe('when title is in view', () => {
|
|
|
|
it('is not shown', () => {
|
2021-01-29 00:20:46 +05:30
|
|
|
expect(findStickyHeader().exists()).toBe(false);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when title is not in view', () => {
|
2023-06-20 00:43:36 +05:30
|
|
|
beforeEach(() => {
|
2022-10-11 01:57:18 +05:30
|
|
|
wrapper.findComponent(GlIntersectionObserver).vm.$emit('disappear');
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
it('shows with title', () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(findStickyHeader().text()).toContain(initialRequest.title_text);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
it('shows with title for an epic', async () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
await wrapper.setProps({ issuableType: 'epic' });
|
2022-07-16 23:28:13 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(findStickyHeader().text()).toContain(' this is a title');
|
2022-07-16 23:28:13 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it.each`
|
2023-04-23 21:23:45 +05:30
|
|
|
issuableType | issuableStatus | statusIcon
|
|
|
|
${TYPE_ISSUE} | ${STATUS_OPEN} | ${'issues'}
|
|
|
|
${TYPE_ISSUE} | ${STATUS_CLOSED} | ${'issue-closed'}
|
|
|
|
${TYPE_EPIC} | ${STATUS_OPEN} | ${'epic'}
|
|
|
|
${TYPE_EPIC} | ${STATUS_CLOSED} | ${'epic-closed'}
|
2022-07-16 23:28:13 +05:30
|
|
|
`(
|
|
|
|
'shows with state icon "$statusIcon" for $issuableType when status is $issuableStatus',
|
|
|
|
async ({ issuableType, issuableStatus, statusIcon }) => {
|
2023-05-27 22:25:52 +05:30
|
|
|
await wrapper.setProps({ issuableType, issuableStatus });
|
2022-07-16 23:28:13 +05:30
|
|
|
|
|
|
|
expect(findStickyHeader().findComponent(GlIcon).props('name')).toBe(statusIcon);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
it.each`
|
|
|
|
title | state
|
2023-04-23 21:23:45 +05:30
|
|
|
${'shows with Open when status is opened'} | ${STATUS_OPEN}
|
|
|
|
${'shows with Closed when status is closed'} | ${STATUS_CLOSED}
|
|
|
|
${'shows with Open when status is reopened'} | ${STATUS_REOPENED}
|
2021-01-29 00:20:46 +05:30
|
|
|
`('$title', async ({ state }) => {
|
2023-05-27 22:25:52 +05:30
|
|
|
await wrapper.setProps({ issuableStatus: state });
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
expect(findStickyHeader().text()).toContain(IssuableStatusText[state]);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
it.each`
|
|
|
|
title | isConfidential
|
2021-11-11 11:23:49 +05:30
|
|
|
${'does not show confidential badge when issue is not confidential'} | ${false}
|
|
|
|
${'shows confidential badge when issue is confidential'} | ${true}
|
2021-01-29 00:20:46 +05:30
|
|
|
`('$title', async ({ isConfidential }) => {
|
2023-05-27 22:25:52 +05:30
|
|
|
await wrapper.setProps({ isConfidential });
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
const confidentialEl = findConfidentialBadge();
|
|
|
|
expect(confidentialEl.exists()).toBe(isConfidential);
|
|
|
|
if (isConfidential) {
|
|
|
|
expect(confidentialEl.props()).toMatchObject({
|
|
|
|
workspaceType: 'project',
|
|
|
|
issuableType: 'issue',
|
|
|
|
});
|
|
|
|
}
|
2021-01-29 00:20:46 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it.each`
|
|
|
|
title | isLocked
|
2021-11-11 11:23:49 +05:30
|
|
|
${'does not show locked badge when issue is not locked'} | ${false}
|
|
|
|
${'shows locked badge when issue is locked'} | ${true}
|
2021-01-29 00:20:46 +05:30
|
|
|
`('$title', async ({ isLocked }) => {
|
2023-05-27 22:25:52 +05:30
|
|
|
await wrapper.setProps({ isLocked });
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
expect(findLockedBadge().exists()).toBe(isLocked);
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
2021-11-11 11:23:49 +05:30
|
|
|
|
|
|
|
it.each`
|
|
|
|
title | isHidden
|
|
|
|
${'does not show hidden badge when issue is not hidden'} | ${false}
|
|
|
|
${'shows hidden badge when issue is hidden'} | ${true}
|
|
|
|
`('$title', async ({ isHidden }) => {
|
2023-05-27 22:25:52 +05:30
|
|
|
await wrapper.setProps({ isHidden });
|
2021-11-11 11:23:49 +05:30
|
|
|
|
|
|
|
const hiddenBadge = findHiddenBadge();
|
|
|
|
|
|
|
|
expect(hiddenBadge.exists()).toBe(isHidden);
|
|
|
|
|
|
|
|
if (isHidden) {
|
|
|
|
expect(hiddenBadge.attributes('title')).toBe(
|
|
|
|
'This issue is hidden because its author has been banned',
|
|
|
|
);
|
|
|
|
expect(getBinding(hiddenBadge.element, 'gl-tooltip')).not.toBeUndefined();
|
|
|
|
}
|
|
|
|
});
|
2019-07-31 22:56:46 +05:30
|
|
|
});
|
|
|
|
});
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
describe('Composable description component', () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
beforeEach(async () => {
|
|
|
|
await createComponent();
|
|
|
|
});
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
const findIncidentTabs = () => wrapper.findComponent(IncidentTabs);
|
2020-11-24 15:15:51 +05:30
|
|
|
const borderClass = 'gl-border-b-1 gl-border-b-gray-100 gl-border-b-solid gl-mb-6';
|
|
|
|
|
|
|
|
describe('when using description component', () => {
|
|
|
|
it('renders the description component', () => {
|
2022-06-21 17:19:12 +05:30
|
|
|
expect(findDescription().exists()).toBe(true);
|
2020-11-24 15:15:51 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render incident tabs', () => {
|
|
|
|
expect(findIncidentTabs().exists()).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('adds a border below the header', () => {
|
|
|
|
expect(findPinnedLinks().attributes('class')).toContain(borderClass);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('when using incident tabs description wrapper', () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
beforeEach(async () => {
|
|
|
|
await createComponent({
|
|
|
|
props: {
|
2020-11-24 15:15:51 +05:30
|
|
|
descriptionComponent: IncidentTabs,
|
|
|
|
showTitleBorder: false,
|
|
|
|
},
|
2023-05-27 22:25:52 +05:30
|
|
|
options: {
|
2020-11-24 15:15:51 +05:30
|
|
|
mocks: {
|
|
|
|
$apollo: {
|
|
|
|
queries: {
|
|
|
|
alert: {
|
|
|
|
loading: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2023-05-27 22:25:52 +05:30
|
|
|
});
|
2020-11-24 15:15:51 +05:30
|
|
|
});
|
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
it('does not the description component', () => {
|
|
|
|
expect(findDescription().exists()).toBe(false);
|
2020-11-24 15:15:51 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders incident tabs', () => {
|
|
|
|
expect(findIncidentTabs().exists()).toBe(true);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not add a border below the header', () => {
|
|
|
|
expect(findPinnedLinks().attributes('class')).not.toContain(borderClass);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2021-12-11 22:18:48 +05:30
|
|
|
|
|
|
|
describe('taskListUpdateStarted', () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
beforeEach(async () => {
|
|
|
|
await createComponent();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('stops polling', async () => {
|
|
|
|
expect(findTitle().props().titleText).toBe(initialRequest.title_text);
|
|
|
|
|
|
|
|
findDescription().vm.$emit('taskListUpdateStarted');
|
2021-12-11 22:18:48 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
await advanceToNextPoll();
|
2021-12-11 22:18:48 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(findTitle().props().titleText).toBe(initialRequest.title_text);
|
2021-12-11 22:18:48 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('taskListUpdateSucceeded', () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
beforeEach(async () => {
|
|
|
|
await createComponent();
|
|
|
|
findDescription().vm.$emit('taskListUpdateStarted');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('enables polling', async () => {
|
|
|
|
// Ensure that polling is not working before
|
|
|
|
expect(findTitle().props().titleText).toBe(initialRequest.title_text);
|
|
|
|
await advanceToNextPoll();
|
|
|
|
|
|
|
|
expect(findTitle().props().titleText).toBe(initialRequest.title_text);
|
2021-12-11 22:18:48 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
// Enable Polling an move forward
|
|
|
|
findDescription().vm.$emit('taskListUpdateSucceeded');
|
|
|
|
await advanceToNextPoll();
|
2021-12-11 22:18:48 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
// Title has changed: polling works!
|
|
|
|
expect(findTitle().props().titleText).toBe(secondRequest.title_text);
|
2021-12-11 22:18:48 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('taskListUpdateFailed', () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
beforeEach(async () => {
|
|
|
|
await createComponent();
|
|
|
|
findDescription().vm.$emit('taskListUpdateStarted');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('enables polling and calls updateStoreState', async () => {
|
|
|
|
// Ensure that polling is not working before
|
|
|
|
expect(findTitle().props().titleText).toBe(initialRequest.title_text);
|
|
|
|
await advanceToNextPoll();
|
2021-12-11 22:18:48 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(findTitle().props().titleText).toBe(initialRequest.title_text);
|
2021-12-11 22:18:48 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
// Enable Polling an move forward
|
|
|
|
findDescription().vm.$emit('taskListUpdateFailed');
|
|
|
|
await advanceToNextPoll();
|
|
|
|
|
|
|
|
// Title has changed: polling works!
|
|
|
|
expect(findTitle().props().titleText).toBe(secondRequest.title_text);
|
2021-12-11 22:18:48 +05:30
|
|
|
});
|
|
|
|
});
|
2022-07-16 23:28:13 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
describe('saveDescription event', () => {
|
2023-05-27 22:25:52 +05:30
|
|
|
beforeEach(async () => {
|
|
|
|
await createComponent();
|
|
|
|
});
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
it('makes request to update issue', async () => {
|
|
|
|
const description = 'I have been updated!';
|
2023-04-23 21:23:45 +05:30
|
|
|
findDescription().vm.$emit('saveDescription', description);
|
2023-05-27 22:25:52 +05:30
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
await waitForPromises();
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(axiosMock.history.put[0].data).toContain(description);
|
2022-07-16 23:28:13 +05:30
|
|
|
});
|
|
|
|
});
|
2017-09-10 17:25:29 +05:30
|
|
|
});
|