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
2857293a
Commit
2857293a
authored
Dec 06, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix failing tests by waiting and slightly improve code
parent
5f009875
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
27 deletions
+21
-27
dist/converse.js
dist/converse.js
+1
-9
spec/chatbox.js
spec/chatbox.js
+15
-9
spec/controlbox.js
spec/controlbox.js
+1
-1
spec/messages.js
spec/messages.js
+3
-4
src/converse-minimize.js
src/converse-minimize.js
+1
-4
No files found.
dist/converse.js
View file @
2857293a
...
...
@@ -53105,16 +53105,8 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_1__["default"].plugins
},
updateUnreadMessagesCounter() {
const ls = this.model.pluck('num_unread');
let count = 0,
i;
for (i = 0; i < ls.length; i++) {
count += ls[i];
}
this.toggleview.model.save({
'num_unread':
count
'num_unread':
_.sum(this.model.pluck('num_unread'))
});
this.render();
}
spec/chatbox.js
View file @
2857293a
...
...
@@ -1056,18 +1056,19 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
,
1
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
test_utils
.
openControlBox
();
spyOn
(
_converse
,
'
emit
'
);
expect
(
_converse
.
msg_counter
).
toBe
(
0
);
spyOn
(
_converse
,
'
incrementMsgCounter
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
clearMsgCounter
'
).
and
.
callThrough
();
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
view
=
await
test_utils
.
openChatBoxFor
(
_converse
,
sender_jid
)
const
previous_state
=
_converse
.
windowState
;
const
message
=
'
This message will increment the message counter
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
msg
=
$msg
({
const
msg
=
$msg
({
from
:
sender_jid
,
to
:
_converse
.
connection
.
jid
,
type
:
'
chat
'
,
...
...
@@ -1075,8 +1076,13 @@
}).
c
(
'
body
'
).
t
(
message
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
tree
();
_converse
.
windowState
=
'
hidden
'
;
spyOn
(
_converse
,
'
emit
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
incrementMsgCounter
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
clearMsgCounter
'
).
and
.
callThrough
();
_converse
.
chatboxes
.
onMessage
(
msg
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
api
.
chats
.
get
().
length
)
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
));
expect
(
_converse
.
incrementMsgCounter
).
toHaveBeenCalled
();
expect
(
_converse
.
clearMsgCounter
).
not
.
toHaveBeenCalled
();
expect
(
_converse
.
msg_counter
).
toBe
(
1
);
...
...
@@ -1321,7 +1327,7 @@
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread too
'
);
_converse
.
chatboxes
.
onMessage
(
msg
);
await
test_utils
.
waitUntil
(()
=>
chatbox
.
messages
.
length
);
await
test_utils
.
waitUntil
(()
=>
chatbox
.
messages
.
length
>
1
);
indicator_el
=
sizzle
(
selector
,
_converse
.
rosterview
.
el
).
pop
();
expect
(
indicator_el
.
textContent
).
toBe
(
'
2
'
);
done
();
...
...
@@ -1352,7 +1358,7 @@
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread too
'
);
_converse
.
chatboxes
.
onMessage
(
msg
);
await
test_utils
.
waitUntil
(()
=>
chatbox
.
messages
.
length
);
await
test_utils
.
waitUntil
(()
=>
chatbox
.
messages
.
length
>
1
);
indicator_el
=
sizzle
(
selector
,
_converse
.
rosterview
.
el
).
pop
();
expect
(
indicator_el
.
textContent
).
toBe
(
'
2
'
);
done
();
...
...
@@ -1378,7 +1384,7 @@
await
test_utils
.
waitUntil
(()
=>
chatbox
.
messages
.
length
);
expect
(
select_msgs_indicator
().
text
()).
toBe
(
'
1
'
);
_converse
.
chatboxes
.
onMessage
(
msgFactory
());
await
test_utils
.
waitUntil
(()
=>
chatbox
.
messages
.
length
);
await
test_utils
.
waitUntil
(()
=>
chatbox
.
messages
.
length
>
1
);
expect
(
select_msgs_indicator
().
text
()).
toBe
(
'
2
'
);
view
.
maximize
();
expect
(
select_msgs_indicator
().
length
).
toBe
(
0
);
...
...
spec/controlbox.js
View file @
2857293a
...
...
@@ -87,7 +87,7 @@
}).
c
(
'
body
'
).
t
(
'
hello
'
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
_converse
.
chatboxes
.
onMessage
(
msg
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
"
.msgs-indicator
"
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
"
.msgs-indicator
"
)
.
length
);
spyOn
(
chatview
.
model
,
'
incrementUnreadMsgCounter
'
).
and
.
callThrough
();
expect
(
_converse
.
chatboxviews
.
el
.
querySelector
(
'
.restore-chat .message-count
'
).
textContent
).
toBe
(
'
1
'
);
expect
(
_converse
.
rosterview
.
el
.
querySelector
(
'
.msgs-indicator
'
).
textContent
).
toBe
(
'
1
'
);
...
...
spec/messages.js
View file @
2857293a
...
...
@@ -1571,7 +1571,7 @@
.
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
));
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
messages
.
length
);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
)
);
expect
(
chat_content
.
querySelector
(
'
.chat-error
'
).
textContent
).
toEqual
(
error_txt
);
stanza
=
$msg
({
'
to
'
:
_converse
.
connection
.
jid
,
...
...
@@ -1584,7 +1584,7 @@
.
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
));
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
messages
.
length
>
1
);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
)
);
expect
(
chat_content
.
querySelectorAll
(
'
.chat-error
'
).
length
).
toEqual
(
2
);
// We don't render duplicates
...
...
@@ -1599,7 +1599,6 @@
.
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
));
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
messages
.
length
>
2
);
expect
(
chat_content
.
querySelectorAll
(
'
.chat-error
'
).
length
).
toEqual
(
2
);
// We send another message, for which an error will
...
...
@@ -1630,7 +1629,7 @@
.
c
(
'
text
'
,
{
'
xmlns
'
:
"
urn:ietf:params:xml:ns:xmpp-stanzas
"
})
.
t
(
'
Something else went wrong as well
'
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
messages
.
length
>
3
);
await
new
Promise
((
resolve
,
reject
)
=>
view
.
once
(
'
messageInserted
'
,
resolve
)
);
expect
(
chat_content
.
querySelectorAll
(
'
.chat-error
'
).
length
).
toEqual
(
3
);
done
();
}));
...
...
src/converse-minimize.js
View file @
2857293a
...
...
@@ -467,10 +467,7 @@ converse.plugins.add('converse-minimize', {
},
updateUnreadMessagesCounter
()
{
const
ls
=
this
.
model
.
pluck
(
'
num_unread
'
);
let
count
=
0
,
i
;
for
(
i
=
0
;
i
<
ls
.
length
;
i
++
)
{
count
+=
ls
[
i
];
}
this
.
toggleview
.
model
.
save
({
'
num_unread
'
:
count
});
this
.
toggleview
.
model
.
save
({
'
num_unread
'
:
_
.
sum
(
this
.
model
.
pluck
(
'
num_unread
'
))});
this
.
render
();
}
});
...
...
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