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
fc941270
Commit
fc941270
authored
Dec 03, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix failing tests
parent
393bbe02
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
475 additions
and
410 deletions
+475
-410
spec/chatbox.js
spec/chatbox.js
+161
-130
spec/chatroom.js
spec/chatroom.js
+10
-2
spec/protocol.js
spec/protocol.js
+283
-277
tests/utils.js
tests/utils.js
+21
-1
No files found.
spec/chatbox.js
View file @
fc941270
...
...
@@ -10,6 +10,7 @@
}
(
this
,
function
(
$
,
jasmine
,
utils
,
converse
,
mock
,
test_utils
)
{
"
use strict
"
;
var
_
=
converse
.
env
.
_
;
var
$iq
=
converse
.
env
.
$iq
;
var
$msg
=
converse
.
env
.
$msg
;
var
Strophe
=
converse
.
env
.
Strophe
;
var
moment
=
converse
.
env
.
moment
;
...
...
@@ -22,6 +23,12 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
waitUntilFeatureSupportConfirmed
(
_converse
,
'
vcard-temp
'
)
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
},
300
);
}).
then
(
function
()
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
...
...
@@ -46,6 +53,7 @@
expect
(
_
.
includes
(
view
.
$el
.
find
(
'
.chat-msg-author:last
'
).
text
(),
'
**Max Mustermann
'
)).
toBeTruthy
();
expect
(
view
.
$el
.
find
(
'
.chat-msg-content:last
'
).
text
()).
toBe
(
'
is as well
'
);
done
();
});
}));
it
(
"
is created when you click on a roster item
"
,
...
...
@@ -527,7 +535,8 @@
describe
(
"
A Chat Message
"
,
function
()
{
describe
(
"
when received from someone else
"
,
function
()
{
it
(
"
can be received which will open a chatbox and be displayed inside it
"
,
it
(
"
will open a chatbox and be displayed inside it
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
...
...
@@ -953,6 +962,13 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
var
contact
,
sent_stanza
,
IQ_id
,
stanza
;
test_utils
.
waitUntilFeatureSupportConfirmed
(
_converse
,
'
vcard-temp
'
)
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
},
300
);
}).
then
(
function
()
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openControlBox
();
test_utils
.
openContactsPanel
(
_converse
);
...
...
@@ -994,6 +1010,7 @@
var
msg_txt
=
$chat_content
.
find
(
'
.chat-message
'
).
find
(
'
.chat-msg-content
'
).
text
();
expect
(
msg_txt
).
toEqual
(
msgtext
);
done
();
});
}));
it
(
"
will be discarded if it's a malicious message meant to look like a carbon copy
"
,
...
...
@@ -1561,8 +1578,14 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
var
contact
,
sent_stanza
,
IQ_id
,
stanza
;
test_utils
.
waitUntilFeatureSupportConfirmed
(
_converse
,
'
vcard-temp
'
)
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
},
300
);
}).
then
(
function
()
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
// Send a message from a different resource
spyOn
(
_converse
,
'
log
'
);
var
recipient_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
@@ -1596,6 +1619,7 @@
var
status_text
=
$chat_content
.
find
(
'
.chat-info.chat-event
'
).
text
();
expect
(
status_text
).
toBe
(
'
Typing from another device
'
);
done
();
});
}));
});
...
...
@@ -1702,8 +1726,14 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
var
contact
,
sent_stanza
,
IQ_id
,
stanza
;
test_utils
.
waitUntilFeatureSupportConfirmed
(
_converse
,
'
vcard-temp
'
)
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
},
300
);
}).
then
(
function
()
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
// Send a message from a different resource
spyOn
(
_converse
,
'
log
'
);
var
recipient_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
...
...
@@ -1737,6 +1767,7 @@
var
status_text
=
$chat_content
.
find
(
'
.chat-info.chat-event
'
).
text
();
expect
(
status_text
).
toBe
(
'
Stopped typing on the other device
'
);
done
();
});
}));
});
...
...
spec/chatroom.js
View file @
fc941270
...
...
@@ -546,8 +546,16 @@
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
waitUntilFeatureSupportConfirmed
(
_converse
,
'
vcard-temp
'
)
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
},
300
);
}).
then
(
function
()
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
).
then
(
function
()
{
return
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
}).
then
(
function
()
{
var
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
if
(
!
view
.
$el
.
find
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
var
message
=
'
/me is tired
'
;
...
...
spec/protocol.js
View file @
fc941270
...
...
@@ -54,10 +54,16 @@
{
roster_groups
:
false
},
function
(
done
,
_converse
)
{
var
contact
,
sent_stanza
,
IQ_id
,
stanza
;
test_utils
.
waitUntilFeatureSupportConfirmed
(
_converse
,
'
vcard-temp
'
)
.
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
_converse
.
xmppstatus
.
get
(
'
fullname
'
);
},
300
);
}).
then
(
function
()
{
/* The process by which a user subscribes to a contact, including
* the interaction between roster items and subscription states.
*/
var
contact
,
stanza
,
sent_stanza
,
IQ_id
;
test_utils
.
openControlBox
(
_converse
);
var
panel
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
).
contactspanel
;
spyOn
(
panel
,
"
addContactFromForm
"
).
and
.
callThrough
();
...
...
@@ -65,6 +71,7 @@
spyOn
(
_converse
.
roster
,
"
addContact
"
).
and
.
callThrough
();
spyOn
(
_converse
.
roster
,
"
sendContactAddIQ
"
).
and
.
callThrough
();
spyOn
(
_converse
.
api
.
vcard
,
"
get
"
).
and
.
callThrough
();
var
sendIQ
=
_converse
.
connection
.
sendIQ
;
spyOn
(
_converse
.
connection
,
'
sendIQ
'
).
and
.
callFake
(
function
(
iq
,
callback
,
errback
)
{
sent_stanza
=
iq
;
...
...
@@ -180,11 +187,10 @@
*
* <presence to='contact@example.org' type='subscribe'/>
*/
test_utils
.
waitUntil
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
sent_stanzas
.
length
==
1
;
},
300
).
then
(
function
()
{
},
300
);
}).
then
(
function
()
{
expect
(
contact
.
subscribe
).
toHaveBeenCalled
();
expect
(
sent_stanza
.
toLocaleString
()).
toBe
(
// Strophe adds the xmlns attr (although not in spec)
"
<presence to='contact@example.org' type='subscribe' xmlns='jabber:client'>
"
+
...
...
@@ -222,10 +228,11 @@
expect
(
_converse
.
roster
.
updateContact
).
toHaveBeenCalled
();
// Check that the user is now properly shown as a pending
// contact in the roster.
test_utils
.
waitUntil
(
function
()
{
return
$
(
'
a:contains("Pending contacts")
'
).
length
;
},
300
).
then
(
function
()
{
return
test_utils
.
waitUntil
(
function
()
{
return
$
(
'
a:contains("Pending contacts")
'
).
length
;
},
300
);
}).
then
(
function
()
{
var
$header
=
$
(
'
a:contains("Pending contacts")
'
);
expect
(
$header
.
length
).
toBe
(
1
);
expect
(
$header
.
is
(
"
:visible
"
)).
toBeTruthy
();
...
...
@@ -368,7 +375,6 @@
expect
(
$contacts
.
hasClass
(
'
both
'
)).
toBeTruthy
();
done
();
});
});
}));
it
(
"
Alternate Flow: Contact Declines Subscription Request
"
,
...
...
@@ -403,7 +409,7 @@
/* We now assume the contact declines the subscription
* requests.
*
/
* Upon receiving the presence stanza of type "unsubscribed"
* Upon receiving the presence stanza of type "unsubscribed"
* addressed to the user, the user's server (1) MUST deliver
* that presence stanza to the user and (2) MUST initiate a
* roster push to all of the user's available resources that
...
...
tests/utils.js
View file @
fc941270
...
...
@@ -11,7 +11,27 @@
if
(
typeof
window
.
Promise
===
'
undefined
'
)
{
waitUntilPromise
.
setPromiseImplementation
(
Promise
);
}
utils
.
waitUntil
=
waitUntilPromise
[
'
default
'
];
utils
.
waitUntil
=
waitUntilPromise
.
default
;
utils
.
waitUntilFeatureSupportConfirmed
=
function
(
_converse
,
feature_name
)
{
var
IQ_disco
,
stanza
;
return
utils
.
waitUntil
(
function
()
{
IQ_disco
=
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
function
(
iq
)
{
return
iq
.
nodeTree
.
querySelector
(
'
query[xmlns="http://jabber.org/protocol/disco#info"]
'
);
}).
pop
();
return
!
_
.
isUndefined
(
IQ_disco
);
},
300
).
then
(
function
()
{
var
info_IQ_id
=
IQ_disco
.
nodeTree
.
getAttribute
(
'
id
'
);
stanza
=
$iq
({
'
type
'
:
'
result
'
,
'
from
'
:
'
localhost
'
,
'
to
'
:
'
dummy@localhost/resource
'
,
'
id
'
:
info_IQ_id
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
feature
'
,
{
'
var
'
:
feature_name
});
_converse
.
connection
.
_dataRecv
(
utils
.
createRequest
(
stanza
));
});
}
utils
.
createRequest
=
function
(
iq
)
{
iq
=
typeof
iq
.
tree
==
"
function
"
?
iq
.
tree
()
:
iq
;
...
...
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