Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-06 12:18:56 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-06 12:18:56 +0300
commitc06178d51ad9b8d4ce665047873615facfc9c1c5 (patch)
tree2a1acfea73fd0fbdd7d0e240fd7ac52224845f99 /spec/frontend/sidebar
parent0a0e8803b0e3e2fb83d74c9bafc32f4e9d825bcc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/sidebar')
-rw-r--r--spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js16
-rw-r--r--spec/frontend/sidebar/components/participants/sidebar_participants_widget_spec.js89
-rw-r--r--spec/frontend/sidebar/mock_data.js25
3 files changed, 130 insertions, 0 deletions
diff --git a/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js b/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js
index 3fbd863ab40..2e665a494f2 100644
--- a/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js
+++ b/spec/frontend/sidebar/components/assignees/sidebar_assignees_widget_spec.js
@@ -208,6 +208,22 @@ describe('Sidebar assignees widget', () => {
]);
});
+ it('does not trigger mutation or fire event when editing and exiting without making changes', async () => {
+ createComponent();
+
+ await waitForPromises();
+
+ findEditableItem().vm.$emit('open');
+
+ await waitForPromises();
+
+ findEditableItem().vm.$emit('close');
+
+ expect(findEditableItem().props('isDirty')).toBe(false);
+ expect(updateIssueAssigneesMutationSuccess).toHaveBeenCalledTimes(0);
+ expect(wrapper.emitted('assignees-updated')).toBe(undefined);
+ });
+
describe('when expanded', () => {
beforeEach(async () => {
createComponent();
diff --git a/spec/frontend/sidebar/components/participants/sidebar_participants_widget_spec.js b/spec/frontend/sidebar/components/participants/sidebar_participants_widget_spec.js
new file mode 100644
index 00000000000..57b9a10b23e
--- /dev/null
+++ b/spec/frontend/sidebar/components/participants/sidebar_participants_widget_spec.js
@@ -0,0 +1,89 @@
+import { shallowMount } from '@vue/test-utils';
+import Vue from 'vue';
+import VueApollo from 'vue-apollo';
+import createMockApollo from 'helpers/mock_apollo_helper';
+import waitForPromises from 'helpers/wait_for_promises';
+import Participants from '~/sidebar/components/participants/participants.vue';
+import SidebarParticipantsWidget from '~/sidebar/components/participants/sidebar_participants_widget.vue';
+import epicParticipantsQuery from '~/sidebar/queries/epic_participants.query.graphql';
+import { epicParticipantsResponse } from '../../mock_data';
+
+Vue.use(VueApollo);
+
+describe('Sidebar Participants Widget', () => {
+ let wrapper;
+ let fakeApollo;
+
+ const findParticipants = () => wrapper.findComponent(Participants);
+
+ const createComponent = ({
+ participantsQueryHandler = jest.fn().mockResolvedValue(epicParticipantsResponse()),
+ } = {}) => {
+ fakeApollo = createMockApollo([[epicParticipantsQuery, participantsQueryHandler]]);
+
+ wrapper = shallowMount(SidebarParticipantsWidget, {
+ apolloProvider: fakeApollo,
+ propsData: {
+ fullPath: 'group',
+ iid: '1',
+ issuableType: 'epic',
+ },
+ stubs: {
+ Participants,
+ },
+ });
+ };
+
+ afterEach(() => {
+ wrapper.destroy();
+ fakeApollo = null;
+ });
+
+ it('passes a `loading` prop as true to child component when query is loading', () => {
+ createComponent();
+
+ expect(findParticipants().props('loading')).toBe(true);
+ });
+
+ describe('when participants are loaded', () => {
+ beforeEach(() => {
+ createComponent({
+ participantsQueryHandler: jest.fn().mockResolvedValue(epicParticipantsResponse()),
+ });
+ return waitForPromises();
+ });
+
+ it('passes a `loading` prop as false to editable item', () => {
+ expect(findParticipants().props('loading')).toBe(false);
+ });
+
+ it('passes participants to child component', () => {
+ expect(findParticipants().props('participants')).toEqual(
+ epicParticipantsResponse().data.workspace.issuable.participants.nodes,
+ );
+ });
+ });
+
+ describe('when error occurs', () => {
+ it('emits error event with correct parameters', async () => {
+ const mockError = new Error('mayday');
+
+ createComponent({
+ participantsQueryHandler: jest.fn().mockRejectedValue(mockError),
+ });
+
+ await waitForPromises();
+
+ const [
+ [
+ {
+ message,
+ error: { networkError },
+ },
+ ],
+ ] = wrapper.emitted('fetch-error');
+ expect(message).toBe(wrapper.vm.$options.i18n.fetchingError);
+ expect(networkError).toEqual(mockError);
+ });
+ });
+});
diff --git a/spec/frontend/sidebar/mock_data.js b/spec/frontend/sidebar/mock_data.js
index 8a969d64467..b052038661a 100644
--- a/spec/frontend/sidebar/mock_data.js
+++ b/spec/frontend/sidebar/mock_data.js
@@ -262,6 +262,31 @@ export const issuableStartDateResponse = (startDate = null) => ({
},
});
+export const epicParticipantsResponse = () => ({
+ data: {
+ workspace: {
+ __typename: 'Group',
+ issuable: {
+ __typename: 'Epic',
+ id: 'gid://gitlab/Epic/4',
+ participants: {
+ nodes: [
+ {
+ id: 'gid://gitlab/User/2',
+ avatarUrl:
+ 'https://www.gravatar.com/avatar/a95e5b71488f4b9d69ce5ff58bfd28d6?s=80\u0026d=identicon',
+ name: 'Jacki Kub',
+ username: 'francina.skiles',
+ webUrl: '/franc',
+ status: null,
+ },
+ ],
+ },
+ },
+ },
+ },
+});
+
export const issueReferenceResponse = (reference) => ({
data: {
workspace: {