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>2022-07-20 18:40:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-20 18:40:28 +0300
commitb595cb0c1dec83de5bdee18284abe86614bed33b (patch)
tree8c3d4540f193c5ff98019352f554e921b3a41a72 /spec/frontend/projects
parent2f9104a328fc8a4bddeaa4627b595166d24671d0 (diff)
Add latest changes from gitlab-org/gitlab@15-2-stable-eev15.2.0-rc42
Diffstat (limited to 'spec/frontend/projects')
-rw-r--r--spec/frontend/projects/new/components/new_project_url_select_spec.js25
-rw-r--r--spec/frontend/projects/pipelines/charts/components/app_spec.js80
-rw-r--r--spec/frontend/projects/settings/components/new_access_dropdown_spec.js23
3 files changed, 70 insertions, 58 deletions
diff --git a/spec/frontend/projects/new/components/new_project_url_select_spec.js b/spec/frontend/projects/new/components/new_project_url_select_spec.js
index ba22622e1f7..b6d4ee32cf5 100644
--- a/spec/frontend/projects/new/components/new_project_url_select_spec.js
+++ b/spec/frontend/projects/new/components/new_project_url_select_spec.js
@@ -4,6 +4,7 @@ import {
GlDropdownItem,
GlDropdownSectionHeader,
GlSearchBoxByType,
+ GlTruncate,
} from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils';
import Vue, { nextTick } from 'vue';
@@ -15,7 +16,6 @@ import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import eventHub from '~/projects/new/event_hub';
import NewProjectUrlSelect from '~/projects/new/components/new_project_url_select.vue';
import searchQuery from '~/projects/new/queries/search_namespaces_where_user_can_create_projects.query.graphql';
-import { s__ } from '~/locale';
describe('NewProjectUrlSelect component', () => {
let wrapper;
@@ -90,6 +90,7 @@ describe('NewProjectUrlSelect component', () => {
const findButtonLabel = () => wrapper.findComponent(GlButton);
const findDropdown = () => wrapper.findComponent(GlDropdown);
+ const findSelectedPath = () => wrapper.findComponent(GlTruncate);
const findInput = () => wrapper.findComponent(GlSearchBoxByType);
const findHiddenNamespaceInput = () => wrapper.find('[name="project[namespace_id]"]');
@@ -121,14 +122,15 @@ describe('NewProjectUrlSelect component', () => {
describe('when namespaceId is provided', () => {
beforeEach(() => {
- wrapper = mountComponent();
+ wrapper = mountComponent({ mountFn: mount });
});
it('renders a dropdown with the given namespace full path as the text', () => {
- const dropdownProps = findDropdown().props();
+ expect(findSelectedPath().props('text')).toBe(defaultProvide.namespaceFullPath);
+ });
- expect(dropdownProps.text).toBe(defaultProvide.namespaceFullPath);
- expect(dropdownProps.toggleClass).not.toContain('gl-text-gray-500!');
+ it('renders a dropdown without the class', () => {
+ expect(findDropdown().props('toggleClass')).not.toContain('gl-text-gray-500!');
});
it('renders a hidden input with the given namespace id', () => {
@@ -150,14 +152,15 @@ describe('NewProjectUrlSelect component', () => {
};
beforeEach(() => {
- wrapper = mountComponent({ provide });
+ wrapper = mountComponent({ provide, mountFn: mount });
});
it("renders a dropdown with the user's namespace full path as the text", () => {
- const dropdownProps = findDropdown().props();
+ expect(findSelectedPath().props('text')).toBe('Pick a group or namespace');
+ });
- expect(dropdownProps.text).toBe(s__('ProjectsNew|Pick a group or namespace'));
- expect(dropdownProps.toggleClass).toContain('gl-text-gray-500!');
+ it('renders a dropdown with the class', () => {
+ expect(findDropdown().props('toggleClass')).toContain('gl-text-gray-500!');
});
it("renders a hidden input with the user's namespace id", () => {
@@ -236,8 +239,8 @@ describe('NewProjectUrlSelect component', () => {
expect(listItems.at(2).text()).toBe(data.currentUser.groups.nodes[2].fullPath);
});
- it('sets the selection to the group', async () => {
- expect(findDropdown().props('text')).toBe(fullPath);
+ it('sets the selection to the group', () => {
+ expect(findSelectedPath().props('text')).toBe(fullPath);
});
});
diff --git a/spec/frontend/projects/pipelines/charts/components/app_spec.js b/spec/frontend/projects/pipelines/charts/components/app_spec.js
index 98c7856a61a..7b9011fa3d9 100644
--- a/spec/frontend/projects/pipelines/charts/components/app_spec.js
+++ b/spec/frontend/projects/pipelines/charts/components/app_spec.js
@@ -14,6 +14,7 @@ jest.mock('~/lib/utils/url_utility');
const DeploymentFrequencyChartsStub = { name: 'DeploymentFrequencyCharts', render: () => {} };
const LeadTimeChartsStub = { name: 'LeadTimeCharts', render: () => {} };
const TimeToRestoreServiceChartsStub = { name: 'TimeToRestoreServiceCharts', render: () => {} };
+const ChangeFailureRateChartsStub = { name: 'ChangeFailureRateCharts', render: () => {} };
const ProjectQualitySummaryStub = { name: 'ProjectQualitySummary', render: () => {} };
describe('ProjectsPipelinesChartsApp', () => {
@@ -33,6 +34,7 @@ describe('ProjectsPipelinesChartsApp', () => {
DeploymentFrequencyCharts: DeploymentFrequencyChartsStub,
LeadTimeCharts: LeadTimeChartsStub,
TimeToRestoreServiceCharts: TimeToRestoreServiceChartsStub,
+ ChangeFailureRateCharts: ChangeFailureRateChartsStub,
ProjectQualitySummary: ProjectQualitySummaryStub,
},
},
@@ -50,6 +52,7 @@ describe('ProjectsPipelinesChartsApp', () => {
const findGlTabAtIndex = (index) => findAllGlTabs().at(index);
const findLeadTimeCharts = () => wrapper.find(LeadTimeChartsStub);
const findTimeToRestoreServiceCharts = () => wrapper.find(TimeToRestoreServiceChartsStub);
+ const findChangeFailureRateCharts = () => wrapper.find(ChangeFailureRateChartsStub);
const findDeploymentFrequencyCharts = () => wrapper.find(DeploymentFrequencyChartsStub);
const findPipelineCharts = () => wrapper.find(PipelineCharts);
const findProjectQualitySummary = () => wrapper.find(ProjectQualitySummaryStub);
@@ -59,58 +62,49 @@ describe('ProjectsPipelinesChartsApp', () => {
createComponent();
});
- it('renders tabs', () => {
- expect(findGlTabs().exists()).toBe(true);
+ describe.each`
+ title | finderFn | index
+ ${'Pipelines'} | ${findPipelineCharts} | ${0}
+ ${'Deployment frequency'} | ${findDeploymentFrequencyCharts} | ${1}
+ ${'Lead time'} | ${findLeadTimeCharts} | ${2}
+ ${'Time to restore service'} | ${findTimeToRestoreServiceCharts} | ${3}
+ ${'Change failure rate'} | ${findChangeFailureRateCharts} | ${4}
+ ${'Project quality'} | ${findProjectQualitySummary} | ${5}
+ `('Tabs', ({ title, finderFn, index }) => {
+ it(`renders tab with a title ${title} at index ${index}`, () => {
+ expect(findGlTabAtIndex(index).attributes('title')).toBe(title);
+ });
- expect(findGlTabAtIndex(0).attributes('title')).toBe('Pipelines');
- expect(findGlTabAtIndex(1).attributes('title')).toBe('Deployment frequency');
- expect(findGlTabAtIndex(2).attributes('title')).toBe('Lead time');
- expect(findGlTabAtIndex(3).attributes('title')).toBe('Time to restore service');
- });
+ it(`renders the ${title} chart`, () => {
+ expect(finderFn().exists()).toBe(true);
+ });
- it('renders the pipeline charts', () => {
- expect(findPipelineCharts().exists()).toBe(true);
- });
+ it(`updates the current tab and url when the ${title} tab is clicked`, async () => {
+ let chartsPath;
+ const tabName = title.toLowerCase().replace(/\s/g, '-');
- it('renders the deployment frequency charts', () => {
- expect(findDeploymentFrequencyCharts().exists()).toBe(true);
- });
+ setWindowLocation(`${TEST_HOST}/gitlab-org/gitlab-test/-/pipelines/charts`);
- it('renders the lead time charts', () => {
- expect(findLeadTimeCharts().exists()).toBe(true);
- });
+ mergeUrlParams.mockImplementation(({ chart }, path) => {
+ expect(chart).toBe(tabName);
+ expect(path).toBe(window.location.pathname);
+ chartsPath = `${path}?chart=${chart}`;
+ return chartsPath;
+ });
- it('renders the time to restore service charts', () => {
- expect(findTimeToRestoreServiceCharts().exists()).toBe(true);
- });
+ updateHistory.mockImplementation(({ url }) => {
+ expect(url).toBe(chartsPath);
+ });
+ const tabs = findGlTabs();
- it('renders the project quality summary', () => {
- expect(findProjectQualitySummary().exists()).toBe(true);
- });
+ expect(tabs.attributes('value')).toBe('0');
- it('sets the tab and url when a tab is clicked', async () => {
- let chartsPath;
- setWindowLocation(`${TEST_HOST}/gitlab-org/gitlab-test/-/pipelines/charts`);
+ tabs.vm.$emit('input', index);
- mergeUrlParams.mockImplementation(({ chart }, path) => {
- expect(chart).toBe('deployment-frequency');
- expect(path).toBe(window.location.pathname);
- chartsPath = `${path}?chart=${chart}`;
- return chartsPath;
- });
+ await nextTick();
- updateHistory.mockImplementation(({ url }) => {
- expect(url).toBe(chartsPath);
+ expect(tabs.attributes('value')).toBe(index.toString());
});
- const tabs = findGlTabs();
-
- expect(tabs.attributes('value')).toBe('0');
-
- tabs.vm.$emit('input', 1);
-
- await nextTick();
-
- expect(tabs.attributes('value')).toBe('1');
});
it('should not try to push history if the tab does not change', async () => {
@@ -136,6 +130,7 @@ describe('ProjectsPipelinesChartsApp', () => {
${'deployment-frequency-tab'} | ${'p_analytics_ci_cd_deployment_frequency'}
${'lead-time-tab'} | ${'p_analytics_ci_cd_lead_time'}
${'time-to-restore-service-tab'} | ${'p_analytics_ci_cd_time_to_restore_service'}
+ ${'change-failure-rate-tab'} | ${'p_analytics_ci_cd_change_failure_rate'}
`('tracks the $event event when clicked', ({ testId, event }) => {
jest.spyOn(API, 'trackRedisHllUserEvent');
@@ -151,6 +146,7 @@ describe('ProjectsPipelinesChartsApp', () => {
describe('when provided with a query param', () => {
it.each`
chart | tab
+ ${'change-failure-rate'} | ${'4'}
${'time-to-restore-service'} | ${'3'}
${'lead-time'} | ${'2'}
${'deployment-frequency'} | ${'1'}
diff --git a/spec/frontend/projects/settings/components/new_access_dropdown_spec.js b/spec/frontend/projects/settings/components/new_access_dropdown_spec.js
index a42891423cd..1db48ce05d7 100644
--- a/spec/frontend/projects/settings/components/new_access_dropdown_spec.js
+++ b/spec/frontend/projects/settings/components/new_access_dropdown_spec.js
@@ -29,9 +29,20 @@ jest.mock('~/projects/settings/api/access_dropdown_api', () => ({
}),
getDeployKeys: jest.fn().mockResolvedValue({
data: [
- { id: 10, title: 'key10', fingerprint: 'abcdefghijklmnop', owner: { name: 'user1' } },
- { id: 11, title: 'key11', fingerprint: 'abcdefghijklmnop', owner: { name: 'user2' } },
- { id: 12, title: 'key12', fingerprint: 'abcdefghijklmnop', owner: { name: 'user3' } },
+ {
+ id: 10,
+ title: 'key10',
+ fingerprint: 'md5-abcdefghijklmnop',
+ fingerprint_sha256: 'sha256-abcdefghijklmnop',
+ owner: { name: 'user1' },
+ },
+ {
+ id: 11,
+ title: 'key11',
+ fingerprint_sha256: 'sha256-abcdefghijklmnop',
+ owner: { name: 'user2' },
+ },
+ { id: 12, title: 'key12', fingerprint: 'md5-abcdefghijklmnop', owner: { name: 'user3' } },
],
}),
}));
@@ -279,6 +290,7 @@ describe('Access Level Dropdown', () => {
{ id: 115, type: 'group', group_id: 5 },
{ id: 118, type: 'user', user_id: 8, name: 'user2' },
{ id: 121, type: 'deploy_key', deploy_key_id: 11 },
+ { id: 122, type: 'deploy_key', deploy_key_id: 12 },
];
const findSelected = (type) =>
@@ -309,8 +321,9 @@ describe('Access Level Dropdown', () => {
it('should set selected deploy keys as intersection between the server response and preselected mapping some keys', () => {
const selectedDeployKeys = findSelected(LEVEL_TYPES.DEPLOY_KEY);
- expect(selectedDeployKeys).toHaveLength(1);
- expect(selectedDeployKeys.at(0).text()).toContain('key11 (abcdefghijklmn...)');
+ expect(selectedDeployKeys).toHaveLength(2);
+ expect(selectedDeployKeys.at(0).text()).toContain('key11 (sha256-abcdefg...)');
+ expect(selectedDeployKeys.at(1).text()).toContain('key12 (md5-abcdefghij...)');
});
});