Commit e8e492d0 authored by Himanshu Kapoor's avatar Himanshu Kapoor Committed by Himanshu Kapoor

Do not trim wiki content by default

Changelog: fixed
parent 59d04e93
......@@ -119,7 +119,7 @@ export default {
return {
title: this.pageInfo.title?.trim() || '',
format: this.pageInfo.format || 'markdown',
content: this.pageInfo.content?.trim() || '',
content: this.pageInfo.content || '',
isContentEditorLoading: true,
useContentEditor: false,
commitMessage: '',
......@@ -131,7 +131,7 @@ export default {
computed: {
noContent() {
if (this.isContentEditorActive) return this.contentEditor?.empty;
return !this.content;
return !this.content.trim();
},
csrfToken() {
return csrf.token;
......@@ -326,7 +326,7 @@ export default {
<div class="col-sm-10">
<input
id="wiki_title"
v-model.trim="title"
v-model="title"
name="wiki[title]"
type="text"
class="form-control"
......@@ -418,7 +418,7 @@ export default {
<textarea
id="wiki_content"
ref="textarea"
v-model.trim="content"
v-model="content"
name="wiki[content]"
class="note-textarea js-gfm-input js-autosize markdown-area"
dir="auto"
......
......@@ -63,7 +63,7 @@ describe('WikiForm', () => {
persisted: true,
title: 'My page',
content: 'My page content',
content: ' My page content ',
format: 'markdown',
path: '/project/path/-/wikis/home',
};
......@@ -129,6 +129,12 @@ describe('WikiForm', () => {
expect(findMessage().element.value).toBe('Update My page');
});
it('does not trim page content by default', () => {
createWrapper(true);
expect(findContent().element.value).toBe(' My page content ');
});
it.each`
value | text
${'markdown'} | ${'[Link Title](page-slug)'}
......@@ -183,10 +189,10 @@ describe('WikiForm', () => {
describe('when wiki content is updated', () => {
beforeEach(() => {
createWrapper();
createWrapper(true);
const input = findContent();
input.setValue('Lorem ipsum dolar sit!');
input.setValue(' Lorem ipsum dolar sit! ');
input.element.dispatchEvent(new Event('input'));
return wrapper.vm.$nextTick();
......@@ -213,6 +219,10 @@ describe('WikiForm', () => {
it('does not trigger tracking event', async () => {
expect(trackingSpy).not.toHaveBeenCalled();
});
it('does not trim page content', () => {
expect(findContent().element.value).toBe(' Lorem ipsum dolar sit! ');
});
});
});
......@@ -434,7 +444,7 @@ describe('WikiForm', () => {
it('updates content from content editor on form submit', async () => {
// old value
expect(findContent().element.value).toBe('My page content');
expect(findContent().element.value).toBe(' My page content ');
// wait for content editor to load
await waitForPromises();
......@@ -484,7 +494,7 @@ describe('WikiForm', () => {
});
it('the old editor retains its old value and does not use the content from the content editor', () => {
expect(findContent().element.value).toBe('My page content');
expect(findContent().element.value).toBe(' My page content ');
});
});
});
......
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