summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-18 09:09:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-18 09:09:24 +0000
commit4720b569f0fcbb47e9f1a60e95172ae63b6f065a (patch)
tree5c6bcecbca227e608753a57a9aad19ccfe0567b6 /spec
parentcefe554b7ce2d0b52f9de855be832a47c2bc24ab (diff)
downloadgitlab-ce-4720b569f0fcbb47e9f1a60e95172ae63b6f065a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/.eslintrc.yml6
-rw-r--r--spec/frontend/gl_field_errors_spec.js2
-rw-r--r--spec/frontend/monitoring/components/charts/time_series_spec.js39
-rw-r--r--spec/frontend/registry/explorer/components/__snapshots__/registry_breadcrumb_spec.js.snap28
-rw-r--r--spec/frontend/registry/explorer/components/registry_breadcrumb_spec.js135
-rw-r--r--spec/frontend/registry/explorer/pages/details_spec.js4
-rw-r--r--spec/frontend/registry/explorer/stores/actions_spec.js23
-rw-r--r--spec/frontend/vue_shared/components/issue/issue_assignees_spec.js2
-rw-r--r--spec/lib/gitlab/git/blob_spec.rb10
9 files changed, 233 insertions, 16 deletions
diff --git a/spec/frontend/.eslintrc.yml b/spec/frontend/.eslintrc.yml
index e78a38d31f5..c8aacca5ef2 100644
--- a/spec/frontend/.eslintrc.yml
+++ b/spec/frontend/.eslintrc.yml
@@ -6,6 +6,12 @@ plugins:
extends:
- 'plugin:jest/recommended'
settings:
+ # We have to teach eslint-plugin-import what node modules we use
+ # otherwise there is an error when it tries to resolve them
+ import/core-modules:
+ - events
+ - fs
+ - path
import/resolver:
jest:
jestConfigFile: 'jest.config.js'
diff --git a/spec/frontend/gl_field_errors_spec.js b/spec/frontend/gl_field_errors_spec.js
index 4653f519f65..078659bf429 100644
--- a/spec/frontend/gl_field_errors_spec.js
+++ b/spec/frontend/gl_field_errors_spec.js
@@ -1,5 +1,3 @@
-/* eslint-disable arrow-body-style */
-
import $ from 'jquery';
import GlFieldErrors from '~/gl_field_errors';
diff --git a/spec/frontend/monitoring/components/charts/time_series_spec.js b/spec/frontend/monitoring/components/charts/time_series_spec.js
index cfd812002a4..a911b925b66 100644
--- a/spec/frontend/monitoring/components/charts/time_series_spec.js
+++ b/spec/frontend/monitoring/components/charts/time_series_spec.js
@@ -358,6 +358,45 @@ describe('Time series component', () => {
expect(optionSeries[0].name).toEqual(mockSeriesName);
});
});
+
+ it('additional y axis data', () => {
+ const mockCustomYAxisOption = {
+ name: 'Custom y axis label',
+ axisLabel: {
+ formatter: jest.fn(),
+ },
+ };
+
+ timeSeriesChart.setProps({
+ option: {
+ yAxis: mockCustomYAxisOption,
+ },
+ });
+
+ return timeSeriesChart.vm.$nextTick().then(() => {
+ const { yAxis } = getChartOptions();
+
+ expect(yAxis[0]).toMatchObject(mockCustomYAxisOption);
+ });
+ });
+
+ it('additional x axis data', () => {
+ const mockCustomXAxisOption = {
+ name: 'Custom x axis label',
+ };
+
+ timeSeriesChart.setProps({
+ option: {
+ xAxis: mockCustomXAxisOption,
+ },
+ });
+
+ return timeSeriesChart.vm.$nextTick().then(() => {
+ const { xAxis } = getChartOptions();
+
+ expect(xAxis).toMatchObject(mockCustomXAxisOption);
+ });
+ });
});
describe('yAxis formatter', () => {
diff --git a/spec/frontend/registry/explorer/components/__snapshots__/registry_breadcrumb_spec.js.snap b/spec/frontend/registry/explorer/components/__snapshots__/registry_breadcrumb_spec.js.snap
new file mode 100644
index 00000000000..feae2f629b7
--- /dev/null
+++ b/spec/frontend/registry/explorer/components/__snapshots__/registry_breadcrumb_spec.js.snap
@@ -0,0 +1,28 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Registry Breadcrumb when is rootRoute renders 1`] = `
+<ul>
+ <li
+ class="foo bar"
+ >
+ baz
+ </li>
+ <li
+ class="foo bar"
+ >
+ foo
+ </li>
+
+ <!---->
+
+ <li>
+ <a
+ class="foo"
+ >
+ <a>
+
+ </a>
+ </a>
+ </li>
+</ul>
+`;
diff --git a/spec/frontend/registry/explorer/components/registry_breadcrumb_spec.js b/spec/frontend/registry/explorer/components/registry_breadcrumb_spec.js
new file mode 100644
index 00000000000..7ce5ece21ee
--- /dev/null
+++ b/spec/frontend/registry/explorer/components/registry_breadcrumb_spec.js
@@ -0,0 +1,135 @@
+import { shallowMount } from '@vue/test-utils';
+
+import component from '~/registry/explorer/components/registry_breadcrumb.vue';
+
+describe('Registry Breadcrumb', () => {
+ let wrapper;
+ const nameGenerator = jest.fn();
+
+ const crumb = {
+ classList: ['foo', 'bar'],
+ tagName: 'div',
+ innerHTML: 'baz',
+ querySelector: jest.fn(),
+ children: [
+ {
+ tagName: 'a',
+ classList: ['foo'],
+ },
+ ],
+ };
+
+ const querySelectorReturnValue = {
+ classList: ['js-divider'],
+ tagName: 'svg',
+ innerHTML: 'foo',
+ };
+
+ const crumbs = [crumb, { ...crumb, innerHTML: 'foo' }, { ...crumb, classList: ['baz'] }];
+
+ const routes = [
+ { name: 'foo', meta: { nameGenerator, root: true } },
+ { name: 'baz', meta: { nameGenerator } },
+ ];
+
+ const findDivider = () => wrapper.find('.js-divider');
+ const findRootRoute = () => wrapper.find({ ref: 'rootRouteLink' });
+ const findChildRoute = () => wrapper.find({ ref: 'childRouteLink' });
+ const findLastCrumb = () => wrapper.find({ ref: 'lastCrumb' });
+
+ const mountComponent = $route => {
+ wrapper = shallowMount(component, {
+ propsData: {
+ crumbs,
+ },
+ stubs: {
+ 'router-link': { name: 'router-link', template: '<a><slot></slot></a>', props: ['to'] },
+ },
+ mocks: {
+ $route,
+ $router: {
+ options: {
+ routes,
+ },
+ },
+ },
+ });
+ };
+
+ beforeEach(() => {
+ nameGenerator.mockClear();
+ crumb.querySelector = jest.fn();
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ wrapper = null;
+ });
+
+ describe('when is rootRoute', () => {
+ beforeEach(() => {
+ mountComponent(routes[0]);
+ });
+
+ it('renders', () => {
+ expect(wrapper.element).toMatchSnapshot();
+ });
+
+ it('contains a router-link for the child route', () => {
+ expect(findChildRoute().exists()).toBe(true);
+ });
+
+ it('the link text is calculated by nameGenerator', () => {
+ expect(nameGenerator).toHaveBeenCalledWith(routes[0]);
+ expect(nameGenerator).toHaveBeenCalledTimes(1);
+ });
+ });
+
+ describe('when is not rootRoute', () => {
+ beforeEach(() => {
+ crumb.querySelector.mockReturnValue(querySelectorReturnValue);
+ mountComponent(routes[1]);
+ });
+
+ it('renders a divider', () => {
+ expect(findDivider().exists()).toBe(true);
+ });
+
+ it('contains a router-link for the root route', () => {
+ expect(findRootRoute().exists()).toBe(true);
+ });
+
+ it('contains a router-link for the child route', () => {
+ expect(findChildRoute().exists()).toBe(true);
+ });
+
+ it('the link text is calculated by nameGenerator', () => {
+ expect(nameGenerator).toHaveBeenCalledWith(routes[1]);
+ expect(nameGenerator).toHaveBeenCalledTimes(2);
+ });
+ });
+
+ describe('last crumb', () => {
+ const lastChildren = crumb.children[0];
+ beforeEach(() => {
+ nameGenerator.mockReturnValue('foo');
+ mountComponent(routes[0]);
+ });
+
+ it('has the same tag as the last children of the crumbs', () => {
+ expect(findLastCrumb().is(lastChildren.tagName)).toBe(true);
+ });
+
+ it('has the same classes as the last children of the crumbs', () => {
+ expect(findLastCrumb().classes()).toEqual(lastChildren.classList);
+ });
+
+ it('has a link to the current route', () => {
+ expect(findChildRoute().props('to')).toEqual({ to: routes[0].name });
+ });
+
+ it('the link has the correct text', () => {
+ expect(findChildRoute().text()).toEqual('foo');
+ });
+ });
+});
diff --git a/spec/frontend/registry/explorer/pages/details_spec.js b/spec/frontend/registry/explorer/pages/details_spec.js
index 205fb0e33dc..48f3b0f9b65 100644
--- a/spec/frontend/registry/explorer/pages/details_spec.js
+++ b/spec/frontend/registry/explorer/pages/details_spec.js
@@ -254,7 +254,7 @@ describe('Details Page', () => {
return wrapper.vm.$nextTick().then(() => {
expect(store.dispatch).toHaveBeenCalledWith('requestDeleteTag', {
tag: store.state.tags[0],
- imageId: wrapper.vm.$route.params.id,
+ params: wrapper.vm.$route.params.id,
});
// itemsToBeDeleted is not represented in the DOM, is used as parking variable between selected and deleted items
expect(wrapper.vm.itemsToBeDeleted).toEqual([]);
@@ -271,7 +271,7 @@ describe('Details Page', () => {
return wrapper.vm.$nextTick().then(() => {
expect(store.dispatch).toHaveBeenCalledWith('requestDeleteTags', {
ids: store.state.tags.map(t => t.name),
- imageId: wrapper.vm.$route.params.id,
+ params: wrapper.vm.$route.params.id,
});
// itemsToBeDeleted is not represented in the DOM, is used as parking variable between selected and deleted items
expect(wrapper.vm.itemsToBeDeleted).toEqual([]);
diff --git a/spec/frontend/registry/explorer/stores/actions_spec.js b/spec/frontend/registry/explorer/stores/actions_spec.js
index c1b977216ce..a3fb29c0eb9 100644
--- a/spec/frontend/registry/explorer/stores/actions_spec.js
+++ b/spec/frontend/registry/explorer/stores/actions_spec.js
@@ -121,14 +121,14 @@ describe('Actions RegistryExplorer Store', () => {
describe('fetch tags list', () => {
const url = `${endpoint}/1}`;
- const path = window.btoa(JSON.stringify({ tags_path: `${endpoint}/1}` }));
+ const params = window.btoa(JSON.stringify({ tags_path: `${endpoint}/1}` }));
it('sets the tagsList', done => {
mock.onGet(url).replyOnce(200, registryServerResponse, {});
testAction(
actions.requestTagsList,
- { id: path },
+ { params },
{},
[
{ type: types.SET_MAIN_LOADING, payload: true },
@@ -147,7 +147,7 @@ describe('Actions RegistryExplorer Store', () => {
it('should create flash on error', done => {
testAction(
actions.requestTagsList,
- { id: path },
+ { params },
{},
[
{ type: types.SET_MAIN_LOADING, payload: true },
@@ -165,7 +165,7 @@ describe('Actions RegistryExplorer Store', () => {
describe('request delete single tag', () => {
it('successfully performs the delete request', done => {
const deletePath = 'delete/path';
- const url = window.btoa(`${endpoint}/1}`);
+ const params = window.btoa(JSON.stringify({ tags_path: `${endpoint}/1}`, id: 1 }));
mock.onDelete(deletePath).replyOnce(200);
@@ -175,7 +175,7 @@ describe('Actions RegistryExplorer Store', () => {
tag: {
destroy_path: deletePath,
},
- imageId: url,
+ params,
},
{
tagsPagination: {},
@@ -187,7 +187,7 @@ describe('Actions RegistryExplorer Store', () => {
[
{
type: 'requestTagsList',
- payload: { pagination: {}, id: url },
+ payload: { pagination: {}, params },
},
],
() => {
@@ -220,9 +220,10 @@ describe('Actions RegistryExplorer Store', () => {
});
describe('request delete multiple tags', () => {
- const imageId = 1;
+ const id = 1;
+ const params = window.btoa(JSON.stringify({ id }));
const projectPath = 'project-path';
- const url = `${projectPath}/registry/repository/${imageId}/tags/bulk_destroy`;
+ const url = `${projectPath}/registry/repository/${id}/tags/bulk_destroy`;
it('successfully performs the delete request', done => {
mock.onDelete(url).replyOnce(200);
@@ -231,7 +232,7 @@ describe('Actions RegistryExplorer Store', () => {
actions.requestDeleteTags,
{
ids: [1, 2],
- imageId,
+ params,
},
{
config: {
@@ -246,7 +247,7 @@ describe('Actions RegistryExplorer Store', () => {
[
{
type: 'requestTagsList',
- payload: { pagination: {}, id: 1 },
+ payload: { pagination: {}, params },
},
],
() => {
@@ -263,7 +264,7 @@ describe('Actions RegistryExplorer Store', () => {
actions.requestDeleteTags,
{
ids: [1, 2],
- imageId,
+ params,
},
{
config: {
diff --git a/spec/frontend/vue_shared/components/issue/issue_assignees_spec.js b/spec/frontend/vue_shared/components/issue/issue_assignees_spec.js
index b00261ae067..ca75c55df26 100644
--- a/spec/frontend/vue_shared/components/issue/issue_assignees_spec.js
+++ b/spec/frontend/vue_shared/components/issue/issue_assignees_spec.js
@@ -18,7 +18,7 @@ describe('IssueAssigneesComponent', () => {
...props,
},
});
- vm = wrapper.vm; // eslint-disable-line
+ vm = wrapper.vm;
};
const findTooltipText = () => wrapper.find('.js-assignee-tooltip').text();
diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb
index 2495bc46c07..294e67a19d4 100644
--- a/spec/lib/gitlab/git/blob_spec.rb
+++ b/spec/lib/gitlab/git/blob_spec.rb
@@ -588,4 +588,14 @@ describe Gitlab::Git::Blob, :seed_helper do
end
end
end
+
+ describe 'metrics' do
+ it 'defines :gitlab_blob_truncated_true counter' do
+ expect(described_class).to respond_to(:gitlab_blob_truncated_true)
+ end
+
+ it 'defines :gitlab_blob_truncated_false counter' do
+ expect(described_class).to respond_to(:gitlab_blob_truncated_false)
+ end
+ end
end