summaryrefslogtreecommitdiff
path: root/spec/frontend/packages
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-13 12:12:59 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-13 12:12:59 +0000
commitb0891151f160d287e48a5317d3152b195ef950ae (patch)
tree88070363b2f28de0dfb3b0bdf77d71e9fa228e54 /spec/frontend/packages
parent9bc96aa4f94943af9972ca7058ed31771bbcaa53 (diff)
downloadgitlab-ce-b0891151f160d287e48a5317d3152b195ef950ae.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/packages')
-rw-r--r--spec/frontend/packages/shared/components/__snapshots__/publish_method_spec.js.snap42
-rw-r--r--spec/frontend/packages/shared/components/package_icon_and_name_spec.js32
-rw-r--r--spec/frontend/packages/shared/components/package_path_spec.js104
-rw-r--r--spec/frontend/packages/shared/components/package_tags_spec.js107
-rw-r--r--spec/frontend/packages/shared/components/packages_list_loader_spec.js51
-rw-r--r--spec/frontend/packages/shared/components/publish_method_spec.js50
-rw-r--r--spec/frontend/packages/shared/utils_spec.js69
7 files changed, 0 insertions, 455 deletions
diff --git a/spec/frontend/packages/shared/components/__snapshots__/publish_method_spec.js.snap b/spec/frontend/packages/shared/components/__snapshots__/publish_method_spec.js.snap
deleted file mode 100644
index acdf7c49ebd..00000000000
--- a/spec/frontend/packages/shared/components/__snapshots__/publish_method_spec.js.snap
+++ /dev/null
@@ -1,42 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`publish_method renders 1`] = `
-<div
- class="gl-display-flex gl-align-items-center"
->
- <gl-icon-stub
- class="gl-mr-2"
- name="git-merge"
- size="16"
- />
-
- <span
- class="gl-mr-2"
- data-testid="pipeline-ref"
- >
- branch-name
- </span>
-
- <gl-icon-stub
- class="gl-mr-2"
- name="commit"
- size="16"
- />
-
- <gl-link-stub
- class="gl-mr-2"
- data-testid="pipeline-sha"
- href="../commit/sha-baz"
- >
- sha-baz
- </gl-link-stub>
-
- <clipboard-button-stub
- category="tertiary"
- size="small"
- text="sha-baz"
- title="Copy commit SHA"
- tooltipplacement="top"
- />
-</div>
-`;
diff --git a/spec/frontend/packages/shared/components/package_icon_and_name_spec.js b/spec/frontend/packages/shared/components/package_icon_and_name_spec.js
deleted file mode 100644
index c96a570a29c..00000000000
--- a/spec/frontend/packages/shared/components/package_icon_and_name_spec.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import { GlIcon } from '@gitlab/ui';
-import { shallowMount } from '@vue/test-utils';
-import PackageIconAndName from '~/packages/shared/components/package_icon_and_name.vue';
-
-describe('PackageIconAndName', () => {
- let wrapper;
-
- const findIcon = () => wrapper.find(GlIcon);
-
- const mountComponent = () => {
- wrapper = shallowMount(PackageIconAndName, {
- slots: {
- default: 'test',
- },
- });
- };
-
- it('has an icon', () => {
- mountComponent();
-
- const icon = findIcon();
-
- expect(icon.exists()).toBe(true);
- expect(icon.props('name')).toBe('package');
- });
-
- it('renders the slot content', () => {
- mountComponent();
-
- expect(wrapper.text()).toBe('test');
- });
-});
diff --git a/spec/frontend/packages/shared/components/package_path_spec.js b/spec/frontend/packages/shared/components/package_path_spec.js
deleted file mode 100644
index edbdd55c1d7..00000000000
--- a/spec/frontend/packages/shared/components/package_path_spec.js
+++ /dev/null
@@ -1,104 +0,0 @@
-import { shallowMount } from '@vue/test-utils';
-import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
-import PackagePath from '~/packages/shared/components/package_path.vue';
-
-describe('PackagePath', () => {
- let wrapper;
-
- const mountComponent = (propsData = { path: 'foo' }) => {
- wrapper = shallowMount(PackagePath, {
- propsData,
- directives: {
- GlTooltip: createMockDirective(),
- },
- });
- };
-
- const BASE_ICON = 'base-icon';
- const ROOT_LINK = 'root-link';
- const ROOT_CHEVRON = 'root-chevron';
- const ELLIPSIS_ICON = 'ellipsis-icon';
- const ELLIPSIS_CHEVRON = 'ellipsis-chevron';
- const LEAF_LINK = 'leaf-link';
-
- const findItem = (name) => wrapper.find(`[data-testid="${name}"]`);
- const findTooltip = (w) => getBinding(w.element, 'gl-tooltip');
-
- afterEach(() => {
- wrapper.destroy();
- wrapper = null;
- });
-
- describe.each`
- path | rootUrl | shouldExist | shouldNotExist
- ${'foo/bar'} | ${'/foo/bar'} | ${[]} | ${[ROOT_CHEVRON, ELLIPSIS_ICON, ELLIPSIS_CHEVRON, LEAF_LINK]}
- ${'foo/bar/baz'} | ${'/foo/bar'} | ${[ROOT_CHEVRON, LEAF_LINK]} | ${[ELLIPSIS_ICON, ELLIPSIS_CHEVRON]}
- ${'foo/bar/baz/baz2'} | ${'/foo/bar'} | ${[ROOT_CHEVRON, LEAF_LINK, ELLIPSIS_ICON, ELLIPSIS_CHEVRON]} | ${[]}
- ${'foo/bar/baz/baz2/bar2'} | ${'/foo/bar'} | ${[ROOT_CHEVRON, LEAF_LINK, ELLIPSIS_ICON, ELLIPSIS_CHEVRON]} | ${[]}
- `('given path $path', ({ path, shouldExist, shouldNotExist, rootUrl }) => {
- const pathPieces = path.split('/').slice(1);
- const hasTooltip = shouldExist.includes(ELLIPSIS_ICON);
-
- describe('not disabled component', () => {
- beforeEach(() => {
- mountComponent({ path });
- });
-
- it('should have a base icon', () => {
- expect(findItem(BASE_ICON).exists()).toBe(true);
- });
-
- it('should have a root link', () => {
- const root = findItem(ROOT_LINK);
- expect(root.exists()).toBe(true);
- expect(root.attributes('href')).toBe(rootUrl);
- });
-
- if (hasTooltip) {
- it('should have a tooltip', () => {
- const tooltip = findTooltip(findItem(ELLIPSIS_ICON));
- expect(tooltip).toBeDefined();
- expect(tooltip.value).toMatchObject({
- title: path,
- });
- });
- }
-
- if (shouldExist.length) {
- it.each(shouldExist)(`should have %s`, (element) => {
- expect(findItem(element).exists()).toBe(true);
- });
- }
-
- if (shouldNotExist.length) {
- it.each(shouldNotExist)(`should not have %s`, (element) => {
- expect(findItem(element).exists()).toBe(false);
- });
- }
-
- if (shouldExist.includes(LEAF_LINK)) {
- it('the last link should be the last piece of the path', () => {
- const leaf = findItem(LEAF_LINK);
- expect(leaf.attributes('href')).toBe(`/${path}`);
- expect(leaf.text()).toBe(pathPieces[pathPieces.length - 1]);
- });
- }
- });
-
- describe('disabled component', () => {
- beforeEach(() => {
- mountComponent({ path, disabled: true });
- });
-
- it('root link is disabled', () => {
- expect(findItem(ROOT_LINK).attributes('disabled')).toBe('true');
- });
-
- if (shouldExist.includes(LEAF_LINK)) {
- it('the last link is disabled', () => {
- expect(findItem(LEAF_LINK).attributes('disabled')).toBe('true');
- });
- }
- });
- });
-});
diff --git a/spec/frontend/packages/shared/components/package_tags_spec.js b/spec/frontend/packages/shared/components/package_tags_spec.js
deleted file mode 100644
index 881b49cfb06..00000000000
--- a/spec/frontend/packages/shared/components/package_tags_spec.js
+++ /dev/null
@@ -1,107 +0,0 @@
-import { mount } from '@vue/test-utils';
-import PackageTags from '~/packages/shared/components/package_tags.vue';
-import { mockTags } from 'jest/packages_and_registries/infrastructure_registry/components/mock_data';
-
-describe('PackageTags', () => {
- let wrapper;
-
- function createComponent(tags = [], props = {}) {
- const propsData = {
- tags,
- ...props,
- };
-
- wrapper = mount(PackageTags, {
- propsData,
- });
- }
-
- const tagLabel = () => wrapper.find('[data-testid="tagLabel"]');
- const tagBadges = () => wrapper.findAll('[data-testid="tagBadge"]');
- const moreBadge = () => wrapper.find('[data-testid="moreBadge"]');
-
- afterEach(() => {
- if (wrapper) wrapper.destroy();
- });
-
- describe('tag label', () => {
- it('shows the tag label by default', () => {
- createComponent();
-
- expect(tagLabel().exists()).toBe(true);
- });
-
- it('hides when hideLabel prop is set to true', () => {
- createComponent(mockTags, { hideLabel: true });
-
- expect(tagLabel().exists()).toBe(false);
- });
- });
-
- it('renders the correct number of tags', () => {
- createComponent(mockTags.slice(0, 2));
-
- expect(tagBadges()).toHaveLength(2);
- expect(moreBadge().exists()).toBe(false);
- });
-
- it('does not render more than the configured tagDisplayLimit', () => {
- createComponent(mockTags);
-
- expect(tagBadges()).toHaveLength(2);
- });
-
- it('renders the more tags badge if there are more than the configured limit', () => {
- createComponent(mockTags);
-
- expect(tagBadges()).toHaveLength(2);
- expect(moreBadge().exists()).toBe(true);
- expect(moreBadge().text()).toContain('2');
- });
-
- it('renders the configured tagDisplayLimit when set in props', () => {
- createComponent(mockTags, { tagDisplayLimit: 1 });
-
- expect(tagBadges()).toHaveLength(1);
- expect(moreBadge().exists()).toBe(true);
- expect(moreBadge().text()).toContain('3');
- });
-
- describe('tagBadgeStyle', () => {
- const defaultStyle = ['badge', 'badge-info', 'gl-display-none'];
-
- it('shows tag badge when there is only one', () => {
- createComponent([mockTags[0]]);
-
- const expectedStyle = [...defaultStyle, 'gl-display-flex', 'gl-ml-3'];
-
- expect(tagBadges().at(0).classes()).toEqual(expect.arrayContaining(expectedStyle));
- });
-
- it('shows tag badge for medium or heigher resolutions', () => {
- createComponent(mockTags);
-
- const expectedStyle = [...defaultStyle, 'd-md-flex'];
-
- expect(tagBadges().at(1).classes()).toEqual(expect.arrayContaining(expectedStyle));
- });
-
- it('correctly prepends left and appends right when there is more than one tag', () => {
- createComponent(mockTags, {
- tagDisplayLimit: 4,
- });
-
- const expectedStyleWithoutAppend = [...defaultStyle, 'd-md-flex'];
- const expectedStyleWithAppend = [...expectedStyleWithoutAppend, 'gl-mr-2'];
-
- const allBadges = tagBadges();
-
- expect(allBadges.at(0).classes()).toEqual(
- expect.arrayContaining([...expectedStyleWithAppend, 'gl-ml-3']),
- );
- expect(allBadges.at(1).classes()).toEqual(expect.arrayContaining(expectedStyleWithAppend));
- expect(allBadges.at(2).classes()).toEqual(expect.arrayContaining(expectedStyleWithAppend));
- expect(allBadges.at(3).classes()).toEqual(expect.arrayContaining(expectedStyleWithoutAppend));
- });
- });
-});
diff --git a/spec/frontend/packages/shared/components/packages_list_loader_spec.js b/spec/frontend/packages/shared/components/packages_list_loader_spec.js
deleted file mode 100644
index 4ff01068f92..00000000000
--- a/spec/frontend/packages/shared/components/packages_list_loader_spec.js
+++ /dev/null
@@ -1,51 +0,0 @@
-import { mount } from '@vue/test-utils';
-import PackagesListLoader from '~/packages/shared/components/packages_list_loader.vue';
-
-describe('PackagesListLoader', () => {
- let wrapper;
-
- const createComponent = (props = {}) => {
- wrapper = mount(PackagesListLoader, {
- propsData: {
- ...props,
- },
- });
- };
-
- const findDesktopShapes = () => wrapper.find('[data-testid="desktop-loader"]');
- const findMobileShapes = () => wrapper.find('[data-testid="mobile-loader"]');
-
- beforeEach(createComponent);
-
- afterEach(() => {
- wrapper.destroy();
- wrapper = null;
- });
-
- describe('desktop loader', () => {
- it('produces the right loader', () => {
- expect(findDesktopShapes().findAll('rect[width="1000"]')).toHaveLength(20);
- });
-
- it('has the correct classes', () => {
- expect(findDesktopShapes().classes()).toEqual([
- 'gl-display-none',
- 'gl-sm-display-flex',
- 'gl-flex-direction-column',
- ]);
- });
- });
-
- describe('mobile loader', () => {
- it('produces the right loader', () => {
- expect(findMobileShapes().findAll('rect[height="170"]')).toHaveLength(5);
- });
-
- it('has the correct classes', () => {
- expect(findMobileShapes().classes()).toEqual([
- 'gl-flex-direction-column',
- 'gl-sm-display-none',
- ]);
- });
- });
-});
diff --git a/spec/frontend/packages/shared/components/publish_method_spec.js b/spec/frontend/packages/shared/components/publish_method_spec.js
deleted file mode 100644
index 784776fd3f0..00000000000
--- a/spec/frontend/packages/shared/components/publish_method_spec.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import { shallowMount } from '@vue/test-utils';
-import PublishMethod from '~/packages/shared/components/publish_method.vue';
-import { packageList } from 'jest/packages_and_registries/infrastructure_registry/components/mock_data';
-
-describe('publish_method', () => {
- let wrapper;
-
- const [packageWithoutPipeline, packageWithPipeline] = packageList;
-
- const findPipelineRef = () => wrapper.find('[data-testid="pipeline-ref"]');
- const findPipelineSha = () => wrapper.find('[data-testid="pipeline-sha"]');
- const findManualPublish = () => wrapper.find('[data-testid="manually-published"]');
-
- const mountComponent = (packageEntity = {}, isGroup = false) => {
- wrapper = shallowMount(PublishMethod, {
- propsData: {
- packageEntity,
- isGroup,
- },
- });
- };
-
- afterEach(() => {
- wrapper.destroy();
- wrapper = null;
- });
-
- it('renders', () => {
- mountComponent(packageWithPipeline);
- expect(wrapper.element).toMatchSnapshot();
- });
-
- describe('pipeline information', () => {
- it('displays branch and commit when pipeline info exists', () => {
- mountComponent(packageWithPipeline);
-
- expect(findPipelineRef().exists()).toBe(true);
- expect(findPipelineSha().exists()).toBe(true);
- });
-
- it('does not show any pipeline details when no information exists', () => {
- mountComponent(packageWithoutPipeline);
-
- expect(findPipelineRef().exists()).toBe(false);
- expect(findPipelineSha().exists()).toBe(false);
- expect(findManualPublish().exists()).toBe(true);
- expect(findManualPublish().text()).toBe('Manually Published');
- });
- });
-});
diff --git a/spec/frontend/packages/shared/utils_spec.js b/spec/frontend/packages/shared/utils_spec.js
deleted file mode 100644
index 94c16606cf8..00000000000
--- a/spec/frontend/packages/shared/utils_spec.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import { PackageType, TrackingCategories } from '~/packages/shared/constants';
-import {
- packageTypeToTrackCategory,
- beautifyPath,
- getPackageTypeLabel,
- getCommitLink,
-} from '~/packages/shared/utils';
-import { packageList } from 'jest/packages_and_registries/infrastructure_registry/components/mock_data';
-
-describe('Packages shared utils', () => {
- describe('packageTypeToTrackCategory', () => {
- it('prepend UI to package category', () => {
- expect(packageTypeToTrackCategory()).toMatchInlineSnapshot(`"UI::undefined"`);
- });
-
- it.each(Object.keys(PackageType))('returns a correct category string for %s', (packageKey) => {
- const packageName = PackageType[packageKey];
- expect(packageTypeToTrackCategory(packageName)).toBe(
- `UI::${TrackingCategories[packageName]}`,
- );
- });
- });
-
- describe('beautifyPath', () => {
- it('returns a string with spaces around /', () => {
- expect(beautifyPath('foo/bar')).toBe('foo / bar');
- });
- it('does not fail for empty string', () => {
- expect(beautifyPath()).toBe('');
- });
- });
-
- describe('getPackageTypeLabel', () => {
- describe.each`
- packageType | expectedResult
- ${'conan'} | ${'Conan'}
- ${'maven'} | ${'Maven'}
- ${'npm'} | ${'npm'}
- ${'nuget'} | ${'NuGet'}
- ${'pypi'} | ${'PyPI'}
- ${'rubygems'} | ${'RubyGems'}
- ${'composer'} | ${'Composer'}
- ${'debian'} | ${'Debian'}
- ${'helm'} | ${'Helm'}
- ${'foo'} | ${null}
- `(`package type`, ({ packageType, expectedResult }) => {
- it(`${packageType} should show as ${expectedResult}`, () => {
- expect(getPackageTypeLabel(packageType)).toBe(expectedResult);
- });
- });
- });
-
- describe('getCommitLink', () => {
- it('returns a relative link when isGroup is false', () => {
- const link = getCommitLink(packageList[0], false);
-
- expect(link).toContain('../commit');
- });
-
- describe('when isGroup is true', () => {
- it('returns an absolute link matching project path', () => {
- const mavenPackage = packageList[0];
- const link = getCommitLink(mavenPackage, true);
-
- expect(link).toContain(`/${mavenPackage.project_path}/commit`);
- });
- });
- });
-});