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
c6f3da58
Commit
c6f3da58
authored
Sep 12, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up test
parent
c24e7227
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
35 deletions
+9
-35
spec/messages.js
spec/messages.js
+8
-34
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+1
-1
No files found.
spec/messages.js
View file @
c6f3da58
...
...
@@ -1658,14 +1658,12 @@
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitForRoster
(
_converse
,
'
current
'
,
1
);
test_utils
.
openControlBox
();
// 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"
...
...
@@ -1682,14 +1680,7 @@
await
_converse
.
api
.
chats
.
open
(
sender_jid
)
let
msg_text
=
'
This message will not be sent, due to an error
'
;
const
view
=
_converse
.
api
.
chatviews
.
get
(
sender_jid
);
view
.
model
.
messages
.
create
({
'
msgid
'
:
'
82bc02ce-9651-4336-baf0-fa04762ed8d2
'
,
'
fullname
'
:
fullname
,
'
sender
'
:
'
me
'
,
'
time
'
:
(
new
Date
()).
toISOString
(),
'
message
'
:
msg_text
});
view
.
model
.
sendMessage
(
msg_text
);
const
message
=
await
view
.
model
.
sendMessage
(
msg_text
);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
const
chat_content
=
view
.
el
.
querySelector
(
'
.chat-content
'
);
let
msg_txt
=
sizzle
(
'
.chat-msg:last .chat-msg__text
'
,
chat_content
).
pop
().
textContent
;
...
...
@@ -1699,15 +1690,8 @@
// not be received, to test that errors appear
// after the relevant message.
msg_text
=
'
This message will be sent, and also receive an error
'
;
view
.
model
.
messages
.
create
({
'
msgid
'
:
'
6fcdeee3-000f-4ce8-a17e-9ce28f0ae104
'
,
'
fullname
'
:
fullname
,
'
sender
'
:
'
me
'
,
'
time
'
:
(
new
Date
()).
toISOString
(),
'
message
'
:
msg_text
});
view
.
model
.
sendMessage
(
msg_text
);
await
u
.
waitUntil
(()
=>
sizzle
(
'
.chat-msg .chat-msg__text
'
,
chat_content
).
length
===
4
,
1000
);
const
second_message
=
await
view
.
model
.
sendMessage
(
msg_text
);
await
u
.
waitUntil
(()
=>
sizzle
(
'
.chat-msg .chat-msg__text
'
,
chat_content
).
length
===
2
,
1000
);
msg_txt
=
sizzle
(
'
.chat-msg:last .chat-msg__text
'
,
chat_content
).
pop
().
textContent
;
expect
(
msg_txt
).
toEqual
(
msg_text
);
...
...
@@ -1725,7 +1709,7 @@
let
stanza
=
$msg
({
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
error
'
,
'
id
'
:
'
82bc02ce-9651-4336-baf0-fa04762ed8d2
'
,
'
id
'
:
message
.
get
(
'
msgid
'
)
,
'
from
'
:
sender_jid
})
.
c
(
'
error
'
,
{
'
type
'
:
'
cancel
'
})
...
...
@@ -1738,7 +1722,7 @@
stanza
=
$msg
({
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
error
'
,
'
id
'
:
'
6fcdeee3-000f-4ce8-a17e-9ce28f0ae104
'
,
'
id
'
:
second_message
.
get
(
'
id
'
)
,
'
from
'
:
sender_jid
})
.
c
(
'
error
'
,
{
'
type
'
:
'
cancel
'
})
...
...
@@ -1763,18 +1747,8 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
expect
(
chat_content
.
querySelectorAll
(
'
.chat-error
'
).
length
).
toEqual
(
2
);
// 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 also receive an error
'
;
view
.
model
.
messages
.
create
({
'
msgid
'
:
'
another-id
'
,
'
fullname
'
:
fullname
,
'
sender
'
:
'
me
'
,
'
time
'
:
(
new
Date
()).
toISOString
(),
'
message
'
:
msg_text
});
view
.
model
.
sendMessage
(
msg_text
);
const
third_message
=
await
view
.
model
.
sendMessage
(
msg_text
);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
msg_txt
=
sizzle
(
'
.chat-msg:last .chat-msg__text
'
,
chat_content
).
pop
().
textContent
;
expect
(
msg_txt
).
toEqual
(
msg_text
);
...
...
@@ -1783,11 +1757,11 @@
stanza
=
$msg
({
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
error
'
,
'
id
'
:
'
another-id
'
,
'
id
'
:
third_message
.
get
(
'
id
'
)
,
'
from
'
:
sender_jid
})
.
c
(
'
error
'
,
{
'
type
'
:
'
cancel
'
})
.
c
(
'
remote-server-not-foun
d
'
,
{
'
xmlns
'
:
"
urn:ietf:params:xml:ns:xmpp-stanzas
"
}).
up
()
.
c
(
'
not-allowe
d
'
,
{
'
xmlns
'
:
"
urn:ietf:params:xml:ns:xmpp-stanzas
"
}).
up
()
.
c
(
'
text
'
,
{
'
xmlns
'
:
"
urn:ietf:params:xml:ns:xmpp-stanzas
"
})
.
t
(
'
Something else went wrong as well
'
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
...
...
src/headless/converse-chatboxes.js
View file @
c6f3da58
...
...
@@ -558,7 +558,7 @@ converse.plugins.add('converse-chatboxes', {
}
const
older_versions
=
message
.
get
(
'
older_versions
'
)
||
{};
if
((
attrs
.
time
<
message
.
get
(
'
time
'
))
&&
message
.
get
(
'
edited
'
))
{
// This is an older message which has been corrected afterwards
// This is an older message which has been corrected afterwards
older_versions
[
attrs
.
time
]
=
attrs
[
'
message
'
];
message
.
save
({
'
older_versions
'
:
older_versions
});
}
else
{
...
...
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