Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
3df342dd2f
commit
fb41d98732
3 changed files with 42 additions and 26 deletions
|
@ -2,12 +2,14 @@
|
|||
import { EDITOR_READY_EVENT } from '~/editor/constants';
|
||||
import { CiSchemaExtension } from '~/editor/extensions/editor_ci_schema_ext';
|
||||
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';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
EditorLite,
|
||||
},
|
||||
mixins: [glFeatureFlagMixin()],
|
||||
inject: ['ciConfigPath', 'projectPath', 'projectNamespace'],
|
||||
inheritAttrs: false,
|
||||
data() {
|
||||
|
@ -25,14 +27,16 @@ export default {
|
|||
this.$emit('updateCiConfig', content);
|
||||
},
|
||||
registerCiSchema() {
|
||||
const editorInstance = this.$refs.editor.getEditor();
|
||||
if (this.glFeatures.schemaLinting) {
|
||||
const editorInstance = this.$refs.editor.getEditor();
|
||||
|
||||
editorInstance.use(new CiSchemaExtension({ instance: editorInstance }));
|
||||
editorInstance.registerCiSchema({
|
||||
projectPath: this.projectPath,
|
||||
projectNamespace: this.projectNamespace,
|
||||
ref: this.commitSha,
|
||||
});
|
||||
editorInstance.use(new CiSchemaExtension({ instance: editorInstance }));
|
||||
editorInstance.registerCiSchema({
|
||||
projectPath: this.projectPath,
|
||||
projectNamespace: this.projectNamespace,
|
||||
ref: this.commitSha,
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
readyEvent: EDITOR_READY_EVENT,
|
||||
|
|
|
@ -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_branch_switcher, @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
|
||||
|
||||
feature_category :pipeline_authoring
|
||||
|
|
|
@ -32,12 +32,13 @@ describe('Pipeline Editor | Text editor component', () => {
|
|||
},
|
||||
};
|
||||
|
||||
const createComponent = (opts = {}, mountFn = shallowMount) => {
|
||||
const createComponent = (glFeatures = {}, mountFn = shallowMount) => {
|
||||
wrapper = mountFn(TextEditor, {
|
||||
provide: {
|
||||
projectPath: mockProjectPath,
|
||||
projectNamespace: mockProjectNamespace,
|
||||
ciConfigPath: mockCiConfigPath,
|
||||
glFeatures,
|
||||
},
|
||||
attrs: {
|
||||
value: mockCiYml,
|
||||
|
@ -54,7 +55,6 @@ describe('Pipeline Editor | Text editor component', () => {
|
|||
stubs: {
|
||||
EditorLite: MockEditorLite,
|
||||
},
|
||||
...opts,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -66,7 +66,6 @@ describe('Pipeline Editor | Text editor component', () => {
|
|||
|
||||
afterEach(() => {
|
||||
wrapper.destroy();
|
||||
wrapper = null;
|
||||
|
||||
mockUse.mockClear();
|
||||
mockRegisterCiSchema.mockClear();
|
||||
|
@ -100,25 +99,37 @@ describe('Pipeline Editor | Text editor component', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('register CI schema', () => {
|
||||
beforeEach(async () => {
|
||||
createComponent();
|
||||
describe('CI schema', () => {
|
||||
describe('when `schema_linting` feature flag is on', () => {
|
||||
beforeEach(() => {
|
||||
createComponent({ schemaLinting: true });
|
||||
// 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.
|
||||
mockRegisterCiSchema.mockClear();
|
||||
mockUse.mockClear();
|
||||
findEditor().vm.$emit(EDITOR_READY_EVENT);
|
||||
});
|
||||
|
||||
// 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.
|
||||
mockRegisterCiSchema.mockClear();
|
||||
mockUse.mockClear();
|
||||
|
||||
findEditor().vm.$emit(EDITOR_READY_EVENT);
|
||||
it('configures editor with syntax highlight', () => {
|
||||
expect(mockUse).toHaveBeenCalledTimes(1);
|
||||
expect(mockRegisterCiSchema).toHaveBeenCalledTimes(1);
|
||||
expect(mockRegisterCiSchema).toHaveBeenCalledWith({
|
||||
projectNamespace: mockProjectNamespace,
|
||||
projectPath: mockProjectPath,
|
||||
ref: mockCommitSha,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('configures editor with syntax highlight', async () => {
|
||||
expect(mockUse).toHaveBeenCalledTimes(1);
|
||||
expect(mockRegisterCiSchema).toHaveBeenCalledTimes(1);
|
||||
expect(mockRegisterCiSchema).toHaveBeenCalledWith({
|
||||
projectNamespace: mockProjectNamespace,
|
||||
projectPath: mockProjectPath,
|
||||
ref: mockCommitSha,
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue