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
dfe9d301
Commit
dfe9d301
authored
Feb 13, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test that roster groups are fetched before contacts
updates #1405
parent
b172861d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
27 deletions
+49
-27
dist/converse.js
dist/converse.js
+4
-8
spec/bookmarks.js
spec/bookmarks.js
+3
-3
spec/roomslist.js
spec/roomslist.js
+1
-1
spec/roster.js
spec/roster.js
+28
-0
src/headless/converse-roster.js
src/headless/converse-roster.js
+7
-11
tests/mock.js
tests/mock.js
+6
-4
No files found.
dist/converse.js
View file @
dfe9d301
...
...
@@ -68022,10 +68022,6 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
}
} else {
try {
/* Make sure not to run fetchRosterContacts async, since we need
* the contacts to exist before processing contacts presence,
* which might come in the same BOSH request.
*/
await _converse.rostergroups.fetchRosterGroups();
_converse.emit('rosterGroupsFetched');
...
...
@@ -68379,7 +68375,7 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
if (collection.length === 0 || this.rosterVersioningSupported() && !_converse.session.get('roster_fetched')) {
_converse.send_initial_presence = true;
await
_converse.roster.fetchFromServer();
return
_converse.roster.fetchFromServer();
} else {
_converse.emit('cachedRoster', collection);
}
...
...
@@ -68810,13 +68806,13 @@ _converse_headless_converse_core__WEBPACK_IMPORTED_MODULE_0__["default"].plugins
* Returns a promise which resolves once the groups have been
* returned.
*/
return new Promise(
(resolve, reject)
=> {
return new Promise(
success
=> {
this.fetch({
s
ilent: true
,
s
uccess
,
// We need to first have all groups before
// we can start positioning them, so we set
// 'silent' to true.
s
uccess: resolv
e
s
ilent: tru
e
});
});
}
spec/bookmarks.js
View file @
dfe9d301
...
...
@@ -362,7 +362,7 @@
it
(
"
can be retrieved from the XMPP server
"
,
mock
.
initConverse
(
[
'
send
'
]
,
[
'
chatBoxesFetched
'
,
'
roomsPanelRendered
'
,
'
rosterGroupsFetched
'
],
{},
{
'
connection
'
:
[
'
send
'
]}
,
[
'
chatBoxesFetched
'
,
'
roomsPanelRendered
'
,
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitUntilDiscoConfirmed
(
...
...
@@ -453,7 +453,7 @@
describe
(
"
The rooms panel
"
,
function
()
{
it
(
"
shows a list of bookmarks
"
,
mock
.
initConverse
(
[
'
send
'
]
,
[
'
rosterGroupsFetched
'
],
{},
{
'
connection
'
:
[
'
send
'
]}
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
test_utils
.
waitUntilDiscoConfirmed
(
...
...
@@ -541,7 +541,7 @@
it
(
"
remembers the toggle state of the bookmarks list
"
,
mock
.
initConverse
(
[
'
send
'
]
,
[
'
rosterGroupsFetched
'
],
{},
{
'
connection
'
:
[
'
send
'
]}
,
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
();
...
...
spec/roomslist.js
View file @
dfe9d301
...
...
@@ -48,7 +48,7 @@
it
(
"
uses bookmarks to determine groupchat names
"
,
mock
.
initConverse
(
[
'
send
'
]
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
'
view_mode
'
:
'
fullscreen
'
},
{
'
connection
'
:
[
'
send
'
]}
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
'
view_mode
'
:
'
fullscreen
'
},
async
function
(
done
,
_converse
)
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
...
...
spec/roster.js
View file @
dfe9d301
...
...
@@ -30,6 +30,34 @@
describe
(
"
The Contacts Roster
"
,
function
()
{
it
(
"
is populated once we have registered a presence handler
"
,
mock
.
initConverse
(
{
'
_converse
'
:
[
'
emit
'
]},
null
,
{},
async
function
(
done
,
_converse
)
{
const
IQs
=
_converse
.
connection
.
IQ_stanzas
;
await
test_utils
.
waitUntil
(()
=>
_converse
.
emit
.
calls
.
all
().
map
(
c
=>
c
.
args
[
0
]).
includes
(
'
rosterGroupsFetched
'
));
const
node
=
await
test_utils
.
waitUntil
(
()
=>
_
.
filter
(
IQs
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq query[xmlns="jabber:iq:roster"]
'
)).
pop
());
expect
(
_converse
.
emit
.
calls
.
all
().
map
(
c
=>
c
.
args
[
0
]).
includes
(
'
rosterContactsFetched
'
)).
toBeFalsy
();
expect
(
node
.
toLocaleString
()).
toBe
(
`<iq id="
${
node
.
nodeTree
.
getAttribute
(
'
id
'
)}
" type="get" xmlns="jabber:client">`
+
`<query xmlns="jabber:iq:roster"/>`
+
`</iq>`
);
const
result
=
$iq
({
'
to
'
:
_converse
.
connection
.
jid
,
'
type
'
:
'
result
'
,
'
id
'
:
node
.
nodeTree
.
getAttribute
(
'
id
'
)
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
jabber:iq:roster
'
}).
c
(
'
item
'
,
{
'
jid
'
:
'
nurse@example.com
'
}).
up
()
.
c
(
'
item
'
,
{
'
jid
'
:
'
romeo@example.com
'
})
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
await
test_utils
.
waitUntil
(()
=>
_converse
.
emit
.
calls
.
all
().
map
(
c
=>
c
.
args
[
0
]).
includes
(
'
rosterContactsFetched
'
));
done
();
}));
it
(
"
supports roster versioning
"
,
mock
.
initConverse
(
null
,
[
'
rosterGroupsFetched
'
],
{},
...
...
src/headless/converse-roster.js
View file @
dfe9d301
...
...
@@ -88,13 +88,8 @@ converse.plugins.add('converse-roster', {
}
}
else
{
try
{
/* Make sure not to run fetchRosterContacts async, since we need
* the contacts to exist before processing contacts presence,
* which might come in the same BOSH request.
*/
await
_converse
.
rostergroups
.
fetchRosterGroups
();
_converse
.
emit
(
'
rosterGroupsFetched
'
);
await
_converse
.
roster
.
fetchRosterContacts
();
_converse
.
emit
(
'
rosterContactsFetched
'
);
}
catch
(
reason
)
{
...
...
@@ -407,7 +402,7 @@ converse.plugins.add('converse-roster', {
if
(
collection
.
length
===
0
||
(
this
.
rosterVersioningSupported
()
&&
!
_converse
.
session
.
get
(
'
roster_fetched
'
)))
{
_converse
.
send_initial_presence
=
true
;
await
_converse
.
roster
.
fetchFromServer
();
return
_converse
.
roster
.
fetchFromServer
();
}
else
{
_converse
.
emit
(
'
cachedRoster
'
,
collection
);
}
...
...
@@ -780,12 +775,13 @@ converse.plugins.add('converse-roster', {
* Returns a promise which resolves once the groups have been
* returned.
*/
return
new
Promise
(
(
resolve
,
reject
)
=>
{
return
new
Promise
(
success
=>
{
this
.
fetch
({
silent
:
true
,
// We need to first have all groups before
success
,
// We need to first have all groups before
// we can start positioning them, so we set
// 'silent' to true.
s
uccess
:
resolve
s
ilent
:
true
,
});
});
}
...
...
tests/mock.js
View file @
dfe9d301
...
...
@@ -167,10 +167,8 @@
}
const
connection
=
mock
.
mock_connection
();
if
(
!
_
.
isUndefined
(
spies
))
{
_
.
forEach
(
spies
,
function
(
method
)
{
spyOn
(
connection
,
method
);
});
if
(
!
_
.
isNil
(
spies
))
{
_
.
forEach
(
spies
.
connection
,
method
=>
spyOn
(
connection
,
method
));
}
const
_converse
=
await
converse
.
initialize
(
_
.
extend
({
...
...
@@ -186,6 +184,10 @@
'
debug
'
:
false
},
settings
||
{}));
if
(
!
_
.
isNil
(
spies
))
{
_
.
forEach
(
spies
.
_converse
,
method
=>
spyOn
(
_converse
,
method
).
and
.
callThrough
());
}
_converse
.
ChatBoxViews
.
prototype
.
trimChat
=
function
()
{};
_converse
.
api
.
vcard
.
get
=
function
(
model
,
force
)
{
...
...
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