Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
60ea5a44
Commit
60ea5a44
authored
Jul 06, 2021
by
Enrique Alcantara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display content editor errors
parent
0d4e9458
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
11 deletions
+57
-11
app/assets/javascripts/content_editor/components/content_editor.vue
.../javascripts/content_editor/components/content_editor.vue
+24
-7
spec/frontend/content_editor/components/content_editor_spec.js
...frontend/content_editor/components/content_editor_spec.js
+33
-4
No files found.
app/assets/javascripts/content_editor/components/content_editor.vue
View file @
60ea5a44
<
script
>
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
EditorContent
as
TiptapEditorContent
}
from
'
@tiptap/vue-2
'
;
import
{
ContentEditor
}
from
'
../services/content_editor
'
;
import
TopToolbar
from
'
./top_toolbar.vue
'
;
export
default
{
components
:
{
GlAlert
,
TiptapEditorContent
,
TopToolbar
,
},
...
...
@@ -14,15 +16,30 @@ export default {
required
:
true
,
},
},
data
()
{
return
{
error
:
''
,
};
},
mounted
()
{
this
.
contentEditor
.
tiptapEditor
.
on
(
'
error
'
,
(
error
)
=>
{
this
.
error
=
error
;
});
},
};
</
script
>
<
template
>
<div
data-testid=
"content-editor"
class=
"md-area"
:class=
"
{ 'is-focused': contentEditor.tiptapEditor.isFocused }"
>
<top-toolbar
class=
"gl-mb-4"
:content-editor=
"contentEditor"
/>
<tiptap-editor-content
class=
"md"
:editor=
"contentEditor.tiptapEditor"
/>
<div>
<gl-alert
v-if=
"error"
class=
"gl-mb-6"
variant=
"danger"
@
dismiss=
"error = ''"
>
{{
error
}}
</gl-alert>
<div
data-testid=
"content-editor"
class=
"md-area"
:class=
"
{ 'is-focused': contentEditor.tiptapEditor.isFocused }"
>
<top-toolbar
ref=
"toolbar"
class=
"gl-mb-4"
:content-editor=
"contentEditor"
/>
<tiptap-editor-content
class=
"md"
:editor=
"contentEditor.tiptapEditor"
/>
</div>
</div>
</
template
>
spec/frontend/content_editor/components/content_editor_spec.js
View file @
60ea5a44
import
{
GlAlert
}
from
'
@gitlab/ui
'
;
import
{
EditorContent
}
from
'
@tiptap/vue-2
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
nextTick
}
from
'
vue
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
ContentEditor
from
'
~/content_editor/components/content_editor.vue
'
;
import
TopToolbar
from
'
~/content_editor/components/top_toolbar.vue
'
;
import
{
createContentEditor
}
from
'
~/content_editor/services/create_content_editor
'
;
...
...
@@ -8,8 +10,11 @@ describe('ContentEditor', () => {
let
wrapper
;
let
editor
;
const
findEditorElement
=
()
=>
wrapper
.
findByTestId
(
'
content-editor
'
);
const
findErrorAlert
=
()
=>
wrapper
.
findComponent
(
GlAlert
);
const
createWrapper
=
async
(
contentEditor
)
=>
{
wrapper
=
shallowMount
(
ContentEditor
,
{
wrapper
=
shallowMount
Extended
(
ContentEditor
,
{
propsData
:
{
contentEditor
,
},
...
...
@@ -49,7 +54,7 @@ describe('ContentEditor', () => {
editor
.
tiptapEditor
.
isFocused
=
isFocused
;
createWrapper
(
editor
);
expect
(
wrapper
.
classes
()).
toStrictEqual
(
classes
);
expect
(
findEditorElement
()
.
classes
()).
toStrictEqual
(
classes
);
},
);
...
...
@@ -57,6 +62,30 @@ describe('ContentEditor', () => {
editor
.
tiptapEditor
.
isFocused
=
true
;
createWrapper
(
editor
);
expect
(
wrapper
.
classes
()).
toContain
(
'
is-focused
'
);
expect
(
findEditorElement
().
classes
()).
toContain
(
'
is-focused
'
);
});
describe
(
'
displaying error
'
,
()
=>
{
const
error
=
'
Content Editor error
'
;
beforeEach
(
async
()
=>
{
createWrapper
(
editor
);
editor
.
tiptapEditor
.
emit
(
'
error
'
,
error
);
await
nextTick
();
});
it
(
'
displays error notifications from the tiptap editor
'
,
()
=>
{
expect
(
findErrorAlert
().
text
()).
toBe
(
error
);
});
it
(
'
allows dismissing an error alert
'
,
async
()
=>
{
findErrorAlert
().
vm
.
$emit
(
'
dismiss
'
);
await
nextTick
();
expect
(
findErrorAlert
().
exists
()).
toBe
(
false
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment