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:
Diffstat (limited to 'spec/frontend/environments')
-rw-r--r--spec/frontend/environments/edit_environment_spec.js52
-rw-r--r--spec/frontend/environments/environment_form_spec.js48
-rw-r--r--spec/frontend/environments/environment_item_spec.js7
-rw-r--r--spec/frontend/environments/environment_table_spec.js11
-rw-r--r--spec/frontend/environments/environments_app_spec.js51
-rw-r--r--spec/frontend/environments/environments_detail_header_spec.js8
-rw-r--r--spec/frontend/environments/environments_folder_view_spec.js1
-rw-r--r--spec/frontend/environments/folder/environments_folder_view_spec.js1
8 files changed, 77 insertions, 102 deletions
diff --git a/spec/frontend/environments/edit_environment_spec.js b/spec/frontend/environments/edit_environment_spec.js
index 3e7f5dd5ff4..2c8c054ccbd 100644
--- a/spec/frontend/environments/edit_environment_spec.js
+++ b/spec/frontend/environments/edit_environment_spec.js
@@ -15,15 +15,12 @@ const DEFAULT_OPTS = {
projectEnvironmentsPath: '/projects/environments',
updateEnvironmentPath: '/proejcts/environments/1',
},
- propsData: { environment: { name: 'foo', externalUrl: 'https://foo.example.com' } },
+ propsData: { environment: { id: '0', name: 'foo', external_url: 'https://foo.example.com' } },
};
describe('~/environments/components/edit.vue', () => {
let wrapper;
let mock;
- let name;
- let url;
- let form;
const createWrapper = (opts = {}) =>
mountExtended(EditEnvironment, {
@@ -34,9 +31,6 @@ describe('~/environments/components/edit.vue', () => {
beforeEach(() => {
mock = new MockAdapter(axios);
wrapper = createWrapper();
- name = wrapper.findByLabelText('Name');
- url = wrapper.findByLabelText('External URL');
- form = wrapper.findByRole('form', { name: 'Edit environment' });
});
afterEach(() => {
@@ -44,19 +38,22 @@ describe('~/environments/components/edit.vue', () => {
wrapper.destroy();
});
+ const findNameInput = () => wrapper.findByLabelText('Name');
+ const findExternalUrlInput = () => wrapper.findByLabelText('External URL');
+ const findForm = () => wrapper.findByRole('form', { name: 'Edit environment' });
+
const showsLoading = () => wrapper.find(GlLoadingIcon).exists();
const submitForm = async (expected, response) => {
mock
.onPut(DEFAULT_OPTS.provide.updateEnvironmentPath, {
- name: expected.name,
external_url: expected.url,
+ id: '0',
})
.reply(...response);
- await name.setValue(expected.name);
- await url.setValue(expected.url);
+ await findExternalUrlInput().setValue(expected.url);
- await form.trigger('submit');
+ await findForm().trigger('submit');
await waitForPromises();
};
@@ -65,18 +62,8 @@ describe('~/environments/components/edit.vue', () => {
expect(header.exists()).toBe(true);
});
- it.each`
- input | value
- ${() => name} | ${'test'}
- ${() => url} | ${'https://example.org'}
- `('it changes the value of the input to $value', async ({ input, value }) => {
- await input().setValue(value);
-
- expect(input().element.value).toBe(value);
- });
-
it('shows loader after form is submitted', async () => {
- const expected = { name: 'test', url: 'https://google.ca' };
+ const expected = { url: 'https://google.ca' };
expect(showsLoading()).toBe(false);
@@ -86,7 +73,7 @@ describe('~/environments/components/edit.vue', () => {
});
it('submits the updated environment on submit', async () => {
- const expected = { name: 'test', url: 'https://google.ca' };
+ const expected = { url: 'https://google.ca' };
await submitForm(expected, [200, { path: '/test' }]);
@@ -94,11 +81,24 @@ describe('~/environments/components/edit.vue', () => {
});
it('shows errors on error', async () => {
- const expected = { name: 'test', url: 'https://google.ca' };
+ const expected = { url: 'https://google.ca' };
- await submitForm(expected, [400, { message: ['name taken'] }]);
+ await submitForm(expected, [400, { message: ['uh oh!'] }]);
- expect(createFlash).toHaveBeenCalledWith({ message: 'name taken' });
+ expect(createFlash).toHaveBeenCalledWith({ message: 'uh oh!' });
expect(showsLoading()).toBe(false);
});
+
+ it('renders a disabled "Name" field', () => {
+ const nameInput = findNameInput();
+
+ expect(nameInput.attributes().disabled).toBe('disabled');
+ expect(nameInput.element.value).toBe('foo');
+ });
+
+ it('renders an "External URL" field', () => {
+ const urlInput = findExternalUrlInput();
+
+ expect(urlInput.element.value).toBe('https://foo.example.com');
+ });
});
diff --git a/spec/frontend/environments/environment_form_spec.js b/spec/frontend/environments/environment_form_spec.js
index ed8fda71dab..f1af08bcf32 100644
--- a/spec/frontend/environments/environment_form_spec.js
+++ b/spec/frontend/environments/environment_form_spec.js
@@ -102,4 +102,52 @@ describe('~/environments/components/form.vue', () => {
wrapper = createWrapper({ loading: true });
expect(wrapper.findComponent(GlLoadingIcon).exists()).toBe(true);
});
+ describe('when a new environment is being created', () => {
+ beforeEach(() => {
+ wrapper = createWrapper({
+ environment: {
+ name: '',
+ externalUrl: '',
+ },
+ });
+ });
+
+ it('renders an enabled "Name" field', () => {
+ const nameInput = wrapper.findByLabelText('Name');
+
+ expect(nameInput.attributes().disabled).toBeUndefined();
+ expect(nameInput.element.value).toBe('');
+ });
+
+ it('renders an "External URL" field', () => {
+ const urlInput = wrapper.findByLabelText('External URL');
+
+ expect(urlInput.element.value).toBe('');
+ });
+ });
+
+ describe('when an existing environment is being edited', () => {
+ beforeEach(() => {
+ wrapper = createWrapper({
+ environment: {
+ id: 1,
+ name: 'test',
+ externalUrl: 'https://example.com',
+ },
+ });
+ });
+
+ it('renders a disabled "Name" field', () => {
+ const nameInput = wrapper.findByLabelText('Name');
+
+ expect(nameInput.attributes().disabled).toBe('disabled');
+ expect(nameInput.element.value).toBe('test');
+ });
+
+ it('renders an "External URL" field', () => {
+ const urlInput = wrapper.findByLabelText('External URL');
+
+ expect(urlInput.element.value).toBe('https://example.com');
+ });
+ });
});
diff --git a/spec/frontend/environments/environment_item_spec.js b/spec/frontend/environments/environment_item_spec.js
index a568a7d5396..b930259149f 100644
--- a/spec/frontend/environments/environment_item_spec.js
+++ b/spec/frontend/environments/environment_item_spec.js
@@ -31,7 +31,6 @@ describe('Environment item', () => {
factory({
propsData: {
model: environment,
- canReadEnvironment: true,
tableData,
},
});
@@ -135,7 +134,6 @@ describe('Environment item', () => {
factory({
propsData: {
model: environmentWithoutDeployable,
- canReadEnvironment: true,
tableData,
},
});
@@ -161,7 +159,6 @@ describe('Environment item', () => {
factory({
propsData: {
model: environmentWithoutUpcomingDeployment,
- canReadEnvironment: true,
tableData,
},
});
@@ -177,7 +174,6 @@ describe('Environment item', () => {
factory({
propsData: {
model: environment,
- canReadEnvironment: true,
tableData,
shouldShowAutoStopDate: true,
},
@@ -205,7 +201,6 @@ describe('Environment item', () => {
...environment,
auto_stop_at: futureDate,
},
- canReadEnvironment: true,
tableData,
shouldShowAutoStopDate: true,
},
@@ -241,7 +236,6 @@ describe('Environment item', () => {
...environment,
auto_stop_at: pastDate,
},
- canReadEnvironment: true,
tableData,
shouldShowAutoStopDate: true,
},
@@ -360,7 +354,6 @@ describe('Environment item', () => {
factory({
propsData: {
model: folder,
- canReadEnvironment: true,
tableData,
},
});
diff --git a/spec/frontend/environments/environment_table_spec.js b/spec/frontend/environments/environment_table_spec.js
index 71426ee5170..1851163ac68 100644
--- a/spec/frontend/environments/environment_table_spec.js
+++ b/spec/frontend/environments/environment_table_spec.js
@@ -28,7 +28,6 @@ describe('Environment table', () => {
factory({
propsData: {
environments: [folder],
- canReadEnvironment: true,
...eeOnlyProps,
},
});
@@ -50,7 +49,6 @@ describe('Environment table', () => {
await factory({
propsData: {
environments: [mockItem],
- canReadEnvironment: true,
userCalloutsPath: '/callouts',
lockPromotionSvgPath: '/assets/illustrations/lock-promotion.svg',
helpCanaryDeploymentsPath: 'help/canary-deployments',
@@ -78,7 +76,6 @@ describe('Environment table', () => {
propsData: {
environments: [mockItem],
canCreateDeployment: false,
- canReadEnvironment: true,
userCalloutsPath: '/callouts',
lockPromotionSvgPath: '/assets/illustrations/lock-promotion.svg',
helpCanaryDeploymentsPath: 'help/canary-deployments',
@@ -114,7 +111,6 @@ describe('Environment table', () => {
propsData: {
environments: [mockItem],
canCreateDeployment: false,
- canReadEnvironment: true,
userCalloutsPath: '/callouts',
lockPromotionSvgPath: '/assets/illustrations/lock-promotion.svg',
helpCanaryDeploymentsPath: 'help/canary-deployments',
@@ -151,7 +147,6 @@ describe('Environment table', () => {
factory({
propsData: {
environments: [mockItem],
- canReadEnvironment: true,
userCalloutsPath: '/callouts',
lockPromotionSvgPath: '/assets/illustrations/lock-promotion.svg',
helpCanaryDeploymentsPath: 'help/canary-deployments',
@@ -179,7 +174,6 @@ describe('Environment table', () => {
propsData: {
environments: [mockItem],
canCreateDeployment: false,
- canReadEnvironment: true,
userCalloutsPath: '/callouts',
lockPromotionSvgPath: '/assets/illustrations/lock-promotion.svg',
helpCanaryDeploymentsPath: 'help/canary-deployments',
@@ -230,7 +224,6 @@ describe('Environment table', () => {
factory({
propsData: {
environments: mockItems,
- canReadEnvironment: true,
...eeOnlyProps,
},
});
@@ -296,7 +289,6 @@ describe('Environment table', () => {
factory({
propsData: {
environments: mockItems,
- canReadEnvironment: true,
...eeOnlyProps,
},
});
@@ -335,7 +327,6 @@ describe('Environment table', () => {
factory({
propsData: {
environments: mockItems,
- canReadEnvironment: true,
...eeOnlyProps,
},
});
@@ -364,7 +355,6 @@ describe('Environment table', () => {
factory({
propsData: {
environments: mockItems,
- canReadEnvironment: true,
...eeOnlyProps,
},
});
@@ -415,7 +405,6 @@ describe('Environment table', () => {
factory({
propsData: {
environments: mockItems,
- canReadEnvironment: true,
...eeOnlyProps,
},
});
diff --git a/spec/frontend/environments/environments_app_spec.js b/spec/frontend/environments/environments_app_spec.js
index dc176001943..cd05ecbfb53 100644
--- a/spec/frontend/environments/environments_app_spec.js
+++ b/spec/frontend/environments/environments_app_spec.js
@@ -1,4 +1,4 @@
-import { GlTabs, GlAlert } from '@gitlab/ui';
+import { GlTabs } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter';
import { extendedWrapper } from 'helpers/vue_test_utils_helper';
@@ -7,9 +7,7 @@ import DeployBoard from '~/environments/components/deploy_board.vue';
import EmptyState from '~/environments/components/empty_state.vue';
import EnableReviewAppModal from '~/environments/components/enable_review_app_modal.vue';
import EnvironmentsApp from '~/environments/components/environments_app.vue';
-import { ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME } from '~/environments/constants';
import axios from '~/lib/utils/axios_utils';
-import { setCookie, getCookie, removeCookie } from '~/lib/utils/common_utils';
import * as urlUtils from '~/lib/utils/url_utility';
import { environment, folder } from './mock_data';
@@ -20,7 +18,6 @@ describe('Environment', () => {
const mockData = {
endpoint: 'environments.json',
canCreateEnvironment: true,
- canReadEnvironment: true,
newEnvironmentPath: 'environments/new',
helpPagePath: 'help',
userCalloutsPath: '/callouts',
@@ -50,7 +47,6 @@ describe('Environment', () => {
const findNewEnvironmentButton = () => wrapper.findByTestId('new-environment');
const findEnvironmentsTabAvailable = () => wrapper.find('.js-environments-tab-available > a');
const findEnvironmentsTabStopped = () => wrapper.find('.js-environments-tab-stopped > a');
- const findSurveyAlert = () => wrapper.find(GlAlert);
beforeEach(() => {
mock = new MockAdapter(axios);
@@ -283,49 +279,4 @@ describe('Environment', () => {
expect(wrapper.findComponent(GlTabs).attributes('value')).toBe('1');
});
});
-
- describe('survey alert', () => {
- beforeEach(async () => {
- mockRequest(200, { environments: [] });
- await createWrapper(true);
- });
-
- afterEach(() => {
- removeCookie(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME);
- });
-
- describe('when the user has not dismissed the alert', () => {
- it('shows the alert', () => {
- expect(findSurveyAlert().exists()).toBe(true);
- });
-
- describe('when the user dismisses the alert', () => {
- beforeEach(() => {
- findSurveyAlert().vm.$emit('dismiss');
- });
-
- it('hides the alert', () => {
- expect(findSurveyAlert().exists()).toBe(false);
- });
-
- it('persists the dismisal using a cookie', () => {
- const cookieValue = getCookie(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME);
-
- expect(cookieValue).toBe('true');
- });
- });
- });
-
- describe('when the user has previously dismissed the alert', () => {
- beforeEach(async () => {
- setCookie(ENVIRONMENTS_SURVEY_DISMISSED_COOKIE_NAME, 'true');
-
- await createWrapper(true);
- });
-
- it('does not show the alert', () => {
- expect(findSurveyAlert().exists()).toBe(false);
- });
- });
- });
});
diff --git a/spec/frontend/environments/environments_detail_header_spec.js b/spec/frontend/environments/environments_detail_header_spec.js
index 6334060c736..305e7385b43 100644
--- a/spec/frontend/environments/environments_detail_header_spec.js
+++ b/spec/frontend/environments/environments_detail_header_spec.js
@@ -44,7 +44,6 @@ describe('Environments detail header component', () => {
TimeAgo,
},
propsData: {
- canReadEnvironment: false,
canAdminEnvironment: false,
canUpdateEnvironment: false,
canStopEnvironment: false,
@@ -60,7 +59,7 @@ describe('Environments detail header component', () => {
describe('default state with minimal access', () => {
beforeEach(() => {
- createWrapper({ props: { environment: createEnvironment() } });
+ createWrapper({ props: { environment: createEnvironment({ externalUrl: null }) } });
});
it('displays the environment name', () => {
@@ -164,7 +163,6 @@ describe('Environments detail header component', () => {
createWrapper({
props: {
environment: createEnvironment({ hasTerminals: true, externalUrl }),
- canReadEnvironment: true,
},
});
});
@@ -178,8 +176,7 @@ describe('Environments detail header component', () => {
beforeEach(() => {
createWrapper({
props: {
- environment: createEnvironment(),
- canReadEnvironment: true,
+ environment: createEnvironment({ metricsUrl: 'my metrics url' }),
metricsPath,
},
});
@@ -195,7 +192,6 @@ describe('Environments detail header component', () => {
createWrapper({
props: {
environment: createEnvironment(),
- canReadEnvironment: true,
canAdminEnvironment: true,
canStopEnvironment: true,
canUpdateEnvironment: true,
diff --git a/spec/frontend/environments/environments_folder_view_spec.js b/spec/frontend/environments/environments_folder_view_spec.js
index e4661d27872..72a7449f24e 100644
--- a/spec/frontend/environments/environments_folder_view_spec.js
+++ b/spec/frontend/environments/environments_folder_view_spec.js
@@ -11,7 +11,6 @@ describe('Environments Folder View', () => {
const mockData = {
endpoint: 'environments.json',
folderName: 'review',
- canReadEnvironment: true,
cssContainerClass: 'container',
userCalloutsPath: '/callouts',
lockPromotionSvgPath: '/assets/illustrations/lock-promotion.svg',
diff --git a/spec/frontend/environments/folder/environments_folder_view_spec.js b/spec/frontend/environments/folder/environments_folder_view_spec.js
index d02ed8688c6..9eb57b2682f 100644
--- a/spec/frontend/environments/folder/environments_folder_view_spec.js
+++ b/spec/frontend/environments/folder/environments_folder_view_spec.js
@@ -14,7 +14,6 @@ describe('Environments Folder View', () => {
const mockData = {
endpoint: 'environments.json',
folderName: 'review',
- canReadEnvironment: true,
cssContainerClass: 'container',
userCalloutsPath: '/callouts',
lockPromotionSvgPath: '/assets/illustrations/lock-promotion.svg',