diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-28 18:10:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-28 18:10:08 +0300 |
commit | f7f0c0502763777f48964774a87b0a34dfb1d9ab (patch) | |
tree | 777821671f0eba38eadd5f60da96a1e54870350a /spec/frontend | |
parent | 10cb807543dca60b59a380100d1b70730d0e8b29 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/boards/project_select_spec.js | 22 | ||||
-rw-r--r-- | spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js | 144 | ||||
-rw-r--r-- | spec/frontend/vue_shared/security_configuration/components/section_layout_spec.js (renamed from spec/frontend/security_configuration/components/section_layout_spec.js) | 11 |
3 files changed, 31 insertions, 146 deletions
diff --git a/spec/frontend/boards/project_select_spec.js b/spec/frontend/boards/project_select_spec.js index 05dc7d28eaa..7206fb83212 100644 --- a/spec/frontend/boards/project_select_spec.js +++ b/spec/frontend/boards/project_select_spec.js @@ -1,4 +1,10 @@ -import { GlDropdown, GlDropdownItem, GlSearchBoxByType, GlLoadingIcon } from '@gitlab/ui'; +import { + GlDropdown, + GlDropdownItem, + GlSearchBoxByType, + GlLoadingIcon, + GlFormInput, +} from '@gitlab/ui'; import { mount } from '@vue/test-utils'; import Vue, { nextTick } from 'vue'; import Vuex from 'vuex'; @@ -23,6 +29,8 @@ describe('ProjectSelect component', () => { const findInMenuLoadingIcon = () => wrapper.find("[data-testid='dropdown-text-loading-icon']"); const findEmptySearchMessage = () => wrapper.find("[data-testid='empty-result-message']"); + const waitRAF = () => new Promise((resolve) => requestAnimationFrame(resolve)); + const createStore = ({ state, activeGroupProjects }) => { Vue.use(Vuex); @@ -61,6 +69,7 @@ describe('ProjectSelect component', () => { provide: { groupId: 1, }, + attachTo: document.body, }); }; @@ -120,6 +129,17 @@ describe('ProjectSelect component', () => { it('does not render empty search result message', () => { expect(findEmptySearchMessage().exists()).toBe(false); }); + + it('focuses on the search input', async () => { + const dropdownToggle = findGlDropdown().find('.dropdown-toggle'); + + await dropdownToggle.trigger('click'); + await waitRAF(); + await nextTick(); + + const searchInput = findGlDropdown().findComponent(GlFormInput).element; + expect(document.activeElement).toEqual(searchInput); + }); }); describe('when no projects are being returned', () => { diff --git a/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js b/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js index 5a1f17573d4..ed6dc598845 100644 --- a/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js +++ b/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js @@ -1,7 +1,5 @@ import { shallowMount, mount } from '@vue/test-utils'; -import { nextTick } from 'vue'; import Header from '~/vue_merge_request_widget/components/mr_widget_header.vue'; -import WebIdeLink from '~/vue_shared/components/web_ide_link.vue'; describe('MRWidgetHeader', () => { let wrapper; @@ -17,16 +15,6 @@ describe('MRWidgetHeader', () => { gon.relative_url_root = ''; }); - const expectDownloadDropdownItems = () => { - const downloadEmailPatchesEl = wrapper.find('.js-download-email-patches'); - const downloadPlainDiffEl = wrapper.find('.js-download-plain-diff'); - - expect(downloadEmailPatchesEl.text().trim()).toBe('Email patches'); - expect(downloadEmailPatchesEl.attributes('href')).toBe('/mr/email-patches'); - expect(downloadPlainDiffEl.text().trim()).toBe('Plain diff'); - expect(downloadPlainDiffEl.attributes('href')).toBe('/mr/plainDiffPath'); - }; - const commonMrProps = { divergedCommitsCount: 1, sourceBranch: 'mr-widget-refactor', @@ -36,8 +24,6 @@ describe('MRWidgetHeader', () => { statusPath: 'abc', }; - const findWebIdeButton = () => wrapper.findComponent(WebIdeLink); - describe('computed', () => { describe('shouldShowCommitsBehindText', () => { it('return true when there are divergedCommitsCount', () => { @@ -133,136 +119,6 @@ describe('MRWidgetHeader', () => { }); }); - describe('with an open merge request', () => { - const mrDefaultOptions = { - iid: 1, - divergedCommitsCount: 12, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', - sourceBranchRemoved: false, - targetBranchPath: 'foo/bar/commits-path', - targetBranchTreePath: 'foo/bar/tree/path', - targetBranch: 'main', - isOpen: true, - canPushToSourceBranch: true, - emailPatchesPath: '/mr/email-patches', - plainDiffPath: '/mr/plainDiffPath', - statusPath: 'abc', - sourceProjectFullPath: 'root/gitlab-ce', - targetProjectFullPath: 'gitlab-org/gitlab-ce', - gitpodEnabled: true, - showGitpodButton: true, - gitpodUrl: 'http://gitpod.localhost', - userPreferencesGitpodPath: '/-/profile/preferences#user_gitpod_enabled', - userProfileEnableGitpodPath: '/-/profile?user%5Bgitpod_enabled%5D=true', - }; - - it('renders checkout branch button with modal trigger', () => { - createComponent({ - mr: { ...mrDefaultOptions }, - }); - - const button = wrapper.find('.js-check-out-branch'); - - expect(button.text().trim()).toBe('Check out branch'); - }); - - it.each([ - [ - 'renders web ide button', - { - mrProps: {}, - relativeUrl: '', - webIdeUrl: - '/-/ide/project/root/gitlab-ce/merge_requests/1?target_project=gitlab-org%2Fgitlab-ce', - }, - ], - [ - 'renders web ide button with blank target_project, when mr has same target project', - { - mrProps: { targetProjectFullPath: 'root/gitlab-ce' }, - relativeUrl: '', - webIdeUrl: '/-/ide/project/root/gitlab-ce/merge_requests/1?target_project=', - }, - ], - [ - 'renders web ide button with relative url', - { - mrProps: { iid: 2 }, - relativeUrl: '/gitlab', - webIdeUrl: - '/gitlab/-/ide/project/root/gitlab-ce/merge_requests/2?target_project=gitlab-org%2Fgitlab-ce', - }, - ], - ])('%s', async (_, { mrProps, relativeUrl, webIdeUrl }) => { - gon.relative_url_root = relativeUrl; - createComponent({ - mr: { ...mrDefaultOptions, ...mrProps }, - }); - - await nextTick(); - - expect(findWebIdeButton().props()).toMatchObject({ - showEditButton: false, - showWebIdeButton: true, - webIdeText: 'Open in Web IDE', - gitpodText: 'Open in Gitpod', - gitpodEnabled: true, - showGitpodButton: true, - gitpodUrl: 'http://gitpod.localhost', - userPreferencesGitpodPath: mrDefaultOptions.userPreferencesGitpodPath, - userProfileEnableGitpodPath: mrDefaultOptions.userProfileEnableGitpodPath, - webIdeUrl, - }); - }); - - it('does not render web ide button if source branch is removed', async () => { - createComponent({ mr: { ...mrDefaultOptions, sourceBranchRemoved: true } }); - - await nextTick(); - - expect(findWebIdeButton().exists()).toBe(false); - }); - - it('renders download dropdown with links', () => { - createComponent({ - mr: { ...mrDefaultOptions }, - }); - - expectDownloadDropdownItems(); - }); - }); - - describe('with a closed merge request', () => { - beforeEach(() => { - createComponent({ - mr: { - divergedCommitsCount: 12, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', - sourceBranchRemoved: false, - targetBranchPath: 'foo/bar/commits-path', - targetBranchTreePath: 'foo/bar/tree/path', - targetBranch: 'main', - isOpen: false, - emailPatchesPath: '/mr/email-patches', - plainDiffPath: '/mr/plainDiffPath', - statusPath: 'abc', - }, - }); - }); - - it('does not render checkout branch button with modal trigger', () => { - const button = wrapper.find('.js-check-out-branch'); - - expect(button.exists()).toBe(false); - }); - - it('renders download dropdown with links', () => { - expectDownloadDropdownItems(); - }); - }); - describe('without diverged commits', () => { beforeEach(() => { createComponent({ diff --git a/spec/frontend/security_configuration/components/section_layout_spec.js b/spec/frontend/vue_shared/security_configuration/components/section_layout_spec.js index 75da380bbb8..136fe74b0d6 100644 --- a/spec/frontend/security_configuration/components/section_layout_spec.js +++ b/spec/frontend/vue_shared/security_configuration/components/section_layout_spec.js @@ -1,6 +1,7 @@ import { mount } from '@vue/test-utils'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; -import SectionLayout from '~/security_configuration/components/section_layout.vue'; +import SectionLayout from '~/vue_shared/security_configuration/components/section_layout.vue'; +import SectionLoader from '~/vue_shared/security_configuration/components/section_loader.vue'; describe('Section Layout component', () => { let wrapper; @@ -18,6 +19,7 @@ describe('Section Layout component', () => { }; const findHeading = () => wrapper.find('h2'); + const findLoader = () => wrapper.findComponent(SectionLoader); afterEach(() => { wrapper.destroy(); @@ -46,4 +48,11 @@ describe('Section Layout component', () => { }); }); }); + + describe('loading state', () => { + it('should show loaders when loading', () => { + createComponent({ heading: 'testheading', isLoading: true }); + expect(findLoader().exists()).toBe(true); + }); + }); }); |