Commit d200c064 authored by Tiger's avatar Tiger Committed by Jose Vargas
parent 798aae91
...@@ -7,6 +7,7 @@ import { flow, reverse, sortBy } from 'lodash/fp'; ...@@ -7,6 +7,7 @@ import { flow, reverse, sortBy } from 'lodash/fp';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import EnvironmentItem from './environment_item.vue'; import EnvironmentItem from './environment_item.vue';
import DeployBoard from './deploy_board.vue'; import DeployBoard from './deploy_board.vue';
import CanaryUpdateModal from './canary_update_modal.vue';
import CanaryDeploymentCallout from './canary_deployment_callout.vue'; import CanaryDeploymentCallout from './canary_deployment_callout.vue';
export default { export default {
...@@ -16,7 +17,7 @@ export default { ...@@ -16,7 +17,7 @@ export default {
DeployBoard, DeployBoard,
CanaryDeploymentCallout, CanaryDeploymentCallout,
EnvironmentAlert: () => import('ee_component/environments/components/environment_alert.vue'), EnvironmentAlert: () => import('ee_component/environments/components/environment_alert.vue'),
CanaryUpdateModal: () => import('ee_component/environments/components/canary_update_modal.vue'), CanaryUpdateModal,
}, },
props: { props: {
environments: { environments: {
......
...@@ -153,7 +153,7 @@ export default class EnvironmentsStore { ...@@ -153,7 +153,7 @@ export default class EnvironmentsStore {
toggleDeployBoard(environmentID) { toggleDeployBoard(environmentID) {
const environments = this.state.environments.slice(); const environments = this.state.environments.slice();
this.state.environments = environments.map(env => { this.state.environments = environments.map((env) => {
let updated = { ...env }; let updated = { ...env };
if (env.id === environmentID) { if (env.id === environmentID) {
......
...@@ -15,6 +15,9 @@ class Projects::EnvironmentsController < Projects::ApplicationController ...@@ -15,6 +15,9 @@ class Projects::EnvironmentsController < Projects::ApplicationController
push_frontend_feature_flag(:prometheus_computed_alerts) push_frontend_feature_flag(:prometheus_computed_alerts)
push_frontend_feature_flag(:disable_metric_dashboard_refresh_rate) push_frontend_feature_flag(:disable_metric_dashboard_refresh_rate)
end end
before_action do
push_frontend_feature_flag(:canary_ingress_weight_control, default_enabled: true)
end
before_action :authorize_read_environment!, except: [:metrics, :additional_metrics, :metrics_dashboard, :metrics_redirect] before_action :authorize_read_environment!, except: [:metrics, :additional_metrics, :metrics_dashboard, :metrics_redirect]
before_action :authorize_create_environment!, only: [:new, :create] before_action :authorize_create_environment!, only: [:new, :create]
before_action :authorize_stop_environment!, only: [:stop] before_action :authorize_stop_environment!, only: [:stop]
......
...@@ -7,9 +7,6 @@ module EE ...@@ -7,9 +7,6 @@ module EE
prepended do prepended do
before_action :authorize_create_environment_terminal!, only: [:terminal] before_action :authorize_create_environment_terminal!, only: [:terminal]
before_action do
push_frontend_feature_flag(:canary_ingress_weight_control, default_enabled: true)
end
end end
private private
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import CanaryDeploymentBoard from 'ee/environments/components/canary_deployment_callout.vue'; import CanaryDeploymentBoard from '~/environments/components/canary_deployment_callout.vue';
import DeployBoard from 'ee/environments/components/deploy_board_component.vue'; import DeployBoard from '~/environments/components/deploy_board.vue';
import EnvironmentsComponent from '~/environments/components/environments_app.vue'; import EnvironmentsComponent from '~/environments/components/environments_app.vue';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { environment } from './mock_data'; import { environment } from './mock_data';
......
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import EnvironmentAlert from 'ee/environments/components/environment_alert.vue'; import EnvironmentAlert from 'ee/environments/components/environment_alert.vue';
import DeployBoard from 'ee/environments/components/deploy_board_component.vue';
import CanaryUpdateModal from 'ee/environments/components/canary_update_modal.vue';
import EnvironmentTable from '~/environments/components/environments_table.vue'; import EnvironmentTable from '~/environments/components/environments_table.vue';
describe('Environment table', () => { describe('Environment table', () => {
...@@ -51,40 +49,4 @@ describe('Environment table', () => { ...@@ -51,40 +49,4 @@ describe('Environment table', () => {
expect(wrapper.find(EnvironmentAlert).exists()).toBe(true); expect(wrapper.find(EnvironmentAlert).exists()).toBe(true);
}); });
it('should set the enviornment to change and weight when a change canary weight event is recevied', async () => {
const mockItem = {
name: 'review',
size: 1,
environment_path: 'url',
logs_path: 'url',
id: 1,
hasDeployBoard: true,
deployBoardData: deployBoardMockData,
isDeployBoardVisible: true,
isLoadingDeployBoard: false,
isEmptyDeployBoard: false,
};
await factory({
propsData: {
environments: [mockItem],
canCreateDeployment: false,
canReadEnvironment: true,
canaryDeploymentFeatureId: 'canary_deployment',
showCanaryDeploymentCallout: true,
userCalloutsPath: '/callouts',
lockPromotionSvgPath: '/assets/illustrations/lock-promotion.svg',
helpCanaryDeploymentsPath: 'help/canary-deployments',
},
});
wrapper.find(DeployBoard).vm.$emit('changeCanaryWeight', 40);
await wrapper.vm.$nextTick();
expect(wrapper.find(CanaryUpdateModal).props()).toMatchObject({
weight: 40,
environment: mockItem,
});
});
}); });
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { GlDropdownItem } from '@gitlab/ui'; import { GlDropdownItem } from '@gitlab/ui';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
import { CANARY_UPDATE_MODAL } from 'ee/environments/constants'; import { CANARY_UPDATE_MODAL } from '~/environments/constants';
import CanaryIngress from 'ee/environments/components/canary_ingress.vue'; import CanaryIngress from '~/environments/components/canary_ingress.vue';
describe('ee/environments/components/canary_ingress.vue', () => { describe('/environments/components/canary_ingress.vue', () => {
let wrapper; let wrapper;
const setWeightTo = (weightWrapper, x) => const setWeightTo = (weightWrapper, x) =>
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { GlAlert, GlModal } from '@gitlab/ui'; import { GlAlert, GlModal } from '@gitlab/ui';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import CanaryUpdateModal from 'ee/environments/components/canary_update_modal.vue'; import CanaryUpdateModal from '~/environments/components/canary_update_modal.vue';
import updateCanaryIngress from 'ee/environments/graphql/mutations/update_canary_ingress.mutation.graphql'; import updateCanaryIngress from '~/environments/graphql/mutations/update_canary_ingress.mutation.graphql';
describe('ee/environments/components/canary_update_modal.vue', () => { describe('/environments/components/canary_update_modal.vue', () => {
let wrapper; let wrapper;
let modal; let modal;
let mutate; let mutate;
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import EnvironmentTable from '~/environments/components/environments_table.vue'; import EnvironmentTable from '~/environments/components/environments_table.vue';
import eventHub from '~/environments/event_hub'; import eventHub from '~/environments/event_hub';
import DeployBoard from '~/environments/components/deploy_board.vue';
import CanaryUpdateModal from '~/environments/components/canary_update_modal.vue';
import { folder, deployBoardMockData } from './mock_data'; import { folder, deployBoardMockData } from './mock_data';
const eeOnlyProps = { const eeOnlyProps = {
...@@ -93,7 +95,7 @@ describe('Environment table', () => { ...@@ -93,7 +95,7 @@ describe('Environment table', () => {
expect(wrapper.find('.deploy-board-icon').exists()).toBe(true); expect(wrapper.find('.deploy-board-icon').exists()).toBe(true);
}); });
it('should toggle deploy board visibility when arrow is clicked', done => { it('should toggle deploy board visibility when arrow is clicked', (done) => {
const mockItem = { const mockItem = {
name: 'review', name: 'review',
size: 1, size: 1,
...@@ -106,11 +108,12 @@ describe('Environment table', () => { ...@@ -106,11 +108,12 @@ describe('Environment table', () => {
rollback_url: 'url', rollback_url: 'url',
completion: 100, completion: 100,
is_completed: true, is_completed: true,
canary_ingress: { canary_weight: 60 },
}, },
isDeployBoardVisible: false, isDeployBoardVisible: false,
}; };
eventHub.$on('toggleDeployBoard', env => { eventHub.$on('toggleDeployBoard', (env) => {
expect(env.id).toEqual(mockItem.id); expect(env.id).toEqual(mockItem.id);
done(); done();
}); });
...@@ -130,6 +133,42 @@ describe('Environment table', () => { ...@@ -130,6 +133,42 @@ describe('Environment table', () => {
wrapper.find('.deploy-board-icon').trigger('click'); wrapper.find('.deploy-board-icon').trigger('click');
}); });
it('should set the enviornment to change and weight when a change canary weight event is recevied', async () => {
const mockItem = {
name: 'review',
size: 1,
environment_path: 'url',
logs_path: 'url',
id: 1,
hasDeployBoard: true,
deployBoardData: deployBoardMockData,
isDeployBoardVisible: true,
isLoadingDeployBoard: false,
isEmptyDeployBoard: false,
};
await factory({
propsData: {
environments: [mockItem],
canCreateDeployment: false,
canReadEnvironment: true,
canaryDeploymentFeatureId: 'canary_deployment',
showCanaryDeploymentCallout: true,
userCalloutsPath: '/callouts',
lockPromotionSvgPath: '/assets/illustrations/lock-promotion.svg',
helpCanaryDeploymentsPath: 'help/canary-deployments',
},
});
wrapper.find(DeployBoard).vm.$emit('changeCanaryWeight', 40);
await wrapper.vm.$nextTick();
expect(wrapper.find(CanaryUpdateModal).props()).toMatchObject({
weight: 40,
environment: mockItem,
});
});
it('should render canary callout', async () => { it('should render canary callout', async () => {
const mockItem = { const mockItem = {
name: 'review', name: 'review',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment