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
078281d0
Commit
078281d0
authored
Dec 17, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for configuring a MUC
parent
82bfe66c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
176 additions
and
44 deletions
+176
-44
.eslintrc.json
.eslintrc.json
+1
-1
spec/chatroom.js
spec/chatroom.js
+175
-43
No files found.
.eslintrc.json
View file @
078281d0
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
"rules"
:
{
"rules"
:
{
"lodash/prefer-lodash-method"
:
[
2
,
{
"lodash/prefer-lodash-method"
:
[
2
,
{
"ignoreMethods"
:
[
"ignoreMethods"
:
[
"find"
,
"endsWith"
,
"startsWith"
,
"filter"
,
"reduce"
,
"isArray"
,
"create"
,
"
keys"
,
"
find"
,
"endsWith"
,
"startsWith"
,
"filter"
,
"reduce"
,
"isArray"
,
"create"
,
"map"
,
"replace"
,
"toLower"
,
"split"
,
"trim"
,
"forEach"
,
"toUpperCase"
,
"includes"
"map"
,
"replace"
,
"toLower"
,
"split"
,
"trim"
,
"forEach"
,
"toUpperCase"
,
"includes"
]
]
}],
}],
...
...
spec/chatroom.js
View file @
078281d0
...
@@ -2156,53 +2156,185 @@
...
@@ -2156,53 +2156,185 @@
null
,
[
'
rosterGroupsFetched
'
],
{
'
view_mode
'
:
'
fullscreen
'
},
null
,
[
'
rosterGroupsFetched
'
],
{
'
view_mode
'
:
'
fullscreen
'
},
async
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
var
sent_IQ
,
IQ_id
;
let
features
=
[
var
sendIQ
=
_converse
.
connection
.
sendIQ
;
'
http://jabber.org/protocol/muc
'
,
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
room
'
,
'
conference.example.org
'
,
'
dummy
'
);
'
jabber:iq:register
'
,
var
view
=
_converse
.
chatboxviews
.
get
(
'
room@conference.example.org
'
);
'
muc_passwordprotected
'
,
view
.
model
.
set
({
'
muc_publicroom
'
,
'
passwordprotected
'
:
false
,
'
muc_temporary
'
,
'
unsecured
'
:
true
,
'
muc_open
'
,
'
hidden
'
:
false
,
'
muc_unmoderated
'
,
'
public
'
:
true
,
'
muc_nonanonymous
'
'
membersonly
'
:
false
,
];
'
open
'
:
true
,
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
room
'
,
'
conference.example.org
'
,
'
dummy
'
,
features
);
'
persistent
'
:
false
,
const
jid
=
'
room@conference.example.org
'
;
'
temporary
'
:
true
,
const
chatroomview
=
_converse
.
chatboxviews
.
get
(
jid
);
'
nonanonymous
'
:
true
,
let
features_list
=
chatroomview
.
el
.
querySelector
(
'
.features-list
'
);
'
semianonymous
'
:
false
,
let
features_shown
=
features_list
.
textContent
.
split
(
'
\n
'
).
map
(
s
=>
s
.
trim
()).
filter
(
s
=>
s
);
'
moderated
'
:
false
,
expect
(
_
.
difference
([
"
Password protected
"
,
"
Open
"
,
"
Temporary
"
,
"
Not anonymous
"
,
"
Not moderated
"
],
features_shown
).
length
).
toBe
(
0
);
'
unmoderated
'
:
true
expect
(
chatroomview
.
model
.
get
(
'
hidden
'
)).
toBe
(
false
);
expect
(
chatroomview
.
model
.
get
(
'
mam_enabled
'
)).
toBe
(
false
);
expect
(
chatroomview
.
model
.
get
(
'
membersonly
'
)).
toBe
(
false
);
expect
(
chatroomview
.
model
.
get
(
'
moderated
'
)).
toBe
(
false
);
expect
(
chatroomview
.
model
.
get
(
'
nonanonymous
'
)).
toBe
(
true
);
expect
(
chatroomview
.
model
.
get
(
'
open
'
)).
toBe
(
true
);
expect
(
chatroomview
.
model
.
get
(
'
passwordprotected
'
)).
toBe
(
true
);
expect
(
chatroomview
.
model
.
get
(
'
persistent
'
)).
toBe
(
false
);
expect
(
chatroomview
.
model
.
get
(
'
publicroom
'
)).
toBe
(
true
);
expect
(
chatroomview
.
model
.
get
(
'
semianonymous
'
)).
toBe
(
false
);
expect
(
chatroomview
.
model
.
get
(
'
temporary
'
)).
toBe
(
true
);
expect
(
chatroomview
.
model
.
get
(
'
unmoderated
'
)).
toBe
(
true
);
expect
(
chatroomview
.
model
.
get
(
'
unsecured
'
)).
toBe
(
false
);
chatroomview
.
el
.
querySelector
(
'
.configure-chatroom-button
'
).
click
();
const
IQs
=
_converse
.
connection
.
IQ_stanzas
;
let
iq
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQs
,
iq
=>
iq
.
nodeTree
.
querySelector
(
`iq[to="
${
jid
}
"] query[xmlns="
${
Strophe
.
NS
.
MUC_OWNER
}
"]`
)).
pop
());
const
response
=
Strophe
.
xmlHtmlNode
(
`<iq xmlns="jabber:client"
type="result"
to="dummy@localhost/pda"
from="room@conference.example.org" id="
${
iq
.
nodeTree
.
getAttribute
(
'
id
'
)}
">
<query xmlns="http://jabber.org/protocol/muc#owner">
<x xmlns="jabber:x:data" type="form">
<title>Configuration for room@conference.example.org</title>
<instructions>Complete and submit this form to configure the room.</instructions>
<field var="FORM_TYPE" type="hidden">
<value>http://jabber.org/protocol/muc#roomconfig</value>
</field>
<field type="fixed">
<value>Room information</value>
</field>
<field var="muc#roomconfig_roomname" type="text-single" label="Title">
<value>Example Room</value>
</field>
<field var="muc#roomconfig_roomdesc" type="text-single" label="Description">
<desc>A brief description of the room</desc>
<value>This room is used in tests</value>
</field>
<field var="muc#roomconfig_lang" type="text-single" label="Language tag for room (e.g. 'en', 'de', 'fr' etc.)">
<desc>Indicate the primary language spoken in this room</desc>
<value>en</value>
</field>
<field var="muc#roomconfig_persistentroom" type="boolean" label="Persistent (room should remain even when it is empty)">
<desc>Rooms are automatically deleted when they are empty, unless this option is enabled</desc>
<value>1</value>
</field>
<field var="muc#roomconfig_publicroom" type="boolean" label="Include room information in public lists">
<desc>Enable this to allow people to find the room</desc>
<value>1</value>
</field>
<field type="fixed"><value>Access to the room</value></field>
<field var="muc#roomconfig_roomsecret" type="text-private" label="Password"><value/></field>
<field var="muc#roomconfig_membersonly" type="boolean" label="Only allow members to join">
<desc>Enable this to only allow access for room owners, admins and members</desc>
</field>
<field var="{http://prosody.im/protocol/muc}roomconfig_allowmemberinvites" type="boolean" label="Allow members to invite new members"/>
<field type="fixed"><value>Permissions in the room</value>
</field>
<field var="muc#roomconfig_changesubject" type="boolean" label="Allow anyone to set the room's subject">
<desc>Choose whether anyone, or only moderators, may set the room's subject</desc>
</field>
<field var="muc#roomconfig_moderatedroom" type="boolean" label="Moderated (require permission to speak)">
<desc>In moderated rooms occupants must be given permission to speak by a room moderator</desc>
</field>
<field var="muc#roomconfig_whois" type="list-single" label="Addresses (JIDs) of room occupants may be viewed by:">
<option label="Moderators only"><value>moderators</value></option>
<option label="Anyone"><value>anyone</value></option>
<value>anyone</value>
</field>
<field type="fixed"><value>Other options</value></field>
<field var="muc#roomconfig_historylength" type="text-single" label="Maximum number of history messages returned by room">
<desc>Specify the maximum number of previous messages that should be sent to users when they join the room</desc>
<value>50</value>
</field>
<field var="muc#roomconfig_defaulthistorymessages" type="text-single" label="Default number of history messages returned by room">
<desc>Specify the number of previous messages sent to new users when they join the room</desc>
<value>20</value>
</field>
</x>
</query>
</iq>`
);
const
response_el
=
response
.
firstElementChild
;
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
response_el
));
const
el
=
await
test_utils
.
waitUntil
(()
=>
document
.
querySelector
(
'
.chatroom-form legend
'
));
expect
(
el
.
textContent
).
toBe
(
"
Configuration for room@conference.example.org
"
);
sizzle
(
'
[name="muc#roomconfig_membersonly"]
'
,
chatroomview
.
el
).
pop
().
click
();
chatroomview
.
el
.
querySelector
(
'
.btn-primary
'
).
click
();
iq
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
IQs
,
iq
=>
u
.
matchesSelector
(
iq
.
nodeTree
,
`iq[to="
${
jid
}
"][type="set"]`
)).
pop
());
const
result
=
$iq
({
"
xmlns
"
:
"
jabber:client
"
,
"
type
"
:
"
result
"
,
"
to
"
:
"
dummy@localhost/resource
"
,
"
from
"
:
"
lounge@muc.localhost
"
,
"
id
"
:
iq
.
nodeTree
.
getAttribute
(
'
id
'
)
});
});
expect
(
view
.
model
.
get
(
'
persistent
'
)).
toBe
(
false
);
expect
(
view
.
model
.
get
(
'
temporary
'
)).
toBe
(
true
);
view
.
model
.
set
({
'
persistent
'
:
true
});
expect
(
view
.
model
.
get
(
'
persistent
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
temporary
'
)).
toBe
(
false
);
expect
(
view
.
model
.
get
(
'
unsecured
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
passwordprotected
'
)).
toBe
(
false
);
view
.
model
.
set
({
'
passwordprotected
'
:
true
});
expect
(
view
.
model
.
get
(
'
unsecured
'
)).
toBe
(
false
);
expect
(
view
.
model
.
get
(
'
passwordprotected
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
unmoderated
'
)).
toBe
(
true
);
IQs
.
length
=
0
;
// Empty the array
expect
(
view
.
model
.
get
(
'
moderated
'
)).
toBe
(
false
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
result
));
view
.
model
.
set
({
'
moderated
'
:
true
});
expect
(
view
.
model
.
get
(
'
unmoderated
'
)).
toBe
(
false
);
expect
(
view
.
model
.
get
(
'
moderated
'
)).
toBe
(
true
);
expect
(
view
.
model
.
get
(
'
nonanonymous
'
)).
toBe
(
true
);
iq
=
await
test_utils
.
waitUntil
(()
=>
_
.
filter
(
expect
(
view
.
model
.
get
(
'
semianonymous
'
)).
toBe
(
false
);
IQs
,
view
.
model
.
set
({
'
nonanonymous
'
:
false
});
iq
=>
iq
.
nodeTree
.
querySelector
(
expect
(
view
.
model
.
get
(
'
nonanonymous
'
)).
toBe
(
false
);
`iq[to="
${
jid
}
"] query[xmlns="http://jabber.org/protocol/disco#info"]`
expect
(
view
.
model
.
get
(
'
semianonymous
'
)).
toBe
(
true
);
)).
pop
()
);
expect
(
view
.
model
.
get
(
'
open
'
)).
toBe
(
true
);
const
features_stanza
=
$iq
({
expect
(
view
.
model
.
get
(
'
membersonly
'
)).
toBe
(
false
);
'
from
'
:
jid
,
view
.
model
.
set
({
'
membersonly
'
:
true
});
'
id
'
:
iq
.
nodeTree
.
getAttribute
(
'
id
'
),
expect
(
view
.
model
.
get
(
'
open
'
)).
toBe
(
false
);
'
to
'
:
'
dummy@localhost/desktop
'
,
expect
(
view
.
model
.
get
(
'
membersonly
'
)).
toBe
(
true
);
'
type
'
:
'
result
'
}).
c
(
'
query
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/disco#info
'
})
.
c
(
'
identity
'
,
{
'
category
'
:
'
conference
'
,
'
name
'
:
'
Room
'
,
'
type
'
:
'
text
'
}).
up
();
features
=
[
'
http://jabber.org/protocol/muc
'
,
'
jabber:iq:register
'
,
'
muc_passwordprotected
'
,
'
muc_hidden
'
,
'
muc_temporary
'
,
'
muc_open
'
,
'
muc_unmoderated
'
,
'
muc_nonanonymous
'
];
features
.
forEach
(
f
=>
features_stanza
.
c
(
'
feature
'
,
{
'
var
'
:
f
}).
up
());
features_stanza
.
c
(
'
x
'
,
{
'
xmlns
'
:
'
jabber:x:data
'
,
'
type
'
:
'
result
'
})
.
c
(
'
field
'
,
{
'
var
'
:
'
FORM_TYPE
'
,
'
type
'
:
'
hidden
'
})
.
c
(
'
value
'
).
t
(
'
http://jabber.org/protocol/muc#roominfo
'
).
up
().
up
()
.
c
(
'
field
'
,
{
'
type
'
:
'
text-single
'
,
'
var
'
:
'
muc#roominfo_description
'
,
'
label
'
:
'
Description
'
})
.
c
(
'
value
'
).
t
(
'
This is the description
'
).
up
().
up
()
.
c
(
'
field
'
,
{
'
type
'
:
'
text-single
'
,
'
var
'
:
'
muc#roominfo_occupants
'
,
'
label
'
:
'
Number of occupants
'
})
.
c
(
'
value
'
).
t
(
0
);
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
features_stanza
));
spyOn
(
chatroomview
.
occupantsview
,
'
renderRoomFeatures
'
).
and
.
callThrough
();
await
test_utils
.
waitUntil
(()
=>
chatroomview
.
occupantsview
.
renderRoomFeatures
.
calls
.
count
());
features_list
=
chatroomview
.
el
.
querySelector
(
'
.features-list
'
);
features_shown
=
features_list
.
textContent
.
split
(
'
\n
'
).
map
(
s
=>
s
.
trim
()).
filter
(
s
=>
s
);
expect
(
_
.
difference
([
"
Password protected
"
,
"
Hidden
"
,
"
Open
"
,
"
Temporary
"
,
"
Not anonymous
"
,
"
Not moderated
"
],
features_shown
).
length
).
toBe
(
0
);
expect
(
chatroomview
.
model
.
get
(
'
hidden
'
)).
toBe
(
true
);
expect
(
chatroomview
.
model
.
get
(
'
mam_enabled
'
)).
toBe
(
false
);
expect
(
chatroomview
.
model
.
get
(
'
membersonly
'
)).
toBe
(
false
);
expect
(
chatroomview
.
model
.
get
(
'
moderated
'
)).
toBe
(
false
);
expect
(
chatroomview
.
model
.
get
(
'
nonanonymous
'
)).
toBe
(
true
);
expect
(
chatroomview
.
model
.
get
(
'
open
'
)).
toBe
(
true
);
expect
(
chatroomview
.
model
.
get
(
'
passwordprotected
'
)).
toBe
(
true
);
expect
(
chatroomview
.
model
.
get
(
'
persistent
'
)).
toBe
(
false
);
expect
(
chatroomview
.
model
.
get
(
'
publicroom
'
)).
toBe
(
false
);
expect
(
chatroomview
.
model
.
get
(
'
semianonymous
'
)).
toBe
(
false
);
expect
(
chatroomview
.
model
.
get
(
'
temporary
'
)).
toBe
(
true
);
expect
(
chatroomview
.
model
.
get
(
'
unmoderated
'
)).
toBe
(
true
);
expect
(
chatroomview
.
model
.
get
(
'
unsecured
'
)).
toBe
(
false
);
done
();
done
();
}));
}));
...
...
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