Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
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
0
Merge Requests
0
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
converse.js
Commits
be122af3
Commit
be122af3
authored
Jun 23, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for rendering of error messages.
parent
e06a34a9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
100 additions
and
2 deletions
+100
-2
docs/CHANGES.md
docs/CHANGES.md
+2
-1
spec/chatbox.js
spec/chatbox.js
+97
-0
src/converse-chatview.js
src/converse-chatview.js
+1
-1
No files found.
docs/CHANGES.md
View file @
be122af3
...
@@ -6,7 +6,8 @@
...
@@ -6,7 +6,8 @@
-
Made requesting contacts more visible, by placing them at the top of the roster. [jcbrand]
-
Made requesting contacts more visible, by placing them at the top of the roster. [jcbrand]
-
`insertIntoPage`
method of
`ChatBoxView`
has been renamed to
`insertIntoDOM`
,
-
`insertIntoPage`
method of
`ChatBoxView`
has been renamed to
`insertIntoDOM`
,
to make it the same as the method of
`ChatRoomView`
. [jcbrand]
to make it the same as the method of
`ChatRoomView`
. [jcbrand]
-
Render error messages received from the server (for undelivered chat
messages). [jcbrand]
## 1.0.3 (2016-06-20)
## 1.0.3 (2016-06-20)
...
...
spec/chatbox.js
View file @
be122af3
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
"
test_utils
"
"
test_utils
"
],
factory
);
],
factory
);
}
(
this
,
function
(
$
,
_
,
utils
,
mock
,
test_utils
)
{
}
(
this
,
function
(
$
,
_
,
utils
,
mock
,
test_utils
)
{
"
use strict
"
;
var
$msg
=
converse_api
.
env
.
$msg
;
var
$msg
=
converse_api
.
env
.
$msg
;
var
Strophe
=
converse_api
.
env
.
Strophe
;
var
Strophe
=
converse_api
.
env
.
Strophe
;
var
moment
=
converse_api
.
env
.
moment
;
var
moment
=
converse_api
.
env
.
moment
;
...
@@ -459,6 +460,102 @@
...
@@ -459,6 +460,102 @@
}.
bind
(
converse
));
}.
bind
(
converse
));
}.
bind
(
converse
));
}.
bind
(
converse
));
describe
(
"
and for which then an error message is received from the server
"
,
function
()
{
it
(
"
will have the error message displayed after itself
"
,
function
()
{
// TODO: what could still be done for error
// messages... if the <error> element has type
// "cancel", then we know the messages wasn't sent,
// and can give the user a nicer indication of
// that.
/* <message from="scotty@enterprise.com/converse.js-84843526"
* to="kirk@enterprise.com.com"
* type="chat"
* id="82bc02ce-9651-4336-baf0-fa04762ed8d2"
* xmlns="jabber:client">
* <body>yo</body>
* <active xmlns="http://jabber.org/protocol/chatstates"/>
* </message>
*/
var
sender_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
fullname
=
converse
.
xmppstatus
.
get
(
'
fullname
'
);
fullname
=
_
.
isEmpty
(
fullname
)?
converse
.
bare_jid
:
fullname
;
converse_api
.
chats
.
open
(
sender_jid
);
var
msg_text
=
'
This message will not be sent, due to an error
'
;
var
view
=
converse
.
chatboxviews
.
get
(
sender_jid
);
var
message
=
view
.
model
.
messages
.
create
({
'
msgid
'
:
'
82bc02ce-9651-4336-baf0-fa04762ed8d2
'
,
'
fullname
'
:
fullname
,
'
sender
'
:
'
me
'
,
'
time
'
:
moment
().
format
(),
'
message
'
:
msg_text
});
view
.
sendMessage
(
message
);
var
$chat_content
=
view
.
$el
.
find
(
'
.chat-content
'
);
var
msg_txt
=
$chat_content
.
find
(
'
.chat-message:last
'
).
find
(
'
.chat-msg-content
'
).
text
();
expect
(
msg_txt
).
toEqual
(
msg_text
);
// We send another message, for which an error will
// not be received, to test that errors appear
// after the relevant message.
msg_text
=
'
This message will be sent, and not receive an error
'
;
message
=
view
.
model
.
messages
.
create
({
'
msgid
'
:
'
6fcdeee3-000f-4ce8-a17e-9ce28f0ae104
'
,
'
fullname
'
:
fullname
,
'
sender
'
:
'
me
'
,
'
time
'
:
moment
().
format
(),
'
message
'
:
msg_text
});
view
.
sendMessage
(
message
);
msg_txt
=
$chat_content
.
find
(
'
.chat-message:last
'
).
find
(
'
.chat-msg-content
'
).
text
();
expect
(
msg_txt
).
toEqual
(
msg_text
);
/* <message xmlns="jabber:client"
* to="scotty@enterprise.com/converse.js-84843526"
* type="error"
* id="82bc02ce-9651-4336-baf0-fa04762ed8d2"
* from="kirk@enterprise.com.com">
* <error type="cancel">
* <remote-server-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
* <text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">Server-to-server connection failed: Connecting failed: connection timeout</text>
* </error>
* </message>
*/
var
error_txt
=
'
Server-to-server connection failed: Connecting failed: connection timeout
'
;
var
stanza
=
$msg
({
'
to
'
:
converse
.
connection
.
jid
,
'
type
'
:
'
error
'
,
'
id
'
:
'
82bc02ce-9651-4336-baf0-fa04762ed8d2
'
,
'
from
'
:
sender_jid
})
.
c
(
'
error
'
,
{
'
type
'
:
'
cancel
'
})
.
c
(
'
remote-server-not-found
'
,
{
'
xmlns
'
:
"
urn:ietf:params:xml:ns:xmpp-stanzas
"
}).
up
()
.
c
(
'
text
'
,
{
'
xmlns
'
:
"
urn:ietf:params:xml:ns:xmpp-stanzas
"
})
.
t
(
'
Server-to-server connection failed: Connecting failed: connection timeout
'
);
converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
$chat_content
.
find
(
'
.chat-error
'
).
text
()).
toEqual
(
error_txt
);
/* Incoming error messages that are not tied to a
* certain show message (via the msgid attribute),
* are not shown at all. The reason for this is
* that we may get error messages for chat state
* notifications as well.
*/
stanza
=
$msg
({
'
to
'
:
converse
.
connection
.
jid
,
'
type
'
:
'
error
'
,
'
id
'
:
'
some-other-unused-id
'
,
'
from
'
:
sender_jid
})
.
c
(
'
error
'
,
{
'
type
'
:
'
cancel
'
})
.
c
(
'
remote-server-not-found
'
,
{
'
xmlns
'
:
"
urn:ietf:params:xml:ns:xmpp-stanzas
"
}).
up
()
.
c
(
'
text
'
,
{
'
xmlns
'
:
"
urn:ietf:params:xml:ns:xmpp-stanzas
"
})
.
t
(
'
Server-to-server connection failed: Connecting failed: connection timeout
'
);
converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
$chat_content
.
find
(
'
.chat-error
'
).
length
).
toEqual
(
1
);
});
});
it
(
"
will cause the chat area to be scrolled down only if it was at the bottom already
"
,
function
()
{
it
(
"
will cause the chat area to be scrolled down only if it was at the bottom already
"
,
function
()
{
var
message
=
'
This message is received while the chat area is scrolled up
'
;
var
message
=
'
This message is received while the chat area is scrolled up
'
;
var
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
src/converse-chatview.js
View file @
be122af3
...
@@ -369,7 +369,7 @@
...
@@ -369,7 +369,7 @@
handleErrorMessage
:
function
(
message
)
{
handleErrorMessage
:
function
(
message
)
{
var
$message
=
$
(
'
[data-msgid=
'
+
message
.
get
(
'
msgid
'
)
+
'
]
'
);
var
$message
=
$
(
'
[data-msgid=
'
+
message
.
get
(
'
msgid
'
)
+
'
]
'
);
if
(
$message
.
length
)
{
if
(
$message
.
length
)
{
$message
.
after
(
$
(
'
<div class="chat-error"></div>
'
).
text
(
message
.
get
(
'
message
'
)));
$message
.
after
(
$
(
'
<div class="chat-
info chat-
error"></div>
'
).
text
(
message
.
get
(
'
message
'
)));
this
.
scrollDown
();
this
.
scrollDown
();
}
}
},
},
...
...
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