Commit 68a1bbf8 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'svedova-fix-get-action' into 'master'

Fix getAction is undefined bug

See merge request gitlab-org/gitlab!68583
parents 215c7bcc 66a8019f
......@@ -3,6 +3,7 @@ import { debounce } from 'lodash';
import { mapState, mapGetters, mapActions } from 'vuex';
import {
EDITOR_TYPE_DIFF,
EDITOR_TYPE_CODE,
EDITOR_CODE_INSTANCE_FN,
EDITOR_DIFF_INSTANCE_FN,
} from '~/editor/constants';
......@@ -311,7 +312,10 @@ export default {
}),
);
if (this.fileType === MARKDOWN_FILE_TYPE) {
if (
this.fileType === MARKDOWN_FILE_TYPE &&
this.editor?.getEditorType() === EDITOR_TYPE_CODE
) {
import('~/editor/extensions/source_editor_markdown_ext')
.then(({ EditorMarkdownExtension: MarkdownExtension } = {}) => {
this.editor.use(
......
......@@ -166,11 +166,6 @@ describe('RepoEditor', () => {
expect(tabs).toHaveLength(1);
expect(tabs.at(0).text()).toBe('Edit');
});
it('does not get markdown extension by default', async () => {
await createComponent();
expect(vm.editor.projectPath).toBeUndefined();
});
});
describe('when file is markdown', () => {
......@@ -218,11 +213,6 @@ describe('RepoEditor', () => {
});
expect(findTabs()).toHaveLength(0);
});
it('uses the markdown extension and sets it up correctly', async () => {
await createComponent({ activeFile });
expect(vm.editor.projectPath).toBe(vm.currentProjectId);
});
});
describe('when file is binary and not raw', () => {
......@@ -271,6 +261,31 @@ describe('RepoEditor', () => {
expect(vm.editor[fn]).toBe(EditorWebIdeExtension.prototype[fn]);
});
});
it.each`
prefix | activeFile | viewer | shouldHaveMarkdownExtension
${'Should not'} | ${createActiveFile()} | ${viewerTypes.edit} | ${false}
${'Should'} | ${dummyFile.markdown} | ${viewerTypes.edit} | ${true}
${'Should not'} | ${dummyFile.empty} | ${viewerTypes.edit} | ${false}
${'Should not'} | ${createActiveFile()} | ${viewerTypes.diff} | ${false}
${'Should not'} | ${dummyFile.markdown} | ${viewerTypes.diff} | ${false}
${'Should not'} | ${dummyFile.empty} | ${viewerTypes.diff} | ${false}
${'Should not'} | ${createActiveFile()} | ${viewerTypes.mr} | ${false}
${'Should not'} | ${dummyFile.markdown} | ${viewerTypes.mr} | ${false}
${'Should not'} | ${dummyFile.empty} | ${viewerTypes.mr} | ${false}
`(
'$prefix install markdown extension for $activeFile.name in $viewer viewer',
async ({ activeFile, viewer, shouldHaveMarkdownExtension } = {}) => {
await createComponent({ state: { viewer }, activeFile });
if (shouldHaveMarkdownExtension) {
expect(vm.editor.projectPath).toBe(vm.currentProjectId);
expect(vm.editor.togglePreview).toBeDefined();
} else {
expect(vm.editor.projectPath).toBeUndefined();
expect(vm.editor.togglePreview).toBeUndefined();
}
},
);
});
describe('setupEditor', () => {
......
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