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
2f46bb8c
Commit
2f46bb8c
authored
Mar 14, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix failing tests
parent
1565decf
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
53 deletions
+51
-53
spec/chatbox.js
spec/chatbox.js
+24
-25
spec/converse.js
spec/converse.js
+18
-19
spec/roomslist.js
spec/roomslist.js
+6
-7
src/converse-chatview.js
src/converse-chatview.js
+1
-0
src/converse-roomslist.js
src/converse-roomslist.js
+1
-1
src/templates/rooms_list_item.html
src/templates/rooms_list_item.html
+1
-1
No files found.
spec/chatbox.js
View file @
2f46bb8c
...
...
@@ -350,8 +350,8 @@
return
$
(
chatview
.
el
).
find
(
'
.chat-body
'
).
is
(
'
:visible
'
);
},
500
);
}).
then
(
function
()
{
expect
(
$
(
chatview
.
el
).
find
(
'
.toggle-chatbox-button
'
).
hasClass
(
'
icon
-minus
'
)).
toBeTruthy
();
expect
(
$
(
chatview
.
el
).
find
(
'
.toggle-chatbox-button
'
).
hasClass
(
'
icon
-plus
'
)).
toBeFalsy
();
expect
(
$
(
chatview
.
el
).
find
(
'
.toggle-chatbox-button
'
).
hasClass
(
'
fa
-minus
'
)).
toBeTruthy
();
expect
(
$
(
chatview
.
el
).
find
(
'
.toggle-chatbox-button
'
).
hasClass
(
'
fa
-plus
'
)).
toBeFalsy
();
expect
(
chatview
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
done
();
});
...
...
@@ -678,11 +678,11 @@
var
chatboxview
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
expect
(
chatbox
).
toBeDefined
();
expect
(
chatboxview
).
toBeDefined
();
// XXX: I don't really like the convention of
// setting "fullname" to the JID if there's
// no fullname. Should ideally be null if
// there's no fullname.
var
author_el
=
chatboxview
.
el
.
querySelector
(
'
.chat-msg-author
'
);
expect
(
chatbox
.
get
(
'
fullname
'
)
===
sender_jid
);
expect
(
_
.
includes
(
author_el
.
textContent
,
'
max.frankfurter@localhost
'
)).
toBeTruthy
();
test_utils
.
waitUntil
(
function
()
{
return
vcard_fetched
;
},
100
)
.
then
(
function
()
{
expect
(
_converse
.
api
.
vcard
.
get
).
toHaveBeenCalled
();
...
...
@@ -718,13 +718,13 @@
// We don't already have an open chatbox for this user
expect
(
_converse
.
chatboxes
.
get
(
sender_jid
)).
not
.
toBeDefined
();
var
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
expect
(
chatbox
).
not
.
toBeDefined
();
// onMessage is a handler for received XMPP messages
_converse
.
chatboxes
.
onMessage
(
msg
);
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
var
chatbox
=
_converse
.
chatboxes
.
get
(
sender_jid
);
expect
(
chatbox
).
not
.
toBeDefined
();
// onMessage is a handler for received XMPP messages
_converse
.
allow_non_roster_messaging
=
true
;
_converse
.
chatboxes
.
onMessage
(
msg
);
...
...
@@ -744,7 +744,7 @@
expect
(
msg_obj
.
get
(
'
delayed
'
)).
toEqual
(
false
);
// Now check that the message appears inside the chatbox in the DOM
var
$chat_content
=
$
(
chatboxview
.
el
).
find
(
'
.chat-content
'
);
var
msg_txt
=
$chat_content
.
find
(
'
.chat-message
'
).
find
(
'
.chat-msg-content
'
).
text
();
var
msg_txt
=
$chat_content
.
find
(
'
.chat-message
.chat-msg-content
'
).
text
();
expect
(
msg_txt
).
toEqual
(
message
);
var
sender_txt
=
$chat_content
.
find
(
'
span.chat-msg-them
'
).
text
();
expect
(
sender_txt
.
match
(
/^
[
0-9
][
0-9
]
:
[
0-9
][
0-9
]
/
)).
toBeTruthy
();
...
...
@@ -1331,10 +1331,9 @@
}));
it
(
"
received for a minimized chat box will increment a counter on its header
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
...
...
@@ -1439,7 +1438,7 @@
var
$time
=
$chat_content
.
find
(
'
time
'
);
expect
(
$time
.
length
).
toEqual
(
1
);
expect
(
$time
.
attr
(
'
class
'
)).
toEqual
(
'
message chat-info chat-date
'
);
expect
(
$time
.
attr
(
'
class
'
)).
toEqual
(
'
message chat-info chat-date
badge badge-info
'
);
expect
(
$time
.
data
(
'
isodate
'
)).
toEqual
(
moment
(
one_day_ago
.
startOf
(
'
day
'
)).
format
());
expect
(
$time
.
text
()).
toEqual
(
moment
(
one_day_ago
.
startOf
(
'
day
'
)).
format
(
"
dddd MMM Do YYYY
"
));
...
...
@@ -1459,7 +1458,7 @@
expect
(
$time
.
length
).
toEqual
(
2
);
// There are now two time elements
$time
=
$chat_content
.
find
(
'
time:last
'
);
// We check the last one
var
message_date
=
new
Date
();
expect
(
$time
.
attr
(
'
class
'
)).
toEqual
(
'
message chat-info chat-date
'
);
expect
(
$time
.
attr
(
'
class
'
)).
toEqual
(
'
message chat-info chat-date
badge badge-info
'
);
expect
(
$time
.
data
(
'
isodate
'
)).
toEqual
(
moment
(
message_date
).
startOf
(
'
day
'
).
format
());
expect
(
$time
.
text
()).
toEqual
(
moment
(
message_date
).
startOf
(
'
day
'
).
format
(
"
dddd MMM Do YYYY
"
));
...
...
@@ -1502,9 +1501,9 @@
}));
it
(
"
is sanitized to prevent Javascript injection attacks
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
...
...
@@ -1544,9 +1543,9 @@
}));
it
(
"
will have properly escaped URLs
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
...
...
@@ -1644,9 +1643,9 @@
}));
it
(
"
will render the message time as configured
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
...
...
spec/converse.js
View file @
2f46bb8c
...
...
@@ -102,26 +102,26 @@
_converse
.
auto_away
=
3
;
_converse
.
auto_xa
=
6
;
expect
(
_converse
.
xmppstatus
.
getStatus
()).
toBe
(
'
online
'
);
expect
(
_converse
.
api
.
user
.
status
.
get
()).
toBe
(
'
online
'
);
while
(
i
<=
_converse
.
auto_away
)
{
_converse
.
onEverySecond
();
i
++
;
}
expect
(
_converse
.
auto_changed_status
).
toBe
(
true
);
while
(
i
<=
_converse
.
auto_xa
)
{
expect
(
_converse
.
xmppstatus
.
getStatus
()).
toBe
(
'
away
'
);
expect
(
_converse
.
api
.
user
.
status
.
get
()).
toBe
(
'
away
'
);
_converse
.
onEverySecond
();
i
++
;
}
expect
(
_converse
.
xmppstatus
.
getStatus
()).
toBe
(
'
xa
'
);
expect
(
_converse
.
api
.
user
.
status
.
get
()).
toBe
(
'
xa
'
);
expect
(
_converse
.
auto_changed_status
).
toBe
(
true
);
_converse
.
onUserActivity
();
expect
(
_converse
.
xmppstatus
.
getStatus
()).
toBe
(
'
online
'
);
expect
(
_converse
.
api
.
user
.
status
.
get
()).
toBe
(
'
online
'
);
expect
(
_converse
.
auto_changed_status
).
toBe
(
false
);
// Check that it also works for the chat feature
_converse
.
xmppstatus
.
setStatus
(
'
chat
'
);
_converse
.
api
.
user
.
status
.
set
(
'
chat
'
)
i
=
0
;
while
(
i
<=
_converse
.
auto_away
)
{
_converse
.
onEverySecond
();
...
...
@@ -129,36 +129,36 @@
}
expect
(
_converse
.
auto_changed_status
).
toBe
(
true
);
while
(
i
<=
_converse
.
auto_xa
)
{
expect
(
_converse
.
xmppstatus
.
getStatus
()).
toBe
(
'
away
'
);
expect
(
_converse
.
api
.
user
.
status
.
get
()).
toBe
(
'
away
'
);
_converse
.
onEverySecond
();
i
++
;
}
expect
(
_converse
.
xmppstatus
.
getStatus
()).
toBe
(
'
xa
'
);
expect
(
_converse
.
api
.
user
.
status
.
get
()).
toBe
(
'
xa
'
);
expect
(
_converse
.
auto_changed_status
).
toBe
(
true
);
_converse
.
onUserActivity
();
expect
(
_converse
.
xmppstatus
.
getStatus
()).
toBe
(
'
online
'
);
expect
(
_converse
.
api
.
user
.
status
.
get
()).
toBe
(
'
online
'
);
expect
(
_converse
.
auto_changed_status
).
toBe
(
false
);
// Check that it doesn't work for 'dnd'
_converse
.
xmppstatus
.
setStatus
(
'
dnd
'
);
_converse
.
api
.
user
.
status
.
set
(
'
dnd
'
);
i
=
0
;
while
(
i
<=
_converse
.
auto_away
)
{
_converse
.
onEverySecond
();
i
++
;
}
expect
(
_converse
.
xmppstatus
.
getStatus
()).
toBe
(
'
dnd
'
);
expect
(
_converse
.
api
.
user
.
status
.
get
()).
toBe
(
'
dnd
'
);
expect
(
_converse
.
auto_changed_status
).
toBe
(
false
);
while
(
i
<=
_converse
.
auto_xa
)
{
expect
(
_converse
.
xmppstatus
.
getStatus
()).
toBe
(
'
dnd
'
);
expect
(
_converse
.
api
.
user
.
status
.
get
()).
toBe
(
'
dnd
'
);
_converse
.
onEverySecond
();
i
++
;
}
expect
(
_converse
.
xmppstatus
.
getStatus
()).
toBe
(
'
dnd
'
);
expect
(
_converse
.
api
.
user
.
status
.
get
()).
toBe
(
'
dnd
'
);
expect
(
_converse
.
auto_changed_status
).
toBe
(
false
);
_converse
.
onUserActivity
();
expect
(
_converse
.
xmppstatus
.
getStatus
()).
toBe
(
'
dnd
'
);
expect
(
_converse
.
api
.
user
.
status
.
get
()).
toBe
(
'
dnd
'
);
expect
(
_converse
.
auto_changed_status
).
toBe
(
false
);
}));
});
...
...
@@ -248,16 +248,15 @@
expect
(
_converse
.
api
.
contacts
.
get
(
'
non-existing@jabber.org
'
)).
toBeFalsy
();
// Check when a single jid is given
var
jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
attrs
=
_converse
.
api
.
contacts
.
get
(
jid
);
expect
(
typeof
attrs
).
toBe
(
'
object
'
);
expect
(
attrs
.
fullname
).
toBe
(
mock
.
cur_names
[
0
]);
expect
(
attrs
.
jid
).
toBe
(
jid
);
var
contact
=
_converse
.
api
.
contacts
.
get
(
jid
);
expect
(
contact
.
get
(
'
fullname
'
)).
toBe
(
mock
.
cur_names
[
0
]);
expect
(
contact
.
get
(
'
jid
'
)).
toBe
(
jid
);
// You can retrieve multiple contacts by passing in an array
var
jid2
=
mock
.
cur_names
[
1
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
list
=
_converse
.
api
.
contacts
.
get
([
jid
,
jid2
]);
expect
(
_
.
isArray
(
list
)).
toBeTruthy
();
expect
(
list
[
0
].
fullname
).
toBe
(
mock
.
cur_names
[
0
]);
expect
(
list
[
1
].
fullname
).
toBe
(
mock
.
cur_names
[
1
]);
expect
(
list
[
0
].
get
(
'
fullname
'
)
).
toBe
(
mock
.
cur_names
[
0
]);
expect
(
list
[
1
].
get
(
'
fullname
'
)
).
toBe
(
mock
.
cur_names
[
1
]);
// Check that all JIDs are returned if you call without any parameters
list
=
_converse
.
api
.
contacts
.
get
();
expect
(
list
.
length
).
toBe
(
mock
.
cur_names
.
length
);
...
...
spec/roomslist.js
View file @
2f46bb8c
...
...
@@ -9,23 +9,22 @@
it
(
"
is shown under a list of open rooms in the
\"
Rooms
\"
panel
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{
whitelisted_plugins
:
[
'
converse-roomslist
'
],
allow_bookmarks
:
false
// Makes testing easier, otherwise we
{
allow_bookmarks
:
false
// Makes testing easier, otherwise we
// have to mock stanza traffic.
},
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
();
var
controlbox
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
);
var
list
=
controlbox
.
el
.
querySelector
(
'
div.rooms-list-container
'
);
expect
(
_
.
includes
(
list
.
classList
,
'
hidden
'
)).
toBeTruthy
();
test_utils
.
openChatRoom
(
_converse
,
'
room
'
,
'
conference.shakespeare.lit
'
,
'
JC
'
);
test_utils
.
openChatRoom
(
_converse
,
'
room
'
,
'
conference.shakespeare.lit
'
,
'
JC
'
);
expect
(
_
.
isUndefined
(
_converse
.
rooms_list_view
)).
toBeFalsy
();
var
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
expect
(
room_els
.
length
).
toBe
(
1
);
expect
(
room_els
[
0
].
innerText
).
toBe
(
'
room
'
);
expect
(
room_els
[
0
].
innerText
).
toBe
(
'
room
@conference.shakespeare.lit
'
);
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
...
...
@@ -35,7 +34,7 @@
view
.
close
();
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
expect
(
room_els
.
length
).
toBe
(
1
);
expect
(
room_els
[
0
].
innerText
).
toBe
(
'
lounge
'
);
expect
(
room_els
[
0
].
innerText
).
toBe
(
'
lounge
@localhost
'
);
list
=
controlbox
.
el
.
querySelector
(
'
div.rooms-list-container
'
);
expect
(
_
.
includes
(
list
.
classList
,
'
hidden
'
)).
toBeFalsy
();
...
...
@@ -73,7 +72,7 @@
var
close_el
=
_converse
.
rooms_list_view
.
el
.
querySelector
(
"
.close-room
"
);
close_el
.
click
();
expect
(
window
.
confirm
).
toHaveBeenCalledWith
(
'
Are you sure you want to leave the room
"lounge"
?
'
);
'
Are you sure you want to leave the room
lounge@conference.shakespeare.lit
?
'
);
room_els
=
_converse
.
rooms_list_view
.
el
.
querySelectorAll
(
"
.open-room
"
);
expect
(
room_els
.
length
).
toBe
(
0
);
expect
(
_converse
.
chatboxes
.
length
).
toBe
(
1
);
...
...
src/converse-chatview.js
View file @
2f46bb8c
...
...
@@ -1091,6 +1091,7 @@
this
.
setChatState
(
_converse
.
ACTIVE
);
this
.
renderEmojiPicker
();
this
.
scrollDown
();
this
.
focus
();
},
_show
(
f
)
{
...
...
src/converse-roomslist.js
View file @
2f46bb8c
...
...
@@ -211,7 +211,7 @@
ev
.
preventDefault
();
const
name
=
ev
.
target
.
getAttribute
(
'
data-room-name
'
);
const
jid
=
ev
.
target
.
getAttribute
(
'
data-room-jid
'
);
if
(
confirm
(
__
(
"
Are you sure you want to leave the room
\"
%1$s
\"
?
"
,
name
)))
{
if
(
confirm
(
__
(
"
Are you sure you want to leave the room
%1$s
?
"
,
name
)))
{
_converse
.
chatboxviews
.
get
(
jid
).
leave
();
}
},
...
...
src/templates/rooms_list_item.html
View file @
2f46bb8c
...
...
@@ -9,7 +9,7 @@
<a
class=
"right close-room icon-leave"
data-room-jid=
"{{{o.jid}}}"
data-room-name=
"{{{o.name}}}"
data-room-name=
"{{{o.name
|| o.jid
}}}"
title=
"{{{o.info_leave_room}}}"
href=
"#"
>
</a>
{[ if (o.allow_bookmarks) { ]}
...
...
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