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>2024-01-22 21:10:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-22 21:10:33 +0300
commita9a2f9257eae40935e03ca4185d5263bcb7ba45f (patch)
treef12875873819442e10ab04bd15fd975bf4bb7b64 /spec/frontend
parent917d93d86da4dffd96abcfcf3aa83b0d6fa45286 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/diffs/components/app_spec.js4
-rw-r--r--spec/frontend/diffs/components/diff_inline_findings_item_spec.js38
-rw-r--r--spec/frontend/diffs/components/diff_inline_findings_spec.js33
-rw-r--r--spec/frontend/diffs/components/diff_line_spec.js65
-rw-r--r--spec/frontend/diffs/components/diff_view_spec.js45
-rw-r--r--spec/frontend/diffs/components/inline_findings_spec.js33
-rw-r--r--spec/frontend/diffs/utils/diff_line_spec.js30
-rw-r--r--spec/frontend/members/components/filter_sort/sort_dropdown_spec.js65
8 files changed, 36 insertions, 277 deletions
diff --git a/spec/frontend/diffs/components/app_spec.js b/spec/frontend/diffs/components/app_spec.js
index 4676f56c47e..5e0dfd8bd09 100644
--- a/spec/frontend/diffs/components/app_spec.js
+++ b/spec/frontend/diffs/components/app_spec.js
@@ -195,10 +195,6 @@ describe('diffs/components/app', () => {
describe('codequality diff', () => {
it('does not fetch code quality data on FOSS', () => {
createComponent();
- jest.spyOn(wrapper.vm, 'fetchCodequality');
- wrapper.vm.fetchData(false);
-
- expect(wrapper.vm.fetchCodequality).not.toHaveBeenCalled();
expect(codeQualityAndSastQueryHandlerSuccess).not.toHaveBeenCalled();
});
});
diff --git a/spec/frontend/diffs/components/diff_inline_findings_item_spec.js b/spec/frontend/diffs/components/diff_inline_findings_item_spec.js
deleted file mode 100644
index cda3273d51e..00000000000
--- a/spec/frontend/diffs/components/diff_inline_findings_item_spec.js
+++ /dev/null
@@ -1,38 +0,0 @@
-import { GlIcon } from '@gitlab/ui';
-import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
-import DiffInlineFindingsItem from '~/diffs/components/diff_inline_findings_item.vue';
-import { SEVERITY_CLASSES, SEVERITY_ICONS } from '~/ci/reports/codequality_report/constants';
-import { multipleFindingsArrCodeQualityScale } from '../mock_data/inline_findings';
-
-let wrapper;
-
-const [codeQualityFinding] = multipleFindingsArrCodeQualityScale;
-const findIcon = () => wrapper.findComponent(GlIcon);
-const findDescriptionPlainText = () => wrapper.findByTestId('description-plain-text');
-
-describe('DiffCodeQuality', () => {
- const createWrapper = () => {
- return shallowMountExtended(DiffInlineFindingsItem, {
- propsData: {
- finding: codeQualityFinding,
- },
- });
- };
-
- it('shows icon for given degradation', () => {
- wrapper = createWrapper();
- expect(findIcon().exists()).toBe(true);
-
- expect(findIcon().attributes()).toMatchObject({
- class: `inline-findings-severity-icon ${SEVERITY_CLASSES[codeQualityFinding.severity]}`,
- name: SEVERITY_ICONS[codeQualityFinding.severity],
- size: '12',
- });
- });
-
- it('should render severity + description in plain text', () => {
- wrapper = createWrapper();
- expect(findDescriptionPlainText().text()).toContain(codeQualityFinding.severity);
- expect(findDescriptionPlainText().text()).toContain(codeQualityFinding.description);
- });
-});
diff --git a/spec/frontend/diffs/components/diff_inline_findings_spec.js b/spec/frontend/diffs/components/diff_inline_findings_spec.js
deleted file mode 100644
index f654a2e2d4f..00000000000
--- a/spec/frontend/diffs/components/diff_inline_findings_spec.js
+++ /dev/null
@@ -1,33 +0,0 @@
-import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
-import DiffInlineFindings from '~/diffs/components/diff_inline_findings.vue';
-import DiffInlineFindingsItem from '~/diffs/components/diff_inline_findings_item.vue';
-import { NEW_CODE_QUALITY_FINDINGS } from '~/diffs/i18n';
-import { multipleFindingsArrCodeQualityScale } from '../mock_data/inline_findings';
-
-let wrapper;
-const heading = () => wrapper.findByTestId('diff-inline-findings-heading');
-const diffInlineFindingsItems = () => wrapper.findAllComponents(DiffInlineFindingsItem);
-
-describe('DiffInlineFindings', () => {
- const createWrapper = () => {
- return shallowMountExtended(DiffInlineFindings, {
- propsData: {
- title: NEW_CODE_QUALITY_FINDINGS,
- findings: multipleFindingsArrCodeQualityScale,
- },
- });
- };
-
- it('renders the title correctly', () => {
- wrapper = createWrapper();
- expect(heading().text()).toBe(NEW_CODE_QUALITY_FINDINGS);
- });
-
- it('renders the correct number of DiffInlineFindingsItem components with correct props', () => {
- wrapper = createWrapper();
- expect(diffInlineFindingsItems()).toHaveLength(multipleFindingsArrCodeQualityScale.length);
- expect(diffInlineFindingsItems().wrappers[0].props('finding')).toEqual(
- wrapper.props('findings')[0],
- );
- });
-});
diff --git a/spec/frontend/diffs/components/diff_line_spec.js b/spec/frontend/diffs/components/diff_line_spec.js
deleted file mode 100644
index 501bd0757c8..00000000000
--- a/spec/frontend/diffs/components/diff_line_spec.js
+++ /dev/null
@@ -1,65 +0,0 @@
-import { shallowMount } from '@vue/test-utils';
-import DiffLine from '~/diffs/components/diff_line.vue';
-import InlineFindings from '~/diffs/components/inline_findings.vue';
-
-const EXAMPLE_LINE_NUMBER = 3;
-const EXAMPLE_DESCRIPTION = 'example description';
-const EXAMPLE_SEVERITY = 'example severity';
-
-const left = {
- line: {
- left: {
- codequality: [
- {
- line: EXAMPLE_LINE_NUMBER,
- description: EXAMPLE_DESCRIPTION,
- severity: EXAMPLE_SEVERITY,
- },
- ],
- },
- },
-};
-
-const right = {
- line: {
- right: {
- codequality: [
- {
- line: EXAMPLE_LINE_NUMBER,
- description: EXAMPLE_DESCRIPTION,
- severity: EXAMPLE_SEVERITY,
- },
- ],
- },
- },
-};
-
-const mockData = [right, left];
-
-describe('DiffLine', () => {
- const createWrapper = (propsData) => {
- return shallowMount(DiffLine, { propsData });
- };
-
- it('should emit event when hideInlineFindings is called', () => {
- const wrapper = createWrapper(right);
-
- wrapper.findComponent(InlineFindings).vm.$emit('hideInlineFindings');
- expect(wrapper.emitted()).toEqual({
- hideInlineFindings: [[EXAMPLE_LINE_NUMBER]],
- });
- });
-
- mockData.forEach((element) => {
- it('should set correct props for InlineFindings', () => {
- const wrapper = createWrapper(element);
- expect(wrapper.findComponent(InlineFindings).props('codeQuality')).toEqual([
- {
- line: EXAMPLE_LINE_NUMBER,
- description: EXAMPLE_DESCRIPTION,
- severity: EXAMPLE_SEVERITY,
- },
- ]);
- });
- });
-});
diff --git a/spec/frontend/diffs/components/diff_view_spec.js b/spec/frontend/diffs/components/diff_view_spec.js
index 2c8f751804e..2d42c0780b5 100644
--- a/spec/frontend/diffs/components/diff_view_spec.js
+++ b/spec/frontend/diffs/components/diff_view_spec.js
@@ -1,11 +1,9 @@
import { shallowMount } from '@vue/test-utils';
-import Vue, { nextTick } from 'vue';
+import Vue from 'vue';
// eslint-disable-next-line no-restricted-imports
import Vuex from 'vuex';
import { throttle } from 'lodash';
import DiffView from '~/diffs/components/diff_view.vue';
-import DiffLine from '~/diffs/components/diff_line.vue';
-import { diffCodeQuality } from '../mock_data/inline_findings';
jest.mock('lodash/throttle', () => jest.fn((fn) => fn));
const lodash = jest.requireActual('lodash');
@@ -19,7 +17,7 @@ describe('DiffView', () => {
const setSelectedCommentPosition = jest.fn();
const getDiffRow = (wrapper) => wrapper.findComponent(DiffRow).vm;
- const createWrapper = ({ props, flag = false } = {}) => {
+ const createWrapper = ({ props } = {}) => {
Vue.use(Vuex);
const batchComments = {
@@ -51,21 +49,10 @@ describe('DiffView', () => {
diffFile: { file_hash: '123' },
diffLines: [],
...props,
- provide: {
- glFeatures: {
- sastReportsInInlineDiff: flag,
- },
- },
- };
-
- const provide = {
- glFeatures: {
- sastReportsInInlineDiff: flag,
- },
};
const stubs = { DiffExpansionCell, DiffRow, DiffCommentCell, DraftNote };
- return shallowMount(DiffView, { propsData, provide, store, stubs });
+ return shallowMount(DiffView, { propsData, store, stubs });
};
beforeEach(() => {
@@ -76,32 +63,6 @@ describe('DiffView', () => {
throttle.mockReset();
});
- it('does not render a diff-line component when there is no finding', () => {
- const wrapper = createWrapper();
- expect(wrapper.findComponent(DiffLine).exists()).toBe(false);
- });
-
- it('does render a diff-line component with the correct props when there is a finding', async () => {
- const wrapper = createWrapper({ props: diffCodeQuality });
- wrapper.findComponent(DiffRow).vm.$emit('toggleCodeQualityFindings', 2);
- await nextTick();
- expect(wrapper.findComponent(DiffLine).props('line')).toBe(diffCodeQuality.diffLines[2]);
- });
-
- it('does not render a diff-line component when there is a finding and sastReportsInInlineDiff flag is true', async () => {
- const wrapper = createWrapper({ props: diffCodeQuality, flag: true });
- wrapper.findComponent(DiffRow).vm.$emit('toggleCodeQualityFindings', 2);
- await nextTick();
- expect(wrapper.findComponent(DiffLine).exists()).toBe(false);
- });
-
- it('does render a diff-line component when there is a finding and sastReportsInInlineDiff flag is false', async () => {
- const wrapper = createWrapper({ props: diffCodeQuality });
- wrapper.findComponent(DiffRow).vm.$emit('toggleCodeQualityFindings', 2);
- await nextTick();
- expect(wrapper.findComponent(DiffLine).exists()).toBe(true);
- });
-
it.each`
type | side | container | sides | total
${'parallel'} | ${'left'} | ${'.old'} | ${{ left: { lineDrafts: [], renderDiscussion: true }, right: { lineDrafts: [], renderDiscussion: true } }} | ${2}
diff --git a/spec/frontend/diffs/components/inline_findings_spec.js b/spec/frontend/diffs/components/inline_findings_spec.js
deleted file mode 100644
index 102287a23b6..00000000000
--- a/spec/frontend/diffs/components/inline_findings_spec.js
+++ /dev/null
@@ -1,33 +0,0 @@
-import { mountExtended } from 'helpers/vue_test_utils_helper';
-import InlineFindings from '~/diffs/components/inline_findings.vue';
-import DiffInlineFindings from '~/diffs/components/diff_inline_findings.vue';
-import { NEW_CODE_QUALITY_FINDINGS } from '~/diffs/i18n';
-import { threeCodeQualityFindings } from '../mock_data/inline_findings';
-
-let wrapper;
-
-const diffInlineFindings = () => wrapper.findComponent(DiffInlineFindings);
-
-describe('InlineFindings', () => {
- const createWrapper = () => {
- return mountExtended(InlineFindings, {
- propsData: {
- codeQuality: threeCodeQualityFindings,
- },
- });
- };
-
- it('hides details and throws hideInlineFindings event on close click', async () => {
- wrapper = createWrapper();
- expect(wrapper.findByTestId('inline-findings').exists()).toBe(true);
-
- await wrapper.findByTestId('inline-findings-close').trigger('click');
- expect(wrapper.emitted('hideInlineFindings')).toHaveLength(1);
- });
-
- it('renders diff inline findings component with correct props for codequality array', () => {
- wrapper = createWrapper();
- expect(diffInlineFindings().props('title')).toBe(NEW_CODE_QUALITY_FINDINGS);
- expect(diffInlineFindings().props('findings')).toBe(threeCodeQualityFindings);
- });
-});
diff --git a/spec/frontend/diffs/utils/diff_line_spec.js b/spec/frontend/diffs/utils/diff_line_spec.js
deleted file mode 100644
index adcb4a4433c..00000000000
--- a/spec/frontend/diffs/utils/diff_line_spec.js
+++ /dev/null
@@ -1,30 +0,0 @@
-import { pickDirection } from '~/diffs/utils/diff_line';
-
-describe('diff_line utilities', () => {
- describe('pickDirection', () => {
- const left = {
- line_code: 'left',
- };
- const right = {
- line_code: 'right',
- };
- const defaultLine = {
- left,
- right,
- };
-
- it.each`
- code | pick | line | pickDescription
- ${'left'} | ${left} | ${defaultLine} | ${'the left line'}
- ${'right'} | ${right} | ${defaultLine} | ${'the right line'}
- ${'junk'} | ${left} | ${defaultLine} | ${'the default: the left line'}
- ${'junk'} | ${right} | ${{ right }} | ${"the right line if there's no left line to default to"}
- ${'right'} | ${left} | ${{ left }} | ${"the left line when there isn't a right line to match"}
- `(
- 'when provided a line and a line code `$code`, picks $pickDescription',
- ({ code, line, pick }) => {
- expect(pickDirection({ line, code })).toBe(pick);
- },
- );
- });
-});
diff --git a/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js b/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js
index 849a84b1a6f..1f98d0e7ce0 100644
--- a/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js
+++ b/spec/frontend/members/components/filter_sort/sort_dropdown_spec.js
@@ -1,12 +1,12 @@
-import { GlSorting, GlSortingItem } from '@gitlab/ui';
+import { GlSorting } from '@gitlab/ui';
import { mount } from '@vue/test-utils';
-import Vue from 'vue';
+import Vue, { nextTick } from 'vue';
// eslint-disable-next-line no-restricted-imports
import Vuex from 'vuex';
import setWindowLocation from 'helpers/set_window_location_helper';
import * as urlUtilities from '~/lib/utils/url_utility';
import SortDropdown from '~/members/components/filter_sort/sort_dropdown.vue';
-import { MEMBER_TYPES } from '~/members/constants';
+import { MEMBER_TYPES, FIELD_KEY_MAX_ROLE } from '~/members/constants';
Vue.use(Vuex);
@@ -47,59 +47,46 @@ describe('SortDropdown', () => {
const findSortingComponent = () => wrapper.findComponent(GlSorting);
const findSortDirectionToggle = () =>
findSortingComponent().find('button[title^="Sort direction"]');
- const findDropdownToggle = () => wrapper.find('button[aria-haspopup="menu"]');
- const findDropdownItemByText = (text) =>
- wrapper
- .findAllComponents(GlSortingItem)
- .wrappers.find((dropdownItemWrapper) => dropdownItemWrapper.text() === text);
+ const findDropdownToggle = () => wrapper.find('button[aria-haspopup="listbox"]');
beforeEach(() => {
setWindowLocation(URL_HOST);
});
describe('dropdown options', () => {
- it('adds dropdown items for all the sortable fields', () => {
+ it('sets sort options', () => {
const URL_FILTER_PARAMS = '?two_factor=enabled&search=foobar';
- const EXPECTED_BASE_URL = `${URL_HOST}${URL_FILTER_PARAMS}&sort=`;
setWindowLocation(URL_FILTER_PARAMS);
- const expectedDropdownItems = [
+ const expectedSortOptions = [
{
- label: 'Account',
- url: `${EXPECTED_BASE_URL}name_asc`,
+ text: 'Account',
+ value: 'account',
},
{
- label: 'Access granted',
- url: `${EXPECTED_BASE_URL}last_joined`,
+ text: 'Access granted',
+ value: 'granted',
},
{
- label: 'Max role',
- url: `${EXPECTED_BASE_URL}access_level_asc`,
+ text: 'Max role',
+ value: 'maxRole',
},
{
- label: 'Last sign-in',
- url: `${EXPECTED_BASE_URL}recent_sign_in`,
+ text: 'Last sign-in',
+ value: 'lastSignIn',
},
];
createComponent();
- expectedDropdownItems.forEach((expectedDropdownItem) => {
- const dropdownItem = findDropdownItemByText(expectedDropdownItem.label);
-
- expect(dropdownItem).not.toBe(null);
- expect(dropdownItem.find('a').attributes('href')).toBe(expectedDropdownItem.url);
+ expect(findSortingComponent().props()).toMatchObject({
+ text: expectedSortOptions[0].text,
+ isAscending: true,
+ sortBy: expectedSortOptions[0].value,
+ sortOptions: expectedSortOptions,
});
});
-
- it('checks selected sort option', () => {
- setWindowLocation('?sort=access_level_asc');
-
- createComponent();
-
- expect(findDropdownItemByText('Max role').vm.$attrs.active).toBe(true);
- });
});
describe('dropdown toggle', () => {
@@ -117,6 +104,20 @@ describe('SortDropdown', () => {
expect(findDropdownToggle().text()).toBe('Max role');
});
+
+ describe('select new sort field', () => {
+ beforeEach(async () => {
+ jest.spyOn(urlUtilities, 'visitUrl').mockImplementation();
+ createComponent();
+
+ findSortingComponent().vm.$emit('sortByChange', FIELD_KEY_MAX_ROLE);
+ await nextTick();
+ });
+
+ it('sorts by new field', () => {
+ expect(urlUtilities.visitUrl).toHaveBeenCalledWith(`${URL_HOST}?sort=access_level_asc`);
+ });
+ });
});
describe('sort direction toggle', () => {