summaryrefslogtreecommitdiff
path: root/spec/frontend/clusters
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-19 09:09:27 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-19 09:09:27 +0000
commit2af90cef2e2e9c776eae4394a43dba3be7f33d1e (patch)
treebb4bc691caa6cc74b45720ecd779517f9c8c2cd3 /spec/frontend/clusters
parentcf58004721ee715dd3884476f6fa0c62a7e7f247 (diff)
downloadgitlab-ce-2af90cef2e2e9c776eae4394a43dba3be7f33d1e.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/clusters')
-rw-r--r--spec/frontend/clusters/components/ingress_modsecurity_settings_spec.js48
-rw-r--r--spec/frontend/clusters/stores/clusters_store_spec.js2
2 files changed, 41 insertions, 9 deletions
diff --git a/spec/frontend/clusters/components/ingress_modsecurity_settings_spec.js b/spec/frontend/clusters/components/ingress_modsecurity_settings_spec.js
index beb0721260b..0fc7a48f97a 100644
--- a/spec/frontend/clusters/components/ingress_modsecurity_settings_spec.js
+++ b/spec/frontend/clusters/components/ingress_modsecurity_settings_spec.js
@@ -1,7 +1,7 @@
import { shallowMount } from '@vue/test-utils';
import IngressModsecuritySettings from '~/clusters/components/ingress_modsecurity_settings.vue';
import { APPLICATION_STATUS, INGRESS } from '~/clusters/constants';
-import { GlAlert, GlToggle } from '@gitlab/ui';
+import { GlAlert, GlToggle, GlDropdown } from '@gitlab/ui';
import eventHub from '~/clusters/event_hub';
const { UPDATING } = APPLICATION_STATUS;
@@ -13,6 +13,7 @@ describe('IngressModsecuritySettings', () => {
modsecurity_enabled: false,
status: 'installable',
installed: false,
+ modsecurity_mode: 'logging',
};
const createComponent = (props = defaultProps) => {
@@ -29,6 +30,7 @@ describe('IngressModsecuritySettings', () => {
const findSaveButton = () => wrapper.find('.btn-success');
const findCancelButton = () => wrapper.find('[variant="secondary"]');
const findModSecurityToggle = () => wrapper.find(GlToggle);
+ const findModSecurityDropdown = () => wrapper.find(GlDropdown);
describe('when ingress is installed', () => {
beforeEach(() => {
@@ -44,22 +46,50 @@ describe('IngressModsecuritySettings', () => {
describe('with toggle changed by the user', () => {
beforeEach(() => {
findModSecurityToggle().vm.$emit('change');
+ wrapper.setProps({
+ ingress: {
+ ...defaultProps,
+ installed: true,
+ status: 'installed',
+ modsecurity_enabled: true,
+ },
+ });
});
- it('renders both save and cancel buttons', () => {
+ it('renders save and cancel buttons', () => {
expect(findSaveButton().exists()).toBe(true);
expect(findCancelButton().exists()).toBe(true);
});
- describe('and the save changes button is clicked', () => {
+ describe('with dropdown changed by the user', () => {
beforeEach(() => {
- findSaveButton().vm.$emit('click');
+ findModSecurityDropdown().vm.$children[1].$emit('click');
+ wrapper.setProps({
+ ingress: {
+ ...defaultProps,
+ installed: true,
+ status: 'installed',
+ modsecurity_enabled: true,
+ modsecurity_mode: 'blocking',
+ },
+ });
+ });
+
+ it('renders both save and cancel buttons', () => {
+ expect(findSaveButton().exists()).toBe(true);
+ expect(findCancelButton().exists()).toBe(true);
});
- it('triggers save event and pass current modsecurity value', () => {
- expect(eventHub.$emit).toHaveBeenCalledWith('updateApplication', {
- id: INGRESS,
- params: { modsecurity_enabled: false },
+ describe('and the save changes button is clicked', () => {
+ beforeEach(() => {
+ findSaveButton().vm.$emit('click');
+ });
+
+ it('triggers save event and pass current modsecurity value', () => {
+ expect(eventHub.$emit).toHaveBeenCalledWith('updateApplication', {
+ id: INGRESS,
+ params: { modsecurity_enabled: true, modsecurity_mode: 'blocking' },
+ });
});
});
});
@@ -70,7 +100,7 @@ describe('IngressModsecuritySettings', () => {
});
it('triggers reset event and hides both cancel and save changes button', () => {
- expect(eventHub.$emit).toHaveBeenCalledWith('resetIngressModSecurityEnabled', INGRESS);
+ expect(eventHub.$emit).toHaveBeenCalledWith('resetIngressModSecurityChanges', INGRESS);
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 d3775c6cfba..0207fda84c4 100644
--- a/spec/frontend/clusters/stores/clusters_store_spec.js
+++ b/spec/frontend/clusters/stores/clusters_store_spec.js
@@ -82,6 +82,7 @@ describe('Clusters Store', () => {
externalHostname: null,
installed: false,
isEditingModSecurityEnabled: false,
+ isEditingModSecurityMode: false,
installFailed: true,
uninstallable: false,
updateFailed: false,
@@ -89,6 +90,7 @@ describe('Clusters Store', () => {
uninstallFailed: false,
validationError: null,
modsecurity_enabled: false,
+ modsecurity_mode: undefined,
},
runner: {
title: 'GitLab Runner',