Commit 5366d23c authored by Paul Slaughter's avatar Paul Slaughter

Merge branch...

Merge branch '333014-make-the-call-to-register-ci-schema-only-when-schema_linting-ff-is-on' into 'master'

Register CI schema only when `schema_linting` ff is on

See merge request gitlab-org/gitlab!63552
parents 91604ec8 2d3db802
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
import { EDITOR_READY_EVENT } from '~/editor/constants'; import { EDITOR_READY_EVENT } from '~/editor/constants';
import { CiSchemaExtension } from '~/editor/extensions/editor_ci_schema_ext'; import { CiSchemaExtension } from '~/editor/extensions/editor_ci_schema_ext';
import EditorLite from '~/vue_shared/components/editor_lite.vue'; import EditorLite from '~/vue_shared/components/editor_lite.vue';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import getCommitSha from '../../graphql/queries/client/commit_sha.graphql'; import getCommitSha from '../../graphql/queries/client/commit_sha.graphql';
export default { export default {
components: { components: {
EditorLite, EditorLite,
}, },
mixins: [glFeatureFlagMixin()],
inject: ['ciConfigPath', 'projectPath', 'projectNamespace'], inject: ['ciConfigPath', 'projectPath', 'projectNamespace'],
inheritAttrs: false, inheritAttrs: false,
data() { data() {
...@@ -25,6 +27,7 @@ export default { ...@@ -25,6 +27,7 @@ export default {
this.$emit('updateCiConfig', content); this.$emit('updateCiConfig', content);
}, },
registerCiSchema() { registerCiSchema() {
if (this.glFeatures.schemaLinting) {
const editorInstance = this.$refs.editor.getEditor(); const editorInstance = this.$refs.editor.getEditor();
editorInstance.use(new CiSchemaExtension({ instance: editorInstance })); editorInstance.use(new CiSchemaExtension({ instance: editorInstance }));
...@@ -33,6 +36,7 @@ export default { ...@@ -33,6 +36,7 @@ export default {
projectNamespace: this.projectNamespace, projectNamespace: this.projectNamespace,
ref: this.commitSha, ref: this.commitSha,
}); });
}
}, },
}, },
readyEvent: EDITOR_READY_EVENT, readyEvent: EDITOR_READY_EVENT,
......
...@@ -6,6 +6,7 @@ class Projects::Ci::PipelineEditorController < Projects::ApplicationController ...@@ -6,6 +6,7 @@ class Projects::Ci::PipelineEditorController < Projects::ApplicationController
push_frontend_feature_flag(:pipeline_editor_empty_state_action, @project, default_enabled: :yaml) push_frontend_feature_flag(:pipeline_editor_empty_state_action, @project, default_enabled: :yaml)
push_frontend_feature_flag(:pipeline_editor_branch_switcher, @project, default_enabled: :yaml) push_frontend_feature_flag(:pipeline_editor_branch_switcher, @project, default_enabled: :yaml)
push_frontend_feature_flag(:pipeline_editor_drawer, @project, default_enabled: :yaml) push_frontend_feature_flag(:pipeline_editor_drawer, @project, default_enabled: :yaml)
push_frontend_feature_flag(:schema_linting, @project, default_enabled: :yaml)
end end
feature_category :pipeline_authoring feature_category :pipeline_authoring
......
...@@ -32,12 +32,13 @@ describe('Pipeline Editor | Text editor component', () => { ...@@ -32,12 +32,13 @@ describe('Pipeline Editor | Text editor component', () => {
}, },
}; };
const createComponent = (opts = {}, mountFn = shallowMount) => { const createComponent = (glFeatures = {}, mountFn = shallowMount) => {
wrapper = mountFn(TextEditor, { wrapper = mountFn(TextEditor, {
provide: { provide: {
projectPath: mockProjectPath, projectPath: mockProjectPath,
projectNamespace: mockProjectNamespace, projectNamespace: mockProjectNamespace,
ciConfigPath: mockCiConfigPath, ciConfigPath: mockCiConfigPath,
glFeatures,
}, },
attrs: { attrs: {
value: mockCiYml, value: mockCiYml,
...@@ -54,7 +55,6 @@ describe('Pipeline Editor | Text editor component', () => { ...@@ -54,7 +55,6 @@ describe('Pipeline Editor | Text editor component', () => {
stubs: { stubs: {
EditorLite: MockEditorLite, EditorLite: MockEditorLite,
}, },
...opts,
}); });
}; };
...@@ -66,7 +66,6 @@ describe('Pipeline Editor | Text editor component', () => { ...@@ -66,7 +66,6 @@ describe('Pipeline Editor | Text editor component', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
mockUse.mockClear(); mockUse.mockClear();
mockRegisterCiSchema.mockClear(); mockRegisterCiSchema.mockClear();
...@@ -100,19 +99,18 @@ describe('Pipeline Editor | Text editor component', () => { ...@@ -100,19 +99,18 @@ describe('Pipeline Editor | Text editor component', () => {
}); });
}); });
describe('register CI schema', () => { describe('CI schema', () => {
beforeEach(async () => { describe('when `schema_linting` feature flag is on', () => {
createComponent(); beforeEach(() => {
createComponent({ schemaLinting: true });
// Since the editor will have already mounted, the event will have fired. // Since the editor will have already mounted, the event will have fired.
// To ensure we properly test this, we clear the mock and re-remit the event. // To ensure we properly test this, we clear the mock and re-remit the event.
mockRegisterCiSchema.mockClear(); mockRegisterCiSchema.mockClear();
mockUse.mockClear(); mockUse.mockClear();
findEditor().vm.$emit(EDITOR_READY_EVENT); findEditor().vm.$emit(EDITOR_READY_EVENT);
}); });
it('configures editor with syntax highlight', async () => { it('configures editor with syntax highlight', () => {
expect(mockUse).toHaveBeenCalledTimes(1); expect(mockUse).toHaveBeenCalledTimes(1);
expect(mockRegisterCiSchema).toHaveBeenCalledTimes(1); expect(mockRegisterCiSchema).toHaveBeenCalledTimes(1);
expect(mockRegisterCiSchema).toHaveBeenCalledWith({ expect(mockRegisterCiSchema).toHaveBeenCalledWith({
...@@ -122,4 +120,17 @@ describe('Pipeline Editor | Text editor component', () => { ...@@ -122,4 +120,17 @@ describe('Pipeline Editor | Text editor component', () => {
}); });
}); });
}); });
describe('when `schema_linting` feature flag is off', () => {
beforeEach(() => {
createComponent();
findEditor().vm.$emit(EDITOR_READY_EVENT);
});
it('does not call the register CI schema function', () => {
expect(mockUse).not.toHaveBeenCalled();
expect(mockRegisterCiSchema).not.toHaveBeenCalled();
});
});
});
}); });
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