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
b91f4884
Commit
b91f4884
authored
Nov 20, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use async/await
parent
54652f74
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1182 additions
and
1227 deletions
+1182
-1227
spec/chatroom.js
spec/chatroom.js
+1111
-1150
spec/messages.js
spec/messages.js
+71
-77
No files found.
spec/chatroom.js
View file @
b91f4884
...
...
@@ -1735,13 +1735,12 @@
// cheat here and emit the event.
_converse
.
emit
(
'
rosterContactsFetched
'
);
let
view
;
await
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
spyOn
(
_converse
,
'
emit
'
);
spyOn
(
window
,
'
prompt
'
).
and
.
callFake
(
function
()
{
return
"
Please join!
"
;
});
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
// XXX: cheating a lttle bit, normally this'll be set after
// receiving the features for the groupchat.
...
...
@@ -1788,25 +1787,25 @@
it
(
"
can be joined automatically, based upon a received invite
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
// We need roster contacts, who can invite us
spyOn
(
window
,
'
confirm
'
).
and
.
callFake
(
function
()
{
return
true
;
});
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
).
then
(
function
()
{
var
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
view
.
close
();
// Hack, otherwise we have to mock stanzas.
var
name
=
mock
.
cur_names
[
0
];
var
from_jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
room_jid
=
'
lounge@localhost
'
;
var
reason
=
"
Please join this groupchat
"
;
const
name
=
mock
.
cur_names
[
0
];
const
from_jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
room_jid
=
'
lounge@localhost
'
;
const
reason
=
"
Please join this groupchat
"
;
expect
(
_converse
.
chatboxes
.
models
.
length
).
toBe
(
1
);
expect
(
_converse
.
chatboxes
.
models
[
0
].
id
).
toBe
(
"
controlbox
"
);
var
stanza
=
Strophe
.
xmlHtmlNode
(
const
stanza
=
Strophe
.
xmlHtmlNode
(
'
<message xmlns="jabber:client" to="
'
+
_converse
.
bare_jid
+
'
" from="
'
+
from_jid
+
'
" id="9bceb415-f34b-4fa4-80d5-c0d076a24231">
'
+
'
<x xmlns="jabber:x:conference" jid="
'
+
room_jid
+
'
" reason="
'
+
reason
+
'
"/>
'
+
'
</message>
'
).
firstChild
;
...
...
@@ -1818,7 +1817,6 @@
expect
(
_converse
.
chatboxes
.
models
[
0
].
id
).
toBe
(
'
controlbox
'
);
expect
(
_converse
.
chatboxes
.
models
[
1
].
id
).
toBe
(
room_jid
);
done
();
});
}));
it
(
"
shows received groupchat messages
"
,
...
...
@@ -2089,19 +2087,18 @@
it
(
"
queries for the groupchat information before attempting to join the user
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
const
room_jid
=
'
coven@chat.shakespeare.lit
'
;
_converse
.
api
.
rooms
.
open
(
room_jid
,
{
'
nick
'
:
'
some1
'
})
.
then
(()
=>
{
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
await
_converse
.
api
.
rooms
.
open
(
room_jid
,
{
'
nick
'
:
'
some1
'
});
const
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
());
}).
then
(
node
=>
{
// Check that the groupchat queried for the feautures.
const
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
...
...
@@ -2148,10 +2145,9 @@
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_unmoderated
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_nonanonymous
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
features_stanza
));
const
view
=
_converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
return
test_utils
.
waitUntil
(()
=>
(
view
.
model
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
CONNECTING
));
}).
then
(()
=>
{
const
view
=
_converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
let
view
=
_converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
await
test_utils
.
waitUntil
(()
=>
(
view
.
model
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
CONNECTING
));
view
=
_converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
expect
(
view
.
model
.
get
(
'
features_fetched
'
)).
toBeTruthy
();
expect
(
view
.
model
.
get
(
'
passwordprotected
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
hidden
'
)).
toBe
(
true
);
...
...
@@ -2160,17 +2156,16 @@
expect
(
view
.
model
.
get
(
'
unmoderated
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
nonanonymous
'
)).
toBe
(
true
);
done
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}));
it
(
"
updates the shown features when the groupchat configuration has changed
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{
'
view_mode
'
:
'
fullscreen
'
},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
var
sent_IQ
,
IQ_id
;
var
sendIQ
=
_converse
.
connection
.
sendIQ
;
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
room
'
,
'
conference.example.org
'
,
'
dummy
'
).
then
(
function
()
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
room
'
,
'
conference.example.org
'
,
'
dummy
'
);
var
view
=
_converse
.
chatboxviews
.
get
(
'
room@conference.example.org
'
);
view
.
model
.
set
({
'
passwordprotected
'
:
false
,
...
...
@@ -2216,18 +2211,17 @@
expect
(
view
.
model
.
get
(
'
open
'
)).
toBe
(
false
);
expect
(
view
.
model
.
get
(
'
membersonly
'
)).
toBe
(
true
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
indicates when a room is no longer anonymous
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
let
sent_IQ
,
IQ_id
;
const
sendIQ
=
_converse
.
connection
.
sendIQ
;
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
coven
'
,
'
chat.shakespeare.lit
'
,
'
some1
'
).
then
(
function
()
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
coven
'
,
'
chat.shakespeare.lit
'
,
'
some1
'
);
spyOn
(
_converse
.
connection
,
'
sendIQ
'
).
and
.
callFake
(
function
(
iq
,
callback
,
errback
)
{
sent_IQ
=
iq
;
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
...
...
@@ -2266,13 +2260,12 @@
expect
(
sizzle
(
'
.message:last
'
,
chat_body
).
pop
().
textContent
)
.
toBe
(
'
This groupchat is now no longer anonymous
'
);
done
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}));
it
(
"
informs users if they have been kicked out of the groupchat
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
/* <presence
* from='harfleur@chat.shakespeare.lit/pistol'
...
...
@@ -2288,8 +2281,7 @@
* </x>
* </presence>
*/
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
)
.
then
(()
=>
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
presence
=
$pres
().
attrs
({
from
:
'
lounge@localhost/dummy
'
,
to
:
'
dummy@localhost/pda
'
,
...
...
@@ -2320,20 +2312,19 @@
expect
(
chat_body
.
querySelector
(
'
.disconnect-msg:nth-child(3)
'
).
textContent
).
toBe
(
'
The reason given is: "Avaunt, you cullion!".
'
);
done
();
});
}));
it
(
"
can be saved to, and retrieved from, browserStorage
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
)
.
then
(()
=>
{
await
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
// We instantiate a new ChatBoxes collection, which by default
// will be empty.
test_utils
.
openControlBox
();
var
newchatboxes
=
new
_converse
.
ChatBoxes
();
const
newchatboxes
=
new
_converse
.
ChatBoxes
();
expect
(
newchatboxes
.
length
).
toEqual
(
0
);
// The chatboxes will then be fetched from browserStorage inside the
// onConnected method
...
...
@@ -2341,8 +2332,8 @@
expect
(
newchatboxes
.
length
).
toEqual
(
2
);
// Check that the chatrooms retrieved from browserStorage
// have the same attributes values as the original ones.
var
attrs
=
[
'
id
'
,
'
box_id
'
,
'
visible
'
];
var
new_attrs
,
old_attrs
;
const
attrs
=
[
'
id
'
,
'
box_id
'
,
'
visible
'
];
let
new_attrs
,
old_attrs
;
for
(
var
i
=
0
;
i
<
attrs
.
length
;
i
++
)
{
new_attrs
=
_
.
map
(
_
.
map
(
newchatboxes
.
models
,
'
attributes
'
),
attrs
[
i
]);
old_attrs
=
_
.
map
(
_
.
map
(
_converse
.
chatboxes
.
models
,
'
attributes
'
),
attrs
[
i
]);
...
...
@@ -2354,7 +2345,6 @@
}
_converse
.
rosterview
.
render
();
done
();
});
}));
it
(
"
can be minimized by clicking a DOM element with class 'toggle-chatbox-button'
"
,
...
...
@@ -2391,10 +2381,9 @@
it
(
"
can be closed again by clicking a DOM element with class 'close-chatbox-button'
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
)
.
then
(()
=>
{
await
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
spyOn
(
view
,
'
close
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
emit
'
);
...
...
@@ -2405,7 +2394,6 @@
expect
(
view
.
model
.
leave
).
toHaveBeenCalled
();
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
chatBoxClosed
'
,
jasmine
.
any
(
Object
));
done
();
});
}));
});
...
...
@@ -2415,10 +2403,10 @@
it
(
"
takes /help to show the available commands
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
).
then
(
function
()
{
var
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
spyOn
(
view
,
'
onMessageSubmitted
'
).
and
.
callThrough
();
var
textarea
=
view
.
el
.
querySelector
(
'
.chat-textarea
'
);
textarea
.
value
=
'
/help This is the groupchat subject
'
;
...
...
@@ -2449,19 +2437,17 @@
expect
(
info_messages
.
pop
().
textContent
).
toBe
(
'
/ban: Ban user from groupchat
'
);
expect
(
info_messages
.
pop
().
textContent
).
toBe
(
'
/admin: Change user
\'
s affiliation to admin
'
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
takes /member to make an occupant a member
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
let
iq_stanza
,
view
;
let
iq_stanza
;
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
muc.localhost
'
,
'
dummy
'
)
.
then
(()
=>
{
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@muc.localhost
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
muc.localhost
'
,
'
dummy
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@muc.localhost
'
);
/* We don't show join/leave messages for existing occupants. We
* know about them because we receive their presences before we
* receive our own.
...
...
@@ -2514,7 +2500,7 @@
`</query>`
+
`</iq>`
);
cons
t
result
=
$iq
({
le
t
result
=
$iq
({
"
xmlns
"
:
"
jabber:client
"
,
"
type
"
:
"
result
"
,
"
to
"
:
"
dummy@localhost/resource
"
,
...
...
@@ -2523,11 +2509,11 @@
});
_converse
.
connection
.
IQ_stanzas
=
[];
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
let
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="lounge@muc.localhost"][type="get"] item[affiliation="member"]
'
)).
pop
()
);
}).
then
(
node
=>
{
iq_stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
`<iq id="
${
iq_stanza
.
getAttribute
(
'
id
'
)}
" to="lounge@muc.localhost" type="get" xmlns="jabber:client">`
+
...
...
@@ -2537,7 +2523,7 @@
`</iq>`
)
expect
(
view
.
model
.
occupants
.
length
).
toBe
(
2
);
const
result
=
$iq
({
result
=
$iq
({
"
xmlns
"
:
"
jabber:client
"
,
"
type
"
:
"
result
"
,
"
to
"
:
"
dummy@localhost/resource
"
,
...
...
@@ -2548,11 +2534,11 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
expect
(
view
.
model
.
occupants
.
length
).
toBe
(
2
);
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="lounge@muc.localhost"][type="get"] item[affiliation="owner"]
'
)).
pop
()
);
}).
then
(
node
=>
{
iq_stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
`<iq id="
${
iq_stanza
.
getAttribute
(
'
id
'
)}
" to="lounge@muc.localhost" type="get" xmlns="jabber:client">`
+
...
...
@@ -2562,7 +2548,7 @@
`</iq>`
)
expect
(
view
.
model
.
occupants
.
length
).
toBe
(
2
);
const
result
=
$iq
({
result
=
$iq
({
"
xmlns
"
:
"
jabber:client
"
,
"
type
"
:
"
result
"
,
"
to
"
:
"
dummy@localhost/resource
"
,
...
...
@@ -2573,12 +2559,12 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
expect
(
view
.
model
.
occupants
.
length
).
toBe
(
2
);
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
_converse
.
connection
.
IQ_stanzas
,
(
iq
)
=>
iq
.
nodeTree
.
querySelector
(
'
iq[to="lounge@muc.localhost"][type="get"] item[affiliation="admin"]
'
)).
pop
()
);
}).
then
(
node
=>
{
const
iq_stanza
=
node
.
nodeTree
;
iq_stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
`<iq id="
${
iq_stanza
.
getAttribute
(
'
id
'
)}
" to="lounge@muc.localhost" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/muc#admin">`
+
...
...
@@ -2587,7 +2573,7 @@
`</iq>`
)
expect
(
view
.
model
.
occupants
.
length
).
toBe
(
2
);
const
result
=
$iq
({
result
=
$iq
({
"
xmlns
"
:
"
jabber:client
"
,
"
type
"
:
"
result
"
,
"
to
"
:
"
dummy@localhost/resource
"
,
...
...
@@ -2596,12 +2582,10 @@
}).
c
(
"
query
"
,
{
"
xmlns
"
:
"
http://jabber.org/protocol/muc#admin
"
})
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
return
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.badge
'
).
length
>
1
);
}).
then
(()
=>
{
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.badge
'
).
length
>
1
);
expect
(
view
.
model
.
occupants
.
length
).
toBe
(
2
);
expect
(
view
.
el
.
querySelectorAll
(
'
.occupant
'
).
length
).
toBe
(
2
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
takes /topic to set the groupchat topic
"
,
...
...
@@ -2661,30 +2645,28 @@
it
(
"
takes /clear to clear messages
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
).
then
(
function
()
{
var
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
spyOn
(
view
,
'
onMessageSubmitted
'
).
and
.
callThrough
();
spyOn
(
view
,
'
clearMessages
'
);
var
textarea
=
view
.
el
.
querySelector
(
'
.chat-textarea
'
)
const
textarea
=
view
.
el
.
querySelector
(
'
.chat-textarea
'
)
textarea
.
value
=
'
/clear
'
;
view
.
keyPressed
({
target
:
textarea
,
preventDefault
:
_
.
noop
,
keyCode
:
13
});
expect
(
view
.
onMessageSubmitted
).
toHaveBeenCalled
();
expect
(
view
.
clearMessages
).
toHaveBeenCalled
();
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
takes /owner to make a user an owner
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
let
sent_IQ
,
IQ_id
;
const
sendIQ
=
_converse
.
connection
.
sendIQ
;
...
...
@@ -2693,8 +2675,8 @@
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
).
then
(
function
()
{
var
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
spyOn
(
view
,
'
onMessageSubmitted
'
).
and
.
callThrough
();
spyOn
(
view
.
model
,
'
setAffiliation
'
).
and
.
callThrough
();
spyOn
(
view
,
'
showErrorMessage
'
).
and
.
callThrough
();
...
...
@@ -2763,13 +2745,12 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
)[
4
].
textContent
).
toBe
(
"
annoyingGuy is now an owner of this groupchat
"
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
takes /ban to ban a user
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
let
sent_IQ
,
IQ_id
;
const
sendIQ
=
_converse
.
connection
.
sendIQ
;
...
...
@@ -2778,8 +2759,7 @@
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
)
.
then
(()
=>
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
spyOn
(
view
,
'
onMessageSubmitted
'
).
and
.
callThrough
();
spyOn
(
view
.
model
,
'
setAffiliation
'
).
and
.
callThrough
();
...
...
@@ -2846,13 +2826,12 @@
view
.
el
.
querySelectorAll
(
'
.chat-info
'
)[
3
].
textContent
).
toBe
(
"
annoyingGuy has been banned from this groupchat
"
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
takes /kick to kick a user
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
let
sent_IQ
,
IQ_id
;
const
sendIQ
=
_converse
.
connection
.
sendIQ
;
...
...
@@ -2861,7 +2840,7 @@
IQ_id
=
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
);
});
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
).
then
(
function
()
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
spyOn
(
view
,
'
onMessageSubmitted
'
).
and
.
callThrough
();
spyOn
(
view
,
'
modifyRole
'
).
and
.
callThrough
();
...
...
@@ -2935,16 +2914,15 @@
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
)[
3
].
textContent
).
toBe
(
"
annoyingGuy has been kicked out
"
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
).
length
).
toBe
(
4
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
takes /op and /deop to make a user a moderator or not
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
).
then
(
function
()
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
sent_IQ
,
IQ_id
;
var
sendIQ
=
_converse
.
connection
.
sendIQ
;
spyOn
(
_converse
.
connection
,
'
sendIQ
'
).
and
.
callFake
(
function
(
iq
,
callback
,
errback
)
{
...
...
@@ -3074,16 +3052,14 @@
info_msgs
=
Array
.
prototype
.
slice
.
call
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
),
0
);
expect
(
info_msgs
.
pop
().
textContent
).
toBe
(
"
trustworthyguy is no longer a moderator
"
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
takes /mute and /voice to mute and unmute a user
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
)
.
then
(()
=>
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
var
sent_IQ
,
IQ_id
;
var
sendIQ
=
_converse
.
connection
.
sendIQ
;
spyOn
(
_converse
.
connection
,
'
sendIQ
'
).
and
.
callFake
(
function
(
iq
,
callback
,
errback
)
{
...
...
@@ -3213,7 +3189,6 @@
info_msgs
=
Array
.
prototype
.
slice
.
call
(
view
.
el
.
querySelectorAll
(
'
.chat-info
'
),
0
);
expect
(
info_msgs
.
pop
().
textContent
).
toBe
(
"
annoyingGuy has been given a voice again
"
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
});
...
...
@@ -3504,10 +3479,9 @@
it
(
"
will first be added to the member list if the groupchat is members only
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
var
sent_IQs
=
[],
IQ_ids
=
[];
let
invitee_jid
,
sent_stanza
,
sent_id
,
view
;
const
sendIQ
=
_converse
.
connection
.
sendIQ
;
const
IQ_stanzas
=
_converse
.
connection
.
IQ_stanzas
;
const
room_jid
=
'
coven@chat.shakespeare.lit
'
;
...
...
@@ -3516,22 +3490,20 @@
IQ_ids
.
push
(
sendIQ
.
bind
(
this
)(
iq
,
callback
,
errback
));
});
_converse
.
api
.
rooms
.
open
(
room_jid
,
{
'
nick
'
:
'
dummy
'
})
.
then
(()
=>
{
return
test_utils
.
waitUntil
(()
=>
_
.
filter
(
await
_converse
.
api
.
rooms
.
open
(
room_jid
,
{
'
nick
'
:
'
dummy
'
});
const
node
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
)).
pop
());
}).
then
(
node
=>
{
// Check that the groupchat queried for the feautures.
cons
t
stanza
=
node
.
nodeTree
;
le
t
stanza
=
node
.
nodeTree
;
expect
(
node
.
toLocaleString
()).
toBe
(
`<iq from="dummy@localhost/resource" id="
${
stanza
.
getAttribute
(
"
id
"
)}
" to="
${
room_jid
}
" type="get" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/disco#info"/>`
+
`</iq>`
);
view
=
_converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
// State that the chat is members-only via the features IQ
var
features_stanza
=
$iq
({
from
:
'
coven@chat.shakespeare.lit
'
,
...
...
@@ -3550,12 +3522,12 @@
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_temporary
'
}).
up
()
.
c
(
'
feature
'
,
{
'
var
'
:
'
muc_membersonly
'
}).
up
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
features_stanza
));
return
test_utils
.
waitUntil
(()
=>
(
view
.
model
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
CONNECTING
));
}).
then
(()
=>
{
await
test_utils
.
waitUntil
(()
=>
(
view
.
model
.
get
(
'
connection_status
'
)
===
converse
.
ROOMSTATUS
.
CONNECTING
));
expect
(
view
.
model
.
get
(
'
membersonly
'
)).
toBeTruthy
();
test_utils
.
createContacts
(
_converse
,
'
current
'
);
let
sent_stanza
,
sent_id
;
spyOn
(
_converse
.
connection
,
'
send
'
).
and
.
callFake
(
function
(
stanza
)
{
if
(
stanza
.
nodeTree
&&
stanza
.
nodeTree
.
nodeName
===
'
message
'
)
{
sent_id
=
stanza
.
nodeTree
.
getAttribute
(
'
id
'
);
...
...
@@ -3563,7 +3535,7 @@
}
});
var
name
=
mock
.
cur_names
[
0
];
invitee_jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
const
invitee_jid
=
name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
var
reason
=
"
Please join this groupchat
"
;
view
.
model
.
directInvite
(
invitee_jid
,
reason
);
...
...
@@ -3644,14 +3616,12 @@
'
jid
'
:
'
crone1@shakespeare.lit
'
,
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
owner_list_stanza
));
return
test_utils
.
waitUntil
(()
=>
IQ_ids
.
length
,
300
);
}).
then
(()
=>
{
return
test_utils
.
waitUntil
(()
=>
_
.
get
(
_
.
filter
(
await
test_utils
.
waitUntil
(()
=>
IQ_ids
.
length
,
300
);
stanza
=
await
test_utils
.
waitUntil
(()
=>
_
.
get
(
_
.
filter
(
IQ_stanzas
,
iq
=>
iq
.
nodeTree
.
querySelector
(
`iq[to="
${
room_jid
}
"] query[xmlns="http://jabber.org/protocol/muc#admin"]`
)).
pop
(),
'
nodeTree
'
));
}).
then
(
stanza
=>
{
expect
(
stanza
.
outerHTML
,
`<iq id="
${
IQ_ids
.
pop
()}
" to="coven@chat.shakespeare.lit" type="set" xmlns="jabber:client">`
+
`<query xmlns="http://jabber.org/protocol/muc#admin">`
+
...
...
@@ -3667,7 +3637,6 @@
`</message>`
);
done
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}));
});
...
...
@@ -3676,9 +3645,9 @@
it
(
"
can be computed in various ways
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openChatRoom
(
_converse
,
'
coven
'
,
'
chat.shakespeare.lit
'
,
'
dummy
'
);
await
test_utils
.
openChatRoom
(
_converse
,
'
coven
'
,
'
chat.shakespeare.lit
'
,
'
dummy
'
);
var
roomview
=
_converse
.
chatboxviews
.
get
(
'
coven@chat.shakespeare.lit
'
);
var
exclude_existing
=
false
;
...
...
@@ -3741,7 +3710,7 @@
it
(
"
contains a link to a modal through which a new chatroom can be created
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openControlBox
();
_converse
.
emit
(
'
rosterContactsFetched
'
);
...
...
@@ -3750,17 +3719,14 @@
roomspanel
.
el
.
querySelector
(
'
.show-add-muc-modal
'
).
click
();
test_utils
.
closeControlBox
(
_converse
);
const
modal
=
roomspanel
.
add_room_modal
;
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
)
.
then
(()
=>
{
await
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
)
spyOn
(
_converse
.
ChatRoom
.
prototype
,
'
getRoomFeatures
'
).
and
.
callFake
(()
=>
Promise
.
resolve
());
roomspanel
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
modal
.
el
.
querySelector
(
'
input[name="chatroom"]
'
).
value
=
'
lounce@muc.localhost
'
;
modal
.
el
.
querySelector
(
'
form input[type="submit"]
'
).
click
();
return
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
);
}).
then
(()
=>
{
await
test_utils
.
waitUntil
(()
=>
_converse
.
chatboxes
.
length
);
expect
(
sizzle
(
'
.chatroom
'
,
_converse
.
el
).
filter
(
u
.
isVisible
).
length
).
toBe
(
1
);
// There should now be an open chatroom
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
contains a link to a modal which can list groupchats publically available on the server
"
,
...
...
@@ -3828,28 +3794,26 @@
it
(
"
shows the number of unread mentions received
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{
'
allow_bookmarks
'
:
false
},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
// XXX: we set `allow_bookmarks` to false, so that the groupchats
// list gets rendered. Otherwise we would have to mock
// the bookmark stanza exchange.
test_utils
.
openControlBox
();
var
roomspanel
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
).
roomspanel
;
const
roomspanel
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
).
roomspanel
;
expect
(
roomspanel
.
el
.
querySelectorAll
(
'
.available-room
'
).
length
).
toBe
(
0
);
let
view
,
nick
;
const
room_jid
=
'
kitchen@conference.shakespeare.lit
'
;
const
message
=
'
fires: Your attention is required
'
;
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
kitchen
'
,
'
conference.shakespeare.lit
'
,
'
fires
'
)
.
then
(()
=>
{
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
kitchen
'
,
'
conference.shakespeare.lit
'
,
'
fires
'
);
expect
(
roomspanel
.
el
.
querySelectorAll
(
'
.available-room
'
).
length
).
toBe
(
1
);
expect
(
roomspanel
.
el
.
querySelectorAll
(
'
.msgs-indicator
'
).
length
).
toBe
(
0
);
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
room_jid
);
view
.
model
.
set
({
'
minimized
'
:
true
});
var
contact_jid
=
mock
.
cur_names
[
5
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
nick
=
mock
.
chatroom_names
[
0
];
const
nick
=
mock
.
chatroom_names
[
0
];
view
.
model
.
onMessage
(
$msg
({
from
:
room_jid
+
'
/
'
+
nick
,
...
...
@@ -3857,8 +3821,7 @@
to
:
'
dummy@localhost
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
());
return
test_utils
.
waitUntil
(()
=>
view
.
model
.
messages
.
length
);
}).
then
(()
=>
{
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
messages
.
length
);
expect
(
roomspanel
.
el
.
querySelectorAll
(
'
.available-room
'
).
length
).
toBe
(
1
);
expect
(
roomspanel
.
el
.
querySelectorAll
(
'
.msgs-indicator
'
).
length
).
toBe
(
1
);
expect
(
roomspanel
.
el
.
querySelector
(
'
.msgs-indicator
'
).
textContent
).
toBe
(
'
1
'
);
...
...
@@ -3869,8 +3832,7 @@
'
to
'
:
'
dummy@localhost
'
,
'
type
'
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
());
return
test_utils
.
waitUntil
(()
=>
view
.
model
.
messages
.
length
>
1
);
}).
then
(()
=>
{
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
messages
.
length
>
1
);
expect
(
roomspanel
.
el
.
querySelectorAll
(
'
.available-room
'
).
length
).
toBe
(
1
);
expect
(
roomspanel
.
el
.
querySelectorAll
(
'
.msgs-indicator
'
).
length
).
toBe
(
1
);
expect
(
roomspanel
.
el
.
querySelector
(
'
.msgs-indicator
'
).
textContent
).
toBe
(
'
2
'
);
...
...
@@ -3878,7 +3840,6 @@
expect
(
roomspanel
.
el
.
querySelectorAll
(
'
.available-room
'
).
length
).
toBe
(
1
);
expect
(
roomspanel
.
el
.
querySelectorAll
(
'
.msgs-indicator
'
).
length
).
toBe
(
0
);
done
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
))
}));
describe
(
"
A Chat Status Notification
"
,
function
()
{
...
...
spec/messages.js
View file @
b91f4884
...
...
@@ -652,7 +652,7 @@
it
(
"
received for a minimized chat box will increment a counter on its header
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
if
(
_converse
.
view_mode
===
'
fullscreen
'
)
{
return
done
();
...
...
@@ -661,14 +661,12 @@
_converse
.
emit
(
'
rosterContactsFetched
'
);
const
contact_name
=
mock
.
cur_names
[
0
];
const
contact_jid
=
contact_name
.
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
let
chatview
,
trimmedview
,
$count
,
trimmed_chatboxes
;
test_utils
.
openControlBox
();
spyOn
(
_converse
,
'
emit
'
).
and
.
callThrough
();
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
)
.
then
(()
=>
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
))
.
then
(()
=>
{
chatview
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
chatview
=
await
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
expect
(
u
.
isVisible
(
chatview
.
el
)).
toBeTruthy
();
expect
(
chatview
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
chatview
.
el
.
querySelector
(
'
.toggle-chatbox-button
'
).
click
();
...
...
@@ -683,16 +681,16 @@
}).
c
(
'
body
'
).
t
(
message
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
_converse
.
chatboxes
.
onMessage
(
msg
);
return
test_utils
.
waitUntil
(()
=>
chatview
.
model
.
messages
.
length
);
}).
then
(()
=>
{
await
test_utils
.
waitUntil
(()
=>
chatview
.
model
.
messages
.
length
);
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
trimmed_chatboxes
=
_converse
.
minimized_chats
;
trimmedview
=
trimmed_chatboxes
.
get
(
contact_jid
);
$count
=
$
(
trimmedview
.
el
).
find
(
'
.message-count
'
);
const
trimmed_chatboxes
=
_converse
.
minimized_chats
;
const
trimmedview
=
trimmed_chatboxes
.
get
(
contact_jid
);
let
count
=
trimmedview
.
el
.
querySelector
(
'
.message-count
'
);
expect
(
u
.
isVisible
(
chatview
.
el
)).
toBeFalsy
();
expect
(
trimmedview
.
model
.
get
(
'
minimized
'
)).
toBeTruthy
();
expect
(
u
.
isVisible
(
$count
[
0
]
)).
toBeTruthy
();
expect
(
$count
.
html
()
).
toBe
(
'
1
'
);
expect
(
u
.
isVisible
(
count
)).
toBeTruthy
();
expect
(
count
.
textContent
).
toBe
(
'
1
'
);
_converse
.
chatboxes
.
onMessage
(
$msg
({
from
:
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
,
...
...
@@ -702,17 +700,16 @@
}).
c
(
'
body
'
).
t
(
'
This message is also sent to a minimized chatbox
'
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
()
);
return
test_utils
.
waitUntil
(()
=>
chatview
.
model
.
messages
.
length
);
}).
then
(()
=>
{
await
test_utils
.
waitUntil
(()
=>
(
chatview
.
model
.
messages
.
length
>
1
));
expect
(
u
.
isVisible
(
chatview
.
el
)).
toBeFalsy
();
expect
(
trimmedview
.
model
.
get
(
'
minimized
'
)).
toBeTruthy
();
$count
=
$
(
trimmedview
.
el
).
find
(
'
.message-count
'
);
expect
(
u
.
isVisible
(
$count
[
0
]
)).
toBeTruthy
();
expect
(
$count
.
html
()
).
toBe
(
'
2
'
);
count
=
trimmedview
.
el
.
querySelector
(
'
.message-count
'
);
expect
(
u
.
isVisible
(
count
)).
toBeTruthy
();
expect
(
count
.
textContent
).
toBe
(
'
2
'
);
trimmedview
.
el
.
querySelector
(
'
.restore-chat
'
).
click
();
expect
(
trimmed_chatboxes
.
keys
().
length
).
toBe
(
0
);
done
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
))
}));
it
(
"
will indicate when it has a time difference of more than a day between it and its predecessor
"
,
...
...
@@ -1918,16 +1915,14 @@
it
(
"
will render images from oob URLs
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
const
base_url
=
'
https://conversejs.org
'
;
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
let
view
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
.
then
(()
=>
{
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
)
const
view
=
await
_converse
.
api
.
chatviews
.
get
(
contact_jid
);
spyOn
(
view
.
model
,
'
sendMessage
'
).
and
.
callThrough
();
const
url
=
base_url
+
"
/logo/conversejs-filled.svg
"
;
...
...
@@ -1939,8 +1934,8 @@
"
<x xmlns='jabber:x:oob'><url>
"
+
url
+
"
</url></x>
"
+
"
</message>
"
).
firstChild
;
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
stanza
));
return
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-content .chat-msg img
'
).
length
,
2000
);
}).
then
(
function
()
{
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-content .chat-msg img
'
).
length
,
2000
);
const
msg
=
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__text
'
);
expect
(
msg
.
outerHTML
).
toEqual
(
'
<div class="chat-msg__text">Have you seen this funny image?</div>
'
);
const
media
=
view
.
el
.
querySelector
(
'
.chat-msg .chat-msg__media
'
);
...
...
@@ -1950,7 +1945,6 @@
`<img class="chat-image img-thumbnail" src="
${
base_url
}
/logo/conversejs-filled.svg">`
+
`</a>`
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
});
});
...
...
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