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
7ae2b48d
Commit
7ae2b48d
authored
Nov 23, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move /me message tests to own file
Test mention inside a /me message
parent
357b6406
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
115 additions
and
91 deletions
+115
-91
karma.conf.js
karma.conf.js
+1
-0
spec/chatbox.js
spec/chatbox.js
+0
-51
spec/me-messages.js
spec/me-messages.js
+114
-0
spec/muc.js
spec/muc.js
+0
-40
No files found.
karma.conf.js
View file @
7ae2b48d
...
...
@@ -49,6 +49,7 @@ module.exports = function(config) {
{
pattern
:
"
spec/corrections.js
"
,
type
:
'
module
'
},
{
pattern
:
"
spec/receipts.js
"
,
type
:
'
module
'
},
{
pattern
:
"
spec/muc_messages.js
"
,
type
:
'
module
'
},
{
pattern
:
"
spec/me-messages.js
"
,
type
:
'
module
'
},
{
pattern
:
"
spec/mentions.js
"
,
type
:
'
module
'
},
{
pattern
:
"
spec/retractions.js
"
,
type
:
'
module
'
},
{
pattern
:
"
spec/muc.js
"
,
type
:
'
module
'
},
...
...
spec/chatbox.js
View file @
7ae2b48d
...
...
@@ -72,57 +72,6 @@ describe("Chatboxes", function () {
}));
it
(
"
supports the /me command
"
,
mock
.
initConverse
([
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
mock
.
waitForRoster
(
_converse
,
'
current
'
);
await
mock
.
waitUntilDiscoConfirmed
(
_converse
,
'
montague.lit
'
,
[],
[
'
vcard-temp
'
]);
await
u
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
));
await
mock
.
openControlBox
(
_converse
);
expect
(
_converse
.
chatboxes
.
length
).
toEqual
(
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.lit
'
;
let
message
=
'
/me is tired
'
;
const
msg
=
$msg
({
from
:
sender_jid
,
to
:
_converse
.
connection
.
jid
,
type
:
'
chat
'
,
id
:
u
.
getUniqueId
()
}).
c
(
'
body
'
).
t
(
message
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
await
_converse
.
handleMessageStanza
(
msg
);
const
view
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-msg__text
'
));
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--action
'
).
length
).
toBe
(
1
);
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
includes
(
'
**Mercutio
'
)).
toBeTruthy
();
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__text
'
).
textContent
).
toBe
(
'
is tired
'
);
message
=
'
/me is as well
'
;
await
mock
.
sendMessage
(
view
,
message
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--action
'
).
length
).
toBe
(
2
);
await
u
.
waitUntil
(()
=>
sizzle
(
'
.chat-msg__author:last
'
,
view
.
el
).
pop
().
textContent
.
trim
()
===
'
**Romeo Montague
'
);
const
last_el
=
sizzle
(
'
.chat-msg__text:last
'
,
view
.
el
).
pop
();
await
u
.
waitUntil
(()
=>
last_el
.
textContent
===
'
is as well
'
);
expect
(
u
.
hasClass
(
'
chat-msg--followup
'
,
last_el
)).
toBe
(
false
);
// Check that /me messages after a normal message don't
// get the 'chat-msg--followup' class.
message
=
'
This a normal message
'
;
await
mock
.
sendMessage
(
view
,
message
);
const
msg_txt_sel
=
'
converse-chat-message:last-child .chat-msg__text
'
;
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
msg_txt_sel
).
textContent
.
trim
()
===
message
);
let
el
=
view
.
el
.
querySelector
(
'
converse-chat-message:last-child .chat-msg__body
'
);
expect
(
u
.
hasClass
(
'
chat-msg--followup
'
,
el
)).
toBeFalsy
();
message
=
'
/me wrote a 3rd person message
'
;
await
mock
.
sendMessage
(
view
,
message
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
msg_txt_sel
).
textContent
.
trim
()
===
message
.
replace
(
'
/me
'
,
''
));
el
=
view
.
el
.
querySelector
(
'
converse-chat-message:last-child .chat-msg__body
'
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--action
'
).
length
).
toBe
(
3
);
expect
(
sizzle
(
'
.chat-msg__text:last
'
,
view
.
el
).
pop
().
textContent
).
toBe
(
'
wrote a 3rd person message
'
);
expect
(
u
.
isVisible
(
sizzle
(
'
.chat-msg__author:last
'
,
view
.
el
).
pop
())).
toBeTruthy
();
done
();
}));
it
(
"
is created when you click on a roster item
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
...
...
spec/me-messages.js
0 → 100644
View file @
7ae2b48d
/*global mock, converse */
const
{
u
,
sizzle
,
$msg
}
=
converse
.
env
;
describe
(
"
A Groupchat Message
"
,
function
()
{
fit
(
"
supports the /me command
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
mock
.
waitUntilDiscoConfirmed
(
_converse
,
'
montague.lit
'
,
[],
[
'
vcard-temp
'
]);
await
u
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
));
await
mock
.
waitForRoster
(
_converse
,
'
current
'
);
await
mock
.
openAndEnterChatRoom
(
_converse
,
'
lounge@montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@montague.lit
'
);
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
let
message
=
'
/me is tired
'
;
const
nick
=
mock
.
chatroom_names
[
0
];
let
msg
=
$msg
({
'
from
'
:
'
lounge@montague.lit/
'
+
nick
,
'
id
'
:
u
.
getUniqueId
(),
'
to
'
:
'
romeo@montague.lit
'
,
'
type
'
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
();
await
view
.
model
.
handleMessageStanza
(
msg
);
await
u
.
waitUntil
(()
=>
sizzle
(
'
.chat-msg:last .chat-msg__text
'
,
view
.
content
).
pop
());
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
includes
(
'
**Dyon van de Wege
'
)).
toBeTruthy
();
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__text
'
).
textContent
.
trim
()).
toBe
(
'
is tired
'
);
message
=
'
/me is as well
'
;
msg
=
$msg
({
from
:
'
lounge@montague.lit/Romeo Montague
'
,
id
:
u
.
getUniqueId
(),
to
:
'
romeo@montague.lit
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
();
await
view
.
model
.
handleMessageStanza
(
msg
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
===
2
);
expect
(
sizzle
(
'
.chat-msg__author:last
'
,
view
.
el
).
pop
().
textContent
.
includes
(
'
**Romeo Montague
'
)).
toBeTruthy
();
expect
(
sizzle
(
'
.chat-msg__text:last
'
,
view
.
el
).
pop
().
textContent
.
trim
()).
toBe
(
'
is as well
'
);
// Check rendering of a mention inside a me message
const
msg_text
=
"
/me mentions romeo
"
;
msg
=
$msg
({
from
:
'
lounge@montague.lit/gibson
'
,
id
:
u
.
getUniqueId
(),
to
:
'
romeo@montague.lit
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
msg_text
).
up
()
.
c
(
'
reference
'
,
{
'
xmlns
'
:
'
urn:xmpp:reference:0
'
,
'
begin
'
:
'
13
'
,
'
end
'
:
'
19
'
,
'
type
'
:
'
mention
'
,
'
uri
'
:
'
xmpp:romeo@montague.lit
'
}).
nodeTree
;
await
view
.
model
.
handleMessageStanza
(
msg
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-msg__text
'
).
length
===
3
);
await
u
.
waitUntil
(()
=>
sizzle
(
'
.chat-msg__text:last
'
,
view
.
el
).
pop
().
innerHTML
.
replace
(
/<!---->/g
,
''
)
===
'
mentions <span class="mention mention--self badge badge-info">romeo</span>
'
);
done
();
}));
});
describe
(
"
A Message
"
,
function
()
{
it
(
"
supports the /me command
"
,
mock
.
initConverse
([
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
mock
.
waitForRoster
(
_converse
,
'
current
'
);
await
mock
.
waitUntilDiscoConfirmed
(
_converse
,
'
montague.lit
'
,
[],
[
'
vcard-temp
'
]);
await
u
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
));
await
mock
.
openControlBox
(
_converse
);
expect
(
_converse
.
chatboxes
.
length
).
toEqual
(
1
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.lit
'
;
let
message
=
'
/me is tired
'
;
const
msg
=
$msg
({
from
:
sender_jid
,
to
:
_converse
.
connection
.
jid
,
type
:
'
chat
'
,
id
:
u
.
getUniqueId
()
}).
c
(
'
body
'
).
t
(
message
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
();
await
_converse
.
handleMessageStanza
(
msg
);
const
view
=
_converse
.
chatboxviews
.
get
(
sender_jid
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.chat-msg__text
'
));
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--action
'
).
length
).
toBe
(
1
);
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
.
includes
(
'
**Mercutio
'
)).
toBeTruthy
();
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__text
'
).
textContent
).
toBe
(
'
is tired
'
);
message
=
'
/me is as well
'
;
await
mock
.
sendMessage
(
view
,
message
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--action
'
).
length
).
toBe
(
2
);
await
u
.
waitUntil
(()
=>
sizzle
(
'
.chat-msg__author:last
'
,
view
.
el
).
pop
().
textContent
.
trim
()
===
'
**Romeo Montague
'
);
const
last_el
=
sizzle
(
'
.chat-msg__text:last
'
,
view
.
el
).
pop
();
await
u
.
waitUntil
(()
=>
last_el
.
textContent
===
'
is as well
'
);
expect
(
u
.
hasClass
(
'
chat-msg--followup
'
,
last_el
)).
toBe
(
false
);
// Check that /me messages after a normal message don't
// get the 'chat-msg--followup' class.
message
=
'
This a normal message
'
;
await
mock
.
sendMessage
(
view
,
message
);
const
msg_txt_sel
=
'
converse-chat-message:last-child .chat-msg__text
'
;
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
msg_txt_sel
).
textContent
.
trim
()
===
message
);
let
el
=
view
.
el
.
querySelector
(
'
converse-chat-message:last-child .chat-msg__body
'
);
expect
(
u
.
hasClass
(
'
chat-msg--followup
'
,
el
)).
toBeFalsy
();
message
=
'
/me wrote a 3rd person message
'
;
await
mock
.
sendMessage
(
view
,
message
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
msg_txt_sel
).
textContent
.
trim
()
===
message
.
replace
(
'
/me
'
,
''
));
el
=
view
.
el
.
querySelector
(
'
converse-chat-message:last-child .chat-msg__body
'
);
expect
(
view
.
el
.
querySelectorAll
(
'
.chat-msg--action
'
).
length
).
toBe
(
3
);
expect
(
sizzle
(
'
.chat-msg__text:last
'
,
view
.
el
).
pop
().
textContent
).
toBe
(
'
wrote a 3rd person message
'
);
expect
(
u
.
isVisible
(
sizzle
(
'
.chat-msg__author:last
'
,
view
.
el
).
pop
())).
toBeTruthy
();
done
();
}));
});
spec/muc.js
View file @
7ae2b48d
...
...
@@ -1400,46 +1400,6 @@ describe("Groupchats", function () {
done
();
}));
it
(
"
supports the /me command
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
],
{},
async
function
(
done
,
_converse
)
{
await
mock
.
waitUntilDiscoConfirmed
(
_converse
,
'
montague.lit
'
,
[],
[
'
vcard-temp
'
]);
await
u
.
waitUntil
(()
=>
_converse
.
xmppstatus
.
vcard
.
get
(
'
fullname
'
));
await
mock
.
waitForRoster
(
_converse
,
'
current
'
);
await
mock
.
openAndEnterChatRoom
(
_converse
,
'
lounge@montague.lit
'
,
'
romeo
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@montague.lit
'
);
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
let
message
=
'
/me is tired
'
;
const
nick
=
mock
.
chatroom_names
[
0
];
let
msg
=
$msg
({
'
from
'
:
'
lounge@montague.lit/
'
+
nick
,
'
id
'
:
u
.
getUniqueId
(),
'
to
'
:
'
romeo@montague.lit
'
,
'
type
'
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
();
await
view
.
model
.
handleMessageStanza
(
msg
);
await
u
.
waitUntil
(()
=>
sizzle
(
'
.chat-msg:last .chat-msg__text
'
,
view
.
content
).
pop
());
expect
(
_
.
includes
(
view
.
el
.
querySelector
(
'
.chat-msg__author
'
).
textContent
,
'
**Dyon van de Wege
'
)).
toBeTruthy
();
expect
(
view
.
el
.
querySelector
(
'
.chat-msg__text
'
).
textContent
.
trim
()).
toBe
(
'
is tired
'
);
message
=
'
/me is as well
'
;
msg
=
$msg
({
from
:
'
lounge@montague.lit/Romeo Montague
'
,
id
:
u
.
getUniqueId
(),
to
:
'
romeo@montague.lit
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
message
).
tree
();
await
view
.
model
.
handleMessageStanza
(
msg
);
await
u
.
waitUntil
(()
=>
view
.
el
.
querySelectorAll
(
'
.chat-msg
'
).
length
===
2
);
expect
(
sizzle
(
'
.chat-msg__author:last
'
,
view
.
el
).
pop
().
textContent
.
includes
(
'
**Romeo Montague
'
)).
toBeTruthy
();
expect
(
sizzle
(
'
.chat-msg__text:last
'
,
view
.
el
).
pop
().
textContent
.
trim
()).
toBe
(
'
is as well
'
);
done
();
}));
it
(
"
can be configured if you're its owner
"
,
mock
.
initConverse
(
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
...
...
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