summaryrefslogtreecommitdiff
path: root/spec/frontend/super_sidebar
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-04-03 15:24:33 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-04-03 15:24:33 +0000
commit2a7fd3827b0838a900399b0c3440942cdaa09c75 (patch)
treeadb9315f24704a322c0c3e05da2f2b8e835fbf60 /spec/frontend/super_sidebar
parent6e228f38c37c4c7b6d6be648ae2664ebfb5c3c80 (diff)
downloadgitlab-ce-2a7fd3827b0838a900399b0c3440942cdaa09c75.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/super_sidebar')
-rw-r--r--spec/frontend/super_sidebar/components/super_sidebar_spec.js43
-rw-r--r--spec/frontend/super_sidebar/components/user_bar_spec.js17
2 files changed, 5 insertions, 55 deletions
diff --git a/spec/frontend/super_sidebar/components/super_sidebar_spec.js b/spec/frontend/super_sidebar/components/super_sidebar_spec.js
index b16371dae78..6eae650a2a1 100644
--- a/spec/frontend/super_sidebar/components/super_sidebar_spec.js
+++ b/spec/frontend/super_sidebar/components/super_sidebar_spec.js
@@ -1,8 +1,6 @@
-import { nextTick } from 'vue';
import { GlCollapse } from '@gitlab/ui';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import SuperSidebar from '~/super_sidebar/components/super_sidebar.vue';
-import { SUPER_SIDEBAR_PEEK_DELAY } from '~/super_sidebar/constants';
import HelpCenter from '~/super_sidebar/components/help_center.vue';
import UserBar from '~/super_sidebar/components/user_bar.vue';
import SidebarPortalTarget from '~/super_sidebar/components/sidebar_portal_target.vue';
@@ -19,19 +17,13 @@ const focusInputMock = jest.fn();
describe('SuperSidebar component', () => {
let wrapper;
- const findSidebar = () => wrapper.findByTestId('super-sidebar');
- const findHoverArea = () => wrapper.findByTestId('super-sidebar-hover-area');
+ const findSidebar = () => wrapper.find('.super-sidebar');
const findUserBar = () => wrapper.findComponent(UserBar);
const findHelpCenter = () => wrapper.findComponent(HelpCenter);
const findSidebarPortalTarget = () => wrapper.findComponent(SidebarPortalTarget);
- const createWrapper = ({ props = {}, isPeek = false } = {}) => {
+ const createWrapper = (props = {}) => {
wrapper = shallowMountExtended(SuperSidebar, {
- data() {
- return {
- isPeek,
- };
- },
propsData: {
sidebarData,
...props,
@@ -59,36 +51,6 @@ describe('SuperSidebar component', () => {
expect(findSidebar().attributes('inert')).toBe(undefined);
});
- it('updates inert attribute and `gl-visibility-hidden` class when peeking on hover', async () => {
- const setTimeoutSpy = jest.spyOn(global, 'setTimeout');
- isCollapsed.mockReturnValue(true);
- createWrapper();
-
- findHoverArea().trigger('mouseover');
- expect(setTimeoutSpy).toHaveBeenCalledTimes(1);
- expect(setTimeoutSpy).toHaveBeenLastCalledWith(
- expect.any(Function),
- SUPER_SIDEBAR_PEEK_DELAY,
- );
- jest.runAllTimers();
- await nextTick();
-
- expect(findSidebar().classes()).not.toContain('gl-visibility-hidden');
- expect(findSidebar().attributes('inert')).toBe(undefined);
-
- findSidebar().trigger('mouseleave');
- expect(setTimeoutSpy).toHaveBeenCalledTimes(2);
- expect(setTimeoutSpy).toHaveBeenLastCalledWith(
- expect.any(Function),
- SUPER_SIDEBAR_PEEK_DELAY,
- );
- jest.runAllTimers();
- await nextTick();
-
- expect(findSidebar().classes()).toContain('gl-visibility-hidden');
- expect(findSidebar().attributes('inert')).toBe('inert');
- });
-
it('renders UserBar with sidebarData', () => {
createWrapper();
expect(findUserBar().props('sidebarData')).toBe(sidebarData);
@@ -105,7 +67,6 @@ describe('SuperSidebar component', () => {
});
it("does not call the context switcher's focusInput method initially", () => {
- createWrapper();
expect(focusInputMock).not.toHaveBeenCalled();
});
});
diff --git a/spec/frontend/super_sidebar/components/user_bar_spec.js b/spec/frontend/super_sidebar/components/user_bar_spec.js
index a8bd8e341d6..48e62c3564d 100644
--- a/spec/frontend/super_sidebar/components/user_bar_spec.js
+++ b/spec/frontend/super_sidebar/components/user_bar_spec.js
@@ -19,7 +19,6 @@ describe('UserBar component', () => {
const findCreateMenu = () => wrapper.findComponent(CreateMenu);
const findCounter = (at) => wrapper.findAllComponents(Counter).at(at);
const findMergeRequestMenu = () => wrapper.findComponent(MergeRequestMenu);
- const findCollapseButton = () => wrapper.findByTestId('super-sidebar-collapse-button');
const findBrandLogo = () => wrapper.findByTestId('brand-header-custom-logo');
const findSearchButton = () => wrapper.findByTestId('super-sidebar-search-button');
const findSearchModal = () => wrapper.findComponent(SearchModal);
@@ -31,10 +30,9 @@ describe('UserBar component', () => {
searchOptions: () => MOCK_DEFAULT_SEARCH_OPTIONS,
},
});
- const createWrapper = ({ hasCollapseButton = true, extraSidebarData = {} } = {}) => {
+ const createWrapper = (extraSidebarData = {}) => {
wrapper = shallowMountExtended(UserBar, {
propsData: {
- hasCollapseButton,
sidebarData: { ...sidebarData, ...extraSidebarData },
},
provide: {
@@ -82,21 +80,12 @@ describe('UserBar component', () => {
expect(findBrandLogo().exists()).toBe(true);
expect(findBrandLogo().attributes('src')).toBe(sidebarData.logo_url);
});
-
- it('renders collapse button when hasCollapseButton is true', () => {
- expect(findCollapseButton().exists()).toBe(true);
- });
-
- it('does not render collapse button when hasCollapseButton is false', () => {
- createWrapper({ hasCollapseButton: false });
- expect(findCollapseButton().exists()).toBe(false);
- });
});
describe('GitLab Next badge', () => {
describe('when on canary', () => {
it('should render a badge to switch off GitLab Next', () => {
- createWrapper({ extraSidebarData: { gitlab_com_and_canary: true } });
+ createWrapper({ gitlab_com_and_canary: true });
const badge = wrapper.findComponent(GlBadge);
expect(badge.text()).toBe('Next');
expect(badge.attributes('href')).toBe(sidebarData.canary_toggle_com_url);
@@ -105,7 +94,7 @@ describe('UserBar component', () => {
describe('when not on canary', () => {
it('should not render the GitLab Next badge', () => {
- createWrapper({ extraSidebarData: { gitlab_com_and_canary: false } });
+ createWrapper({ gitlab_com_and_canary: false });
const badge = wrapper.findComponent(GlBadge);
expect(badge.exists()).toBe(false);
});