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
4fe2b23d
Commit
4fe2b23d
authored
Jan 11, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modernize some roster tests
By ditching jquery and using async/await
parent
df7d663b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
59 deletions
+53
-59
spec/roster.js
spec/roster.js
+52
-57
src/converse-notification.js
src/converse-notification.js
+1
-2
No files found.
spec/roster.js
View file @
4fe2b23d
...
...
@@ -376,7 +376,7 @@
it
(
"
can be used to organize existing contacts
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_converse
.
roster_groups
=
true
;
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
...
...
@@ -387,36 +387,34 @@
test_utils
.
createGroupedContacts
(
_converse
);
// Check that the groups appear alphabetically and that
// requesting and pending contacts are last.
test_utils
.
waitUntil
(
function
()
{
return
$
(
_converse
.
rosterview
.
el
).
find
(
'
.roster-group:visible a.group-toggle
'
).
length
;
},
500
).
then
(
function
()
{
var
group_titles
=
$
.
map
(
$
(
_converse
.
rosterview
.
el
).
find
(
'
.roster-group:visible a.group-toggle
'
),
function
(
o
)
{
return
$
(
o
).
text
().
trim
();
}
);
expect
(
group_titles
).
toEqual
([
"
Contact requests
"
,
"
colleagues
"
,
"
Family
"
,
"
friends & acquaintences
"
,
"
ænemies
"
,
"
Ungrouped
"
,
"
Pending contacts
"
]);
// Check that usernames appear alphabetically per group
_
.
each
(
_
.
keys
(
mock
.
groups
),
function
(
name
)
{
var
$contacts
=
$
(
_converse
.
rosterview
.
el
).
find
(
'
.roster-group[data-group="
'
+
name
+
'
"] ul
'
);
var
names
=
$
.
map
(
$contacts
,
function
(
o
)
{
return
$
(
o
).
text
().
trim
();
});
expect
(
names
).
toEqual
(
_
.
clone
(
names
).
sort
());
});
done
();
await
test_utils
.
waitUntil
(()
=>
sizzle
(
'
.roster-group a.group-toggle
'
,
_converse
.
rosterview
.
el
).
length
);
const
group_titles
=
_
.
map
(
sizzle
(
'
.roster-group a.group-toggle
'
,
_converse
.
rosterview
.
el
),
o
=>
o
.
textContent
.
trim
()
);
expect
(
group_titles
).
toEqual
([
"
Contact requests
"
,
"
colleagues
"
,
"
Family
"
,
"
friends & acquaintences
"
,
"
ænemies
"
,
"
Ungrouped
"
,
"
Pending contacts
"
]);
// Check that usernames appear alphabetically per group
let
names
;
_
.
each
(
_
.
keys
(
mock
.
groups
),
function
(
name
)
{
const
contacts
=
sizzle
(
'
.roster-group[data-group="
'
+
name
+
'
"] ul
'
,
_converse
.
rosterview
.
el
);
const
names
=
_
.
map
(
contacts
,
o
=>
o
.
textContent
.
trim
());
expect
(
names
).
toEqual
(
_
.
clone
(
names
).
sort
());
});
done
();
}));
it
(
"
gets created when a contact's
\"
groups
\"
attribute changes
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_converse
.
roster_groups
=
true
;
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
...
...
@@ -434,28 +432,28 @@
// Check that the groups appear alphabetically and that
// requesting and pending contacts are last.
test_utils
.
waitUntil
(
function
()
{
return
$
(
_converse
.
rosterview
.
el
).
find
(
'
.roster-group:visible a.group-toggle
'
).
length
;
},
500
).
then
(
function
(
)
{
var
group_titles
=
$
.
map
(
$
(
_converse
.
rosterview
.
el
).
find
(
'
.roster-group:visible a.group-toggle
'
),
function
(
o
)
{
return
$
(
o
).
text
().
trim
();
}
);
expect
(
group_titles
).
toEqual
([
'
firstgroup
'
]
);
var
contact
=
_converse
.
roster
.
get
(
'
groupchanger@localhost
'
);
contact
.
set
({
'
groups
'
:
[
'
secondgroup
'
]}
);
return
test_utils
.
waitUntil
(
function
()
{
return
$
(
_converse
.
rosterview
.
el
).
find
(
'
.roster-group[data-group="secondgroup"]:visible a.group-toggle
'
).
length
;
},
500
);
}).
then
(
function
(
)
{
var
group_titles
=
$
.
map
(
$
(
_converse
.
rosterview
.
el
).
find
(
'
.roster-group:visible a.group-toggle
'
),
function
(
o
)
{
return
$
(
o
).
text
().
trim
();
}
);
expect
(
group_titles
).
toEqual
([
'
secondgroup
'
]
);
done
(
);
}
);
let
group_titles
=
await
test_utils
.
waitUntil
(()
=>
{
const
toggles
=
sizzle
(
'
.roster-group a.group-toggle
'
,
_converse
.
rosterview
.
el
)
;
if
(
_
.
reduce
(
toggles
,
(
result
,
t
)
=>
result
&&
u
.
isVisible
(
t
),
true
)
)
{
return
_
.
map
(
toggles
,
o
=>
o
.
textContent
.
trim
());
}
else
{
return
false
;
}
},
1000
);
expect
(
group_titles
).
toEqual
([
'
firstgroup
'
]);
const
contact
=
_converse
.
roster
.
get
(
'
groupchanger@localhost
'
);
contact
.
set
({
'
groups
'
:
[
'
secondgroup
'
]});
group_titles
=
await
test_utils
.
waitUntil
(()
=>
{
const
toggles
=
sizzle
(
'
.roster-group[data-group="secondgroup"] a.group-toggle
'
,
_converse
.
rosterview
.
el
);
if
(
_
.
reduce
(
toggles
,
(
result
,
t
)
=>
result
&&
u
.
isVisible
(
t
),
true
)
)
{
return
_
.
map
(
toggles
,
o
=>
o
.
textContent
.
trim
());
}
else
{
return
false
;
}
},
1000
);
expect
(
group_titles
).
toEqual
([
'
secondgroup
'
]
);
done
(
);
}));
it
(
"
can share contacts with other roster groups
"
,
...
...
@@ -570,21 +568,18 @@
it
(
"
are shown in the roster when show_only_online_users
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_converse
.
show_only_online_users
=
true
;
test_utils
.
openControlBox
();
spyOn
(
_converse
.
rosterview
,
'
update
'
).
and
.
callThrough
();
_addContacts
(
_converse
);
test_utils
.
waitUntil
(
function
()
{
return
$
(
_converse
.
rosterview
.
el
).
find
(
'
li:visible
'
).
length
;
},
700
).
then
(
function
()
{
expect
(
$
(
_converse
.
rosterview
.
el
).
is
(
'
:visible
'
)).
toEqual
(
true
);
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
expect
(
$
(
_converse
.
rosterview
.
el
).
find
(
'
li:visible
'
).
length
).
toBe
(
3
);
expect
(
$
(
_converse
.
rosterview
.
el
).
find
(
'
ul.roster-group-contacts:visible
'
).
length
).
toBe
(
1
);
done
();
});
await
test_utils
.
waitUntil
(()
=>
_
.
reduce
(
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
li
'
),
(
result
,
el
)
=>
result
&&
u
.
isVisible
(
el
),
true
),
500
);
expect
(
u
.
isVisible
(
_converse
.
rosterview
.
el
)).
toEqual
(
true
);
expect
(
_converse
.
rosterview
.
update
).
toHaveBeenCalled
();
expect
(
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
li
'
).
length
).
toBe
(
3
);
expect
(
_
.
filter
(
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
ul.roster-group-contacts
'
),
u
.
isVisible
).
length
).
toBe
(
1
);
done
();
}));
it
(
"
are shown in the roster when hide_offline_users
"
,
...
...
src/converse-notification.js
View file @
4fe2b23d
...
...
@@ -247,8 +247,7 @@ converse.plugins.add('converse-notification', {
* Will show an HTML5 notification to indicate that the chat
* status has changed.
*/
if
(
_converse
.
areDesktopNotificationsEnabled
()
&&
_converse
.
show_chatstate_notifications
)
{
if
(
_converse
.
areDesktopNotificationsEnabled
()
&&
_converse
.
show_chatstate_notifications
)
{
_converse
.
showChatStateNotification
(
contact
);
}
};
...
...
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