Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Commits on Source (2)
(fix): show backend errors when saving a blog
· a7ba96f3
Marcelo Rivera
authored
Aug 06, 2019
a7ba96f3
(fix): e2e test
· 146c77a0
Marcelo Rivera
authored
Aug 06, 2019
146c77a0
Hide whitespace changes
Inline
Side-by-side
cypress/integration/blogs.spec.js
View file @
146c77a0
...
...
@@ -6,7 +6,7 @@ context('Blogs', () => {
.
should
(
'
eq
'
,
`/newsfeed/subscriptions`
);
})
it
(
'
should not be able to create a new blog if no title or banner are specified
'
,
()
=>
{
it
(
'
should not be able to create a new blog if no title or banner are specified
'
,
()
=>
{
cy
.
visit
(
'
/blog/edit/new
'
);
cy
.
get
(
'
.m-button--submit
'
).
click
();
...
...
@@ -46,17 +46,11 @@ context('Blogs', () => {
cy
.
wait
(
1000
);
cy
.
server
();
cy
.
route
(
"
POST
"
,
"
**/api/v1/blog/new
"
).
as
(
"
newBlog
"
);
cy
.
route
(
"
POST
"
,
"
**
!
/api/v1/blog/new
"
).
as
(
"
newBlog
"
);
cy
.
get
(
'
.m-button--submit
'
).
click
({
force
:
true
});
// TODO: Investigate why disabled flag is being detected
cy
.
wait
(
'
@newBlog
'
,
{
requestTimeout
:
2000
}).
then
((
xhr
)
=>
{
expect
(
xhr
.
status
).
to
.
equal
(
200
);
expect
(
xhr
.
response
.
body
).
to
.
deep
.
equal
({
status
:
'
error
'
,
message
:
'
Please ensure your channel has an avatar before creating a blog
'
});
});
cy
.
get
(
'
h1.m-blog--edit--error
'
).
contains
(
'
Error: Please ensure your channel has an avatar before creating a blog
'
);
});
it
(
'
should be able to create a new blog
'
,
()
=>
{
...
...
src/app/modules/blogs/edit/edit.ts
View file @
146c77a0
...
...
@@ -185,7 +185,7 @@ export class BlogEdit {
this
.
blog
=
response
.
blog
;
this
.
guid
=
response
.
blog
.
guid
;
this
.
title
.
setTitle
(
this
.
blog
.
title
);
if
(
this
.
blog
.
thumbnail_src
)
this
.
existingBanner
=
true
;
//this.hashtagsSelector.setTags(this.blog.tags);
...
...
@@ -235,6 +235,8 @@ export class BlogEdit {
if
(
!
this
.
validate
())
return
;
this
.
error
=
''
;
this
.
inlineEditor
.
prepareForSave
().
then
(()
=>
{
const
blog
=
Object
.
assign
({},
this
.
blog
);
...
...
@@ -248,9 +250,14 @@ export class BlogEdit {
this
.
check_for_banner
().
then
(()
=>
{
this
.
upload
.
post
(
'
api/v1/blog/
'
+
this
.
guid
,
[
this
.
banner
],
blog
)
.
then
((
response
:
any
)
=>
{
this
.
router
.
navigate
(
response
.
route
?
[
'
/
'
+
response
.
route
]:
[
'
/blog/view
'
,
response
.
guid
]);
this
.
canSave
=
true
;
this
.
inProgress
=
false
;
this
.
canSave
=
true
;
if
(
response
.
status
!==
'
success
'
)
{
this
.
error
=
response
.
message
;
return
;
}
this
.
router
.
navigate
(
response
.
route
?
[
'
/
'
+
response
.
route
]:
[
'
/blog/view
'
,
response
.
guid
]);
})
.
catch
((
e
)
=>
{
this
.
canSave
=
true
;
...
...
@@ -275,7 +282,7 @@ export class BlogEdit {
if
(
!
this
.
banner
)
this
.
banner_prompt
=
true
;
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
banner
)
return
resolve
(
true
);
...
...