diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-20 12:21:30 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-20 12:21:30 +0000 |
commit | 2366f969a4b3a95e052e551cc7283a2db8d5562e (patch) | |
tree | 33ea679dad4b92048697729f68f9c606f91b32e4 /spec/frontend | |
parent | c7eec01f1b68b2e047cdd709751cb695ab329933 (diff) | |
download | gitlab-ce-2366f969a4b3a95e052e551cc7283a2db8d5562e.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
4 files changed, 72 insertions, 32 deletions
diff --git a/spec/frontend/boards/components/board_filtered_search_spec.js b/spec/frontend/boards/components/board_filtered_search_spec.js index 64111cfb01a..5a976816f74 100644 --- a/spec/frontend/boards/components/board_filtered_search_spec.js +++ b/spec/frontend/boards/components/board_filtered_search_spec.js @@ -2,7 +2,7 @@ import { shallowMount } from '@vue/test-utils'; import Vue from 'vue'; import Vuex from 'vuex'; import BoardFilteredSearch from '~/boards/components/board_filtered_search.vue'; -import * as urlUtility from '~/lib/utils/url_utility'; +import { updateHistory } from '~/lib/utils/url_utility'; import { TOKEN_TITLE_AUTHOR, TOKEN_TITLE_LABEL, @@ -23,6 +23,12 @@ import { createStore } from '~/boards/stores'; Vue.use(Vuex); +jest.mock('~/lib/utils/url_utility', () => ({ + updateHistory: jest.fn(), + setUrlParams: jest.requireActual('~/lib/utils/url_utility').setUrlParams, + queryToObject: jest.requireActual('~/lib/utils/url_utility').queryToObject, +})); + describe('BoardFilteredSearch', () => { let wrapper; let store; @@ -88,10 +94,9 @@ describe('BoardFilteredSearch', () => { }); it('calls historyPushState', () => { - jest.spyOn(urlUtility, 'updateHistory'); findFilteredSearch().vm.$emit('onFilter', [{ value: { data: 'searchQuery' } }]); - expect(urlUtility.updateHistory).toHaveBeenCalledWith({ + expect(updateHistory).toHaveBeenCalledWith({ replace: true, title: '', url: 'http://test.host/', @@ -120,7 +125,7 @@ describe('BoardFilteredSearch', () => { beforeEach(() => { createComponent(); - jest.spyOn(wrapper.vm, 'performSearch').mockImplementation(); + jest.spyOn(store, 'dispatch').mockImplementation(); }); it('sets the url params to the correct results', () => { @@ -137,10 +142,11 @@ describe('BoardFilteredSearch', () => { { type: TOKEN_TYPE_HEALTH, value: { data: 'onTrack', operator: '=' } }, { type: TOKEN_TYPE_HEALTH, value: { data: 'atRisk', operator: '!=' } }, ]; - jest.spyOn(urlUtility, 'updateHistory'); + findFilteredSearch().vm.$emit('onFilter', mockFilters); - expect(urlUtility.updateHistory).toHaveBeenCalledWith({ + expect(store.dispatch).toHaveBeenCalledWith('performSearch'); + expect(updateHistory).toHaveBeenCalledWith({ title: '', replace: true, url: @@ -158,10 +164,10 @@ describe('BoardFilteredSearch', () => { const mockFilters = [ { type: TOKEN_TYPE_ASSIGNEE, value: { data: assigneeParam, operator: '=' } }, ]; - jest.spyOn(urlUtility, 'updateHistory'); + findFilteredSearch().vm.$emit('onFilter', mockFilters); - expect(urlUtility.updateHistory).toHaveBeenCalledWith({ + expect(updateHistory).toHaveBeenCalledWith({ title: '', replace: true, url: expected, @@ -175,8 +181,6 @@ describe('BoardFilteredSearch', () => { createComponent({ initialFilterParams: { authorUsername: 'root', labelName: ['label'], healthStatus: 'Any' }, }); - - jest.spyOn(store, 'dispatch'); }); it('passes the correct props to FilterSearchBar', () => { @@ -194,11 +198,9 @@ describe('BoardFilteredSearch', () => { }); it('emits setFilters and updates URL when onFilter is emitted', () => { - jest.spyOn(urlUtility, 'updateHistory'); - findFilteredSearch().vm.$emit('onFilter', [{ value: { data: '' } }]); - expect(urlUtility.updateHistory).toHaveBeenCalledWith({ + expect(updateHistory).toHaveBeenCalledWith({ title: '', replace: true, url: 'http://test.host/', diff --git a/spec/frontend/content_editor/services/markdown_serializer_spec.js b/spec/frontend/content_editor/services/markdown_serializer_spec.js index a28d5a278e6..506db4144fc 100644 --- a/spec/frontend/content_editor/services/markdown_serializer_spec.js +++ b/spec/frontend/content_editor/services/markdown_serializer_spec.js @@ -186,6 +186,19 @@ comment --> ); }); + it('correctly renders a comment with markdown in it without adding any slashes', () => { + expect(serialize(paragraph('hi'), comment('this is a list\n- a\n- b\n- c'))).toBe( + ` +hi + +<!--this is a list +- a +- b +- c--> + `.trim(), + ); + }); + it('correctly serializes a line break', () => { expect(serialize(paragraph('hello', hardBreak(), 'world'))).toBe('hello\\\nworld'); }); diff --git a/spec/frontend/issues/dashboard/components/issues_dashboard_app_spec.js b/spec/frontend/issues/dashboard/components/issues_dashboard_app_spec.js index ebf4771e97f..0187970efdc 100644 --- a/spec/frontend/issues/dashboard/components/issues_dashboard_app_spec.js +++ b/spec/frontend/issues/dashboard/components/issues_dashboard_app_spec.js @@ -1,4 +1,4 @@ -import { GlEmptyState } from '@gitlab/ui'; +import { GlDisclosureDropdown, GlEmptyState } from '@gitlab/ui'; import * as Sentry from '@sentry/browser'; import AxiosMockAdapter from 'axios-mock-adapter'; import Vue, { nextTick } from 'vue'; @@ -78,6 +78,7 @@ describe('IssuesDashboardApp component', () => { } const findCalendarButton = () => wrapper.findByRole('link', { name: i18n.calendarLabel }); + const findDisclosureDropdown = () => wrapper.findComponent(GlDisclosureDropdown); const findEmptyState = () => wrapper.findComponent(GlEmptyState); const findIssuableList = () => wrapper.findComponent(IssuableList); const findIssueCardStatistics = () => wrapper.findComponent(IssueCardStatistics); @@ -113,11 +114,10 @@ describe('IssuesDashboardApp component', () => { }); describe('UI components', () => { - beforeEach(() => { + beforeEach(async () => { setWindowLocation(locationSearch); mountComponent(); - jest.runOnlyPendingTimers(); - return waitForPromises(); + await waitForPromises(); }); // https://gitlab.com/gitlab-org/gitlab/-/issues/391722 @@ -154,12 +154,24 @@ describe('IssuesDashboardApp component', () => { }); }); - it('renders RSS button link', () => { - expect(findRssButton().attributes('href')).toBe(defaultProvide.rssPath); - }); + describe('actions dropdown', () => { + it('renders', () => { + expect(findDisclosureDropdown().props()).toMatchObject({ + category: 'tertiary', + icon: 'ellipsis_v', + noCaret: true, + textSrOnly: true, + toggleText: 'Actions', + }); + }); - it('renders calendar button link', () => { - expect(findCalendarButton().attributes('href')).toBe(defaultProvide.calendarPath); + it('renders RSS button link', () => { + expect(findRssButton().attributes('href')).toBe(defaultProvide.rssPath); + }); + + it('renders calendar button link', () => { + expect(findCalendarButton().attributes('href')).toBe(defaultProvide.calendarPath); + }); }); it('renders issue time information', () => { @@ -174,11 +186,10 @@ describe('IssuesDashboardApp component', () => { describe('fetching issues', () => { describe('with a search query', () => { describe('when there are issues returned', () => { - beforeEach(() => { + beforeEach(async () => { setWindowLocation(locationSearch); mountComponent(); - jest.runOnlyPendingTimers(); - return waitForPromises(); + await waitForPromises(); }); it('renders the issues', () => { @@ -193,12 +204,12 @@ describe('IssuesDashboardApp component', () => { }); describe('when there are no issues returned', () => { - beforeEach(() => { + beforeEach(async () => { setWindowLocation(locationSearch); mountComponent({ issuesQueryHandler: jest.fn().mockResolvedValue(emptyIssuesQueryResponse), }); - return waitForPromises(); + await waitForPromises(); }); it('renders no issues', () => { @@ -218,10 +229,10 @@ describe('IssuesDashboardApp component', () => { describe('with no search query', () => { let issuesQueryHandler; - beforeEach(() => { + beforeEach(async () => { issuesQueryHandler = jest.fn().mockResolvedValue(defaultQueryResponse); mountComponent({ issuesQueryHandler }); - return waitForPromises(); + await waitForPromises(); }); it('does not call issues query', () => { @@ -307,11 +318,10 @@ describe('IssuesDashboardApp component', () => { ${'fetching issues'} | ${'issuesQueryHandler'} | ${i18n.errorFetchingIssues} ${'fetching issue counts'} | ${'issuesCountsQueryHandler'} | ${i18n.errorFetchingCounts} `('when there is an error $error', ({ mountOption, message }) => { - beforeEach(() => { + beforeEach(async () => { setWindowLocation(locationSearch); mountComponent({ [mountOption]: jest.fn().mockRejectedValue(new Error('ERROR')) }); - jest.runOnlyPendingTimers(); - return waitForPromises(); + await waitForPromises(); }); it('shows an error message', () => { diff --git a/spec/frontend/sidebar/components/labels/labels_select_widget/dropdown_contents_spec.js b/spec/frontend/sidebar/components/labels/labels_select_widget/dropdown_contents_spec.js index e9023cb9ff6..c0417a2a40b 100644 --- a/spec/frontend/sidebar/components/labels/labels_select_widget/dropdown_contents_spec.js +++ b/spec/frontend/sidebar/components/labels/labels_select_widget/dropdown_contents_spec.js @@ -173,6 +173,21 @@ describe('DropdownContent', () => { expect(findCreateView().exists()).toBe(false); expect(findLabelsView().exists()).toBe(true); }); + + it('selects created labels', async () => { + const createdLabel = { + id: 29, + title: 'new label', + description: null, + color: '#FF0000', + textColor: '#FFFFFF', + }; + + findCreateView().vm.$emit('labelCreated', createdLabel); + await nextTick(); + + expect(findLabelsView().props('localSelectedLabels')).toContain(createdLabel); + }); }); describe('Labels view', () => { |