Commit 1966a037 authored by shampton's avatar shampton

Add test for feature flag

Testing to make sure the visual review app link
does not show up when feature flag is disabled
and vice versa.
parent 74927a2f
......@@ -2,19 +2,25 @@ import { mount, createLocalVue } from '@vue/test-utils';
import MrWidgetPipelineContainer from '~/vue_merge_request_widget/components/mr_widget_pipeline_container.vue';
import { MT_MERGE_STRATEGY, MWPS_MERGE_STRATEGY } from '~/vue_merge_request_widget/constants';
import MergeTrainPositionIndicator from 'ee/vue_merge_request_widget/components/merge_train_position_indicator.vue';
import VisualReviewAppLink from 'ee/vue_merge_request_widget/components/visual_review_app_link.vue';
import { mockStore } from 'spec/vue_mr_widget/mock_data';
describe('MrWidgetPipelineContainer', () => {
let wrapper;
const factory = (mrUpdates = {}) => {
const factory = (mrUpdates = {}, provide = {}) => {
const localVue = createLocalVue();
wrapper = mount(localVue.extend(MrWidgetPipelineContainer), {
propsData: {
mr: Object.assign({}, mockStore, mrUpdates),
},
provide: {
...provide,
},
localVue,
sync: false,
attachToDocument: true,
});
};
......@@ -50,4 +56,76 @@ describe('MrWidgetPipelineContainer', () => {
expect(wrapper.find(MergeTrainPositionIndicator).exists()).toBe(false);
});
});
describe('with anonymous visual review feedback feature flag enabled', () => {
beforeEach(() => {
factory(
{
visualReviewAppAvailable: true,
appUrl: 'http://gitlab.example.com',
iid: 1,
sourceProjectId: 20,
sourceProjectFullPath: 'source/project',
},
{
glFeatures: {
anonymousVisualReviewFeedback: true,
},
},
);
// the visual review app link component is lazy loaded
// so we need to re-render the component
return wrapper.vm.$nextTick();
});
it('renders the visual review app link', done => {
// the visual review app link component is lazy loaded
// so we need to re-render the component again, as once
// apparently isn't enough.
wrapper.vm
.$nextTick()
.then(() => {
expect(wrapper.find(VisualReviewAppLink).exists()).toEqual(true);
})
.then(done)
.catch(done.fail);
});
});
describe('with anonymous visual review feedback feature flag disabled', () => {
beforeEach(() => {
factory(
{
visualReviewAppAvailable: true,
appUrl: 'http://gitlab.example.com',
iid: 1,
sourceProjectId: 20,
sourceProjectFullPath: 'source/project',
},
{
glFeatures: {
anonymousVisualReviewFeedback: false,
},
},
);
// the visual review app link component is lazy loaded
// so we need to re-render the component
return wrapper.vm.$nextTick();
});
it('does not render the visual review app link', done => {
// the visual review app link component is lazy loaded
// so we need to re-render the component again, as once
// apparently isn't enough.
wrapper.vm
.$nextTick()
.then(() => {
expect(wrapper.find(VisualReviewAppLink).exists()).toEqual(false);
})
.then(done)
.catch(done.fail);
});
});
});
......@@ -284,7 +284,20 @@ export const mockStore = {
targetBranch: 'target-branch',
sourceBranch: 'source-branch',
sourceBranchLink: 'source-branch-link',
deployments: [{ id: 0, name: 'bogus' }, { id: 1, name: 'bogus-docs' }],
deployments: [
{
id: 0,
name: 'bogus',
external_url: 'https://fake.com',
external_url_formatted: 'https://fake.com',
},
{
id: 1,
name: 'bogus-docs',
external_url: 'https://fake.com',
external_url_formatted: 'https://fake.com',
},
],
postMergeDeployments: [{ id: 0, name: 'prod' }, { id: 1, name: 'prod-docs' }],
troubleshootingDocsPath: 'troubleshooting-docs-path',
ciStatus: 'ci-status',
......
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