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
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-29 21:09:56 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-29 21:09:56 +0300
commit6f2dc439265369de7b1e1b18b208c6d66cf260eb (patch)
treec961526575126eafdd022ae7b496830dcf252002 /spec
parent647de7e6fd971d435396cc8730a2d162240e3d7c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/static_site_editor_controller_spec.rb5
-rw-r--r--spec/frontend/__mocks__/@toast-ui/vue-editor/index.js6
-rw-r--r--spec/frontend/clusters/components/fluentd_output_settings_spec.js152
-rw-r--r--spec/frontend/clusters/stores/clusters_store_spec.js2
-rw-r--r--spec/frontend/vue_shared/components/rich_content_editor/rich_content_editor_spec.js29
-rw-r--r--spec/models/ci/build_spec.rb10
-rw-r--r--spec/routing/project_routing_spec.rb6
7 files changed, 146 insertions, 64 deletions
diff --git a/spec/controllers/projects/static_site_editor_controller_spec.rb b/spec/controllers/projects/static_site_editor_controller_spec.rb
index f7c8848b8cf..f5d93122f59 100644
--- a/spec/controllers/projects/static_site_editor_controller_spec.rb
+++ b/spec/controllers/projects/static_site_editor_controller_spec.rb
@@ -58,6 +58,11 @@ describe Projects::StaticSiteEditorController do
expect(assigns(:config)).to be_a(Gitlab::StaticSiteEditor::Config)
end
+ it 'correctly assigns ref and path' do
+ expect(assigns(:ref)).to eq('master')
+ expect(assigns(:path)).to eq('README.md')
+ end
+
context 'when combination of ref and file path is incorrect' do
let(:default_params) { super().merge(id: 'unknown') }
diff --git a/spec/frontend/__mocks__/@toast-ui/vue-editor/index.js b/spec/frontend/__mocks__/@toast-ui/vue-editor/index.js
index 5ca620c24cf..03279fc56a4 100644
--- a/spec/frontend/__mocks__/@toast-ui/vue-editor/index.js
+++ b/spec/frontend/__mocks__/@toast-ui/vue-editor/index.js
@@ -4,6 +4,12 @@ export const Editor = {
type: String,
required: true,
},
+ options: {
+ type: Object,
+ },
+ initialEditType: {
+ type: String,
+ },
},
render(h) {
return h('div');
diff --git a/spec/frontend/clusters/components/fluentd_output_settings_spec.js b/spec/frontend/clusters/components/fluentd_output_settings_spec.js
index 360478b36f5..5e27cc49049 100644
--- a/spec/frontend/clusters/components/fluentd_output_settings_spec.js
+++ b/spec/frontend/clusters/components/fluentd_output_settings_spec.js
@@ -1,7 +1,7 @@
import { shallowMount } from '@vue/test-utils';
import FluentdOutputSettings from '~/clusters/components/fluentd_output_settings.vue';
import { APPLICATION_STATUS, FLUENTD } from '~/clusters/constants';
-import { GlAlert, GlDropdown } from '@gitlab/ui';
+import { GlAlert, GlDropdown, GlFormCheckbox } from '@gitlab/ui';
import eventHub from '~/clusters/event_hub';
const { UPDATING } = APPLICATION_STATUS;
@@ -9,34 +9,58 @@ const { UPDATING } = APPLICATION_STATUS;
describe('FluentdOutputSettings', () => {
let wrapper;
- const defaultProps = {
- status: 'installable',
- installed: false,
- updateAvailable: false,
+ const defaultSettings = {
protocol: 'tcp',
host: '127.0.0.1',
port: 514,
- isEditingSettings: false,
+ wafLogEnabled: true,
+ ciliumLogEnabled: false,
+ };
+ const defaultProps = {
+ status: 'installable',
+ updateFailed: false,
+ ...defaultSettings,
};
const createComponent = (props = {}) => {
wrapper = shallowMount(FluentdOutputSettings, {
propsData: {
- fluentd: {
- ...defaultProps,
- ...props,
- },
+ ...defaultProps,
+ ...props,
},
});
};
-
+ const updateComponentPropsFromEvent = () => {
+ const { isEditingSettings, ...props } = eventHub.$emit.mock.calls[0][1];
+ wrapper.setProps(props);
+ };
const findSaveButton = () => wrapper.find({ ref: 'saveBtn' });
const findCancelButton = () => wrapper.find({ ref: 'cancelBtn' });
const findProtocolDropdown = () => wrapper.find(GlDropdown);
+ const findCheckbox = name =>
+ wrapper.findAll(GlFormCheckbox).wrappers.find(x => x.text() === name);
+ const findHost = () => wrapper.find('#fluentd-host');
+ const findPort = () => wrapper.find('#fluentd-port');
+ const changeCheckbox = checkbox => {
+ const currentValue = checkbox.attributes('checked')?.toString() === 'true';
+ checkbox.vm.$emit('input', !currentValue);
+ };
+ const changeInput = ({ element }, val) => {
+ element.value = val;
+ element.dispatchEvent(new Event('input'));
+ };
+ const changePort = val => changeInput(findPort(), val);
+ const changeHost = val => changeInput(findHost(), val);
+ const changeProtocol = idx => findProtocolDropdown().vm.$children[idx].$emit('click');
+ const toApplicationSettings = ({ wafLogEnabled, ciliumLogEnabled, ...settings }) => ({
+ ...settings,
+ waf_log_enabled: wafLogEnabled,
+ cilium_log_enabled: ciliumLogEnabled,
+ });
describe('when fluentd is installed', () => {
beforeEach(() => {
- createComponent({ installed: true, status: 'installed' });
+ createComponent({ status: 'installed' });
jest.spyOn(eventHub, '$emit');
});
@@ -45,73 +69,77 @@ describe('FluentdOutputSettings', () => {
expect(findCancelButton().exists()).toBe(false);
});
- describe('with protocol dropdown changed by the user', () => {
+ describe.each`
+ desc | changeFn | key | value
+ ${'when protocol dropdown is triggered'} | ${() => changeProtocol(1)} | ${'protocol'} | ${'udp'}
+ ${'when host is changed'} | ${() => changeHost('test-host')} | ${'host'} | ${'test-host'}
+ ${'when port is changed'} | ${() => changePort(123)} | ${'port'} | ${123}
+ ${'when wafLogEnabled changes'} | ${() => changeCheckbox(findCheckbox('Send ModSecurity Logs'))} | ${'wafLogEnabled'} | ${!defaultSettings.wafLogEnabled}
+ ${'when ciliumLogEnabled changes'} | ${() => changeCheckbox(findCheckbox('Send Cilium Logs'))} | ${'ciliumLogEnabled'} | ${!defaultSettings.ciliumLogEnabled}
+ `('$desc', ({ changeFn, key, value }) => {
beforeEach(() => {
- findProtocolDropdown().vm.$children[1].$emit('click');
- wrapper.setProps({
- fluentd: {
- ...defaultProps,
- installed: true,
- status: 'installed',
- protocol: 'udp',
- isEditingSettings: true,
- },
- });
- });
-
- it('renders save and cancel buttons', () => {
- expect(findSaveButton().exists()).toBe(true);
- expect(findCancelButton().exists()).toBe(true);
- });
-
- it('enables related toggle and buttons', () => {
- expect(findSaveButton().attributes().disabled).toBeUndefined();
- expect(findCancelButton().attributes().disabled).toBeUndefined();
+ changeFn();
});
it('triggers set event to be propagated with the current value', () => {
expect(eventHub.$emit).toHaveBeenCalledWith('setFluentdSettings', {
- id: FLUENTD,
- host: '127.0.0.1',
- port: 514,
- protocol: 'UDP',
+ [key]: value,
+ isEditingSettings: true,
});
});
- describe('and the save changes button is clicked', () => {
+ describe('when value is updated from store', () => {
beforeEach(() => {
- findSaveButton().vm.$emit('click');
+ updateComponentPropsFromEvent();
+ });
+
+ it('enables save and cancel buttons', () => {
+ expect(findSaveButton().exists()).toBe(true);
+ expect(findSaveButton().attributes().disabled).toBeUndefined();
+ expect(findCancelButton().exists()).toBe(true);
+ expect(findCancelButton().attributes().disabled).toBeUndefined();
});
- it('triggers save event and pass current values', () => {
- expect(eventHub.$emit).toHaveBeenCalledWith('updateApplication', {
- id: FLUENTD,
- params: {
- host: '127.0.0.1',
- port: 514,
- protocol: 'udp',
- },
+ describe('and the save changes button is clicked', () => {
+ beforeEach(() => {
+ eventHub.$emit.mockClear();
+ findSaveButton().vm.$emit('click');
+ });
+
+ it('triggers save event and pass current values', () => {
+ expect(eventHub.$emit).toHaveBeenCalledWith('updateApplication', {
+ id: FLUENTD,
+ params: toApplicationSettings({
+ ...defaultSettings,
+ [key]: value,
+ }),
+ });
});
});
- });
- describe('and the cancel button is clicked', () => {
- beforeEach(() => {
- findCancelButton().vm.$emit('click');
- wrapper.setProps({
- fluentd: {
- ...defaultProps,
- installed: true,
- status: 'installed',
- protocol: 'udp',
+ describe('and the cancel button is clicked', () => {
+ beforeEach(() => {
+ eventHub.$emit.mockClear();
+ findCancelButton().vm.$emit('click');
+ });
+
+ it('triggers reset event', () => {
+ expect(eventHub.$emit).toHaveBeenCalledWith('setFluentdSettings', {
+ ...defaultSettings,
isEditingSettings: false,
- },
+ });
});
- });
- it('triggers reset event and hides both cancel and save changes button', () => {
- expect(findSaveButton().exists()).toBe(false);
- expect(findCancelButton().exists()).toBe(false);
+ describe('when value is updated from store', () => {
+ beforeEach(() => {
+ updateComponentPropsFromEvent();
+ });
+
+ it('does not render save and cancel buttons', () => {
+ expect(findSaveButton().exists()).toBe(false);
+ expect(findCancelButton().exists()).toBe(false);
+ });
+ });
});
});
});
diff --git a/spec/frontend/clusters/stores/clusters_store_spec.js b/spec/frontend/clusters/stores/clusters_store_spec.js
index 58e5bfb8007..36e99c37be5 100644
--- a/spec/frontend/clusters/stores/clusters_store_spec.js
+++ b/spec/frontend/clusters/stores/clusters_store_spec.js
@@ -127,6 +127,7 @@ describe('Clusters Store', () => {
statusReason: null,
requestReason: null,
port: null,
+ ciliumLogEnabled: null,
host: null,
protocol: null,
installed: false,
@@ -136,6 +137,7 @@ describe('Clusters Store', () => {
uninstallSuccessful: false,
uninstallFailed: false,
validationError: null,
+ wafLogEnabled: null,
},
jupyter: {
title: 'JupyterHub',
diff --git a/spec/frontend/vue_shared/components/rich_content_editor/rich_content_editor_spec.js b/spec/frontend/vue_shared/components/rich_content_editor/rich_content_editor_spec.js
index eb2baac3e76..933609c3072 100644
--- a/spec/frontend/vue_shared/components/rich_content_editor/rich_content_editor_spec.js
+++ b/spec/frontend/vue_shared/components/rich_content_editor/rich_content_editor_spec.js
@@ -4,6 +4,27 @@ import RichContentEditor from '~/vue_shared/components/rich_content_editor/rich_
describe('Rich Content Editor', () => {
let wrapper;
+ const editorOptions = {
+ toolbarItems: [
+ 'heading',
+ 'bold',
+ 'italic',
+ 'strike',
+ 'divider',
+ 'quote',
+ 'link',
+ 'codeblock',
+ 'divider',
+ 'ul',
+ 'ol',
+ 'task',
+ 'divider',
+ 'hr',
+ 'table',
+ 'divider',
+ 'code',
+ ],
+ };
const value = '## Some Markdown';
const findEditor = () => wrapper.find({ ref: 'editor' });
@@ -21,6 +42,14 @@ describe('Rich Content Editor', () => {
it('renders the correct content', () => {
expect(findEditor().props().initialValue).toBe(value);
});
+
+ it('provides the correct editor options', () => {
+ expect(findEditor().props().options).toEqual(editorOptions);
+ });
+
+ it('has the correct initial edit type', () => {
+ expect(findEditor().props().initialEditType).toBe('wysiwyg');
+ });
});
describe('when content is changed', () => {
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 5e9226989a5..266d39a0dfb 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -2350,6 +2350,16 @@ describe Ci::Build do
end
end
+ context 'when CI_JOB_JWT generation fails' do
+ it 'CI_JOB_JWT is not included' do
+ expect(Gitlab::Ci::Jwt).to receive(:for_build).and_raise(OpenSSL::PKey::RSAError, 'Neither PUB key nor PRIV key: not enough data')
+ expect(Gitlab::ErrorTracking).to receive(:track_exception)
+
+ expect { subject }.not_to raise_error
+ expect(subject.pluck(:key)).not_to include('CI_JOB_JWT')
+ end
+ end
+
describe 'variables ordering' do
context 'when variables hierarchy is stubbed' do
let(:build_pre_var) { { key: 'build', value: 'value', public: true, masked: false } }
diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb
index 0b2c0f38059..cbbd0dae2eb 100644
--- a/spec/routing/project_routing_spec.rb
+++ b/spec/routing/project_routing_spec.rb
@@ -822,8 +822,10 @@ describe 'project routing' do
describe Projects::StaticSiteEditorController, 'routing' do
it 'routes to static_site_editor#show', :aggregate_failures do
- expect(get('/gitlab/gitlabhq/-/sse/master/CONTRIBUTING.md')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/CONTRIBUTING.md')
- expect(get('/gitlab/gitlabhq/-/sse/master/README')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/README')
+ expect(get('/gitlab/gitlabhq/-/sse/master%2FCONTRIBUTING.md')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/CONTRIBUTING.md')
+ expect(get('/gitlab/gitlabhq/-/sse/master%2FCONTRIBUTING.md/')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/CONTRIBUTING.md')
+ expect(get('/gitlab/gitlabhq/-/sse/master%2FREADME/unsupported/error')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/README', vueroute: 'unsupported/error')
+ expect(get('/gitlab/gitlabhq/-/sse/master%2Flib%2FREADME/success')).to route_to('projects/static_site_editor#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/lib/README', vueroute: 'success')
end
end