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
f2c14557
Commit
f2c14557
authored
Oct 22, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bump waiting time for room opened via modal in test utils
Convert more promise-based tests to async/await
parent
0d3e94c6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
153 additions
and
162 deletions
+153
-162
spec/chatroom.js
spec/chatroom.js
+143
-147
tests/utils.js
tests/utils.js
+10
-15
No files found.
spec/chatroom.js
View file @
f2c14557
...
...
@@ -3197,38 +3197,36 @@
it
(
"
will use the nickname set in the global settings if the user doesn't have a VCard nickname
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{
'
nickname
'
:
'
Benedict-Cucumberpatch
'
},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openChatRoomViaModal
(
_converse
,
'
problematic@muc.localhost
'
)
.
then
(
function
()
{
const
view
=
_converse
.
chatboxviews
.
get
(
'
problematic@muc.localhost
'
);
await
test_utils
.
openChatRoomViaModal
(
_converse
,
'
roomy@muc.localhost
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
roomy@muc.localhost
'
);
expect
(
view
.
model
.
get
(
'
nick
'
)).
toBe
(
'
Benedict-Cucumberpatch
'
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
will show an error message if the groupchat requires a password
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openChatRoomViaModal
(
_converse
,
'
problematic@muc.localhost
'
,
'
dummy
'
)
.
then
(
function
()
{
var
view
=
_converse
.
chatboxviews
.
get
(
'
problematic@muc.localhost
'
);
const
groupchat_jid
=
'
protected
'
;
await
test_utils
.
openChatRoomViaModal
(
_converse
,
groupchat_jid
,
'
dummy
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
groupchat_jid
);
spyOn
(
view
,
'
renderPasswordForm
'
).
and
.
callThrough
();
var
presence
=
$pres
().
attrs
({
from
:
'
problematic@muc.localhost/dummy
'
,
id
:
'
n13mt3l
'
,
to
:
'
dummy@localhost/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
'
from
'
:
`
${
groupchat_jid
}
/dummy`
,
'
id
'
:
u
.
getUniqueId
()
,
'
to
'
:
'
dummy@localhost/pda
'
,
'
type
'
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
lounge@localhost
'
,
type
:
'
auth
'
})
.
c
(
'
not-authorized
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
});
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
var
chat_body
=
view
.
el
.
querySelector
(
'
.chatroom-body
'
);
const
chat_body
=
view
.
el
.
querySelector
(
'
.chatroom-body
'
);
expect
(
view
.
renderPasswordForm
).
toHaveBeenCalled
();
expect
(
chat_body
.
querySelectorAll
(
'
form.chatroom-form
'
).
length
).
toBe
(
1
);
expect
(
chat_body
.
querySelector
(
'
legend
'
).
textContent
)
...
...
@@ -3236,78 +3234,78 @@
// Let's submit the form
spyOn
(
view
,
'
join
'
);
var
input_el
=
view
.
el
.
querySelector
(
'
[name="password"]
'
);
const
input_el
=
view
.
el
.
querySelector
(
'
[name="password"]
'
);
input_el
.
value
=
'
secret
'
;
view
.
el
.
querySelector
(
'
input[type=submit]
'
).
click
();
expect
(
view
.
join
).
toHaveBeenCalledWith
(
'
dummy
'
,
'
secret
'
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
will show an error message if the groupchat is members-only and the user not included
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openChatRoomViaModal
(
_converse
,
'
problematic@muc.localhost
'
,
'
dummy
'
)
.
then
(
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
problematic@muc.localhost/dummy
'
,
id
:
'
n13mt3l
'
,
to
:
'
dummy@localhost/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
const
groupchat_jid
=
'
members-only@muc.localhost
'
await
test_utils
.
openChatRoomViaModal
(
_converse
,
groupchat_jid
,
'
dummy
'
);
const
presence
=
$pres
().
attrs
({
from
:
`
${
groupchat_jid
}
/dummy`
,
id
:
u
.
getUniqueId
()
,
to
:
'
dummy@localhost/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
lounge@localhost
'
,
type
:
'
auth
'
})
.
c
(
'
registration-required
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
_converse
.
chatboxviews
.
get
(
'
problematic@muc.localhost
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
groupchat_jid
);
spyOn
(
view
,
'
showErrorMessage
'
).
and
.
callThrough
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
view
.
el
.
querySelector
(
'
.chatroom-body .disconnect-container .disconnect-msg:last-child
'
).
textContent
)
.
toBe
(
'
You are not on the member list of this groupchat.
'
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
will show an error message if the user has been banned
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openChatRoomViaModal
(
_converse
,
'
problematic@muc.localhost
'
,
'
dummy
'
)
.
then
(
function
()
{
var
presence
=
$pres
().
attrs
({
from
:
'
problematic@muc.localhost/dummy
'
,
id
:
'
n13mt3l
'
,
to
:
'
dummy@localhost/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
const
groupchat_jid
=
'
off-limits@muc.localhost
'
await
test_utils
.
openChatRoomViaModal
(
_converse
,
groupchat_jid
,
'
dummy
'
);
const
presence
=
$pres
().
attrs
({
from
:
`
${
groupchat_jid
}
/dummy`
,
id
:
u
.
getUniqueId
()
,
to
:
'
dummy@localhost/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
lounge@localhost
'
,
type
:
'
auth
'
})
.
c
(
'
forbidden
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
_converse
.
chatboxviews
.
get
(
'
problematic@muc.localhost
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
groupchat_jid
);
spyOn
(
view
,
'
showErrorMessage
'
).
and
.
callThrough
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
view
.
el
.
querySelector
(
'
.chatroom-body .disconnect-container .disconnect-msg:last-child
'
).
textContent
)
.
toBe
(
'
You have been banned from this groupchat.
'
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
will render a nickname form if a nickname conflict happens and muc_nickname_from_jid=false
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openChatRoomViaModal
(
_converse
,
'
problematic@muc.localhost
'
,
'
dummy
'
)
.
then
(
function
()
{
const
groupchat_jid
=
'
conflicted@muc.localhost
'
;
await
test_utils
.
openChatRoomViaModal
(
_converse
,
groupchat_jid
,
'
dummy
'
);
var
presence
=
$pres
().
attrs
({
from
:
'
problematic@muc.localhost/dummy
'
,
id
:
'
n13mt3l
'
,
to
:
'
dummy@localhost/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
from
:
`
${
groupchat_jid
}
/dummy`
,
id
:
u
.
getUniqueId
()
,
to
:
'
dummy@localhost/pda
'
,
type
:
'
error
'
})
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
lounge@localhost
'
,
type
:
'
cancel
'
})
.
c
(
'
conflict
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
_converse
.
chatboxviews
.
get
(
'
problematic@muc.localhost
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
groupchat_jid
);
spyOn
(
view
,
'
showErrorMessage
'
).
and
.
callThrough
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
sizzle
(
'
.chatroom-body form.chatroom-form label:first
'
,
view
.
el
).
pop
().
textContent
)
...
...
@@ -3317,16 +3315,15 @@
input
.
value
=
'
nicky
'
;
view
.
el
.
querySelector
(
'
input[type=submit]
'
).
click
();
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
will automatically choose a new nickname if a nickname conflict happens and muc_nickname_from_jid=true
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
openChatRoomViaModal
(
_converse
,
'
problematic@muc.localhost
'
,
'
dummy
'
)
.
then
(
function
()
{
const
groupchat_jid
=
'
conflicting@muc.localhost
'
await
test_utils
.
openChatRoomViaModal
(
_converse
,
groupchat_jid
,
'
dummy
'
);
/* <presence
* from='coven@chat.shakespeare.lit/thirdwitch'
* id='n13mt3l'
...
...
@@ -3340,18 +3337,18 @@
*/
_converse
.
muc_nickname_from_jid
=
true
;
var
attrs
=
{
from
:
'
problematic@muc.localhost/dummy
'
,
to
:
'
dummy@localhost/pda
'
,
type
:
'
error
'
const
attrs
=
{
'
from
'
:
`
${
groupchat_jid
}
/dummy`
,
'
id
'
:
u
.
getUniqueId
(),
'
to
'
:
'
dummy@localhost/pda
'
,
'
type
'
:
'
error
'
};
attrs
.
id
=
new
Date
().
getTime
();
var
presence
=
$pres
().
attrs
(
attrs
)
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
problematic@muc.localhost
'
,
type
:
'
cancel
'
})
.
c
(
'
conflict
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
let
presence
=
$pres
().
attrs
(
attrs
)
.
c
(
'
x
'
).
attrs
({
'
xmlns
'
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
'
by
'
:
groupchat_jid
,
'
type
'
:
'
cancel
'
})
.
c
(
'
conflict
'
).
attrs
({
'
xmlns
'
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
_converse
.
chatboxviews
.
get
(
'
problematic@muc.localhost
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
groupchat_jid
);
spyOn
(
view
,
'
showErrorMessage
'
).
and
.
callThrough
();
spyOn
(
view
,
'
join
'
).
and
.
callThrough
();
...
...
@@ -3360,26 +3357,25 @@
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
view
.
join
).
toHaveBeenCalledWith
(
'
dummy-2
'
);
attrs
.
from
=
'
problematic@muc.localhost/dummy-2
'
;
attrs
.
id
=
new
Date
().
getTime
();
attrs
.
from
=
`
${
groupchat_jid
}
/dummy-2`
;
attrs
.
id
=
u
.
getUniqueId
();
presence
=
$pres
().
attrs
(
attrs
)
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
problematic@muc.localhost
'
,
type
:
'
cancel
'
})
.
c
(
'
x
'
).
attrs
({
'
xmlns
'
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
'
by
'
:
groupchat_jid
,
type
:
'
cancel
'
})
.
c
(
'
conflict
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
view
.
join
).
toHaveBeenCalledWith
(
'
dummy-3
'
);
attrs
.
from
=
'
problematic@muc.localhost/dummy-3
'
;
attrs
.
from
=
`
${
groupchat_jid
}
/dummy-3`
;
attrs
.
id
=
new
Date
().
getTime
();
presence
=
$pres
().
attrs
(
attrs
)
.
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
by
:
'
problematic@muc.localhost
'
,
type
:
'
cancel
'
})
.
c
(
'
conflict
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
.
c
(
'
x
'
).
attrs
({
'
xmlns
'
:
'
http://jabber.org/protocol/muc
'
}).
up
()
.
c
(
'
error
'
).
attrs
({
'
by
'
:
groupchat_jid
,
'
type
'
:
'
cancel
'
})
.
c
(
'
conflict
'
).
attrs
({
'
xmlns
'
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
view
.
join
).
toHaveBeenCalledWith
(
'
dummy-4
'
);
done
();
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
}));
it
(
"
will show an error message if the user is not allowed to have created the groupchat
"
,
...
...
@@ -3391,7 +3387,7 @@
await
test_utils
.
openChatRoomViaModal
(
_converse
,
groupchat_jid
,
'
dummy
'
)
var
presence
=
$pres
().
attrs
({
from
:
`
${
groupchat_jid
}
/dummy`
,
id
:
'
n13mt3l
'
,
id
:
u
.
getUniqueId
()
,
to
:
'
dummy@localhost/pda
'
,
type
:
'
error
'
}).
c
(
'
x
'
).
attrs
({
xmlns
:
'
http://jabber.org/protocol/muc
'
}).
up
()
...
...
@@ -3412,7 +3408,7 @@
const
groupchat_jid
=
'
conformist@muc.localhost
'
await
test_utils
.
openChatRoomViaModal
(
_converse
,
groupchat_jid
,
'
dummy
'
);
var
presence
=
$pres
().
attrs
({
const
presence
=
$pres
().
attrs
({
from
:
`
${
groupchat_jid
}
/dummy`
,
id
:
u
.
getUniqueId
(),
to
:
'
dummy@localhost/pda
'
,
...
...
@@ -3421,7 +3417,7 @@
.
c
(
'
error
'
).
attrs
({
by
:
'
lounge@localhost
'
,
type
:
'
cancel
'
})
.
c
(
'
not-acceptable
'
).
attrs
({
xmlns
:
'
urn:ietf:params:xml:ns:xmpp-stanzas
'
}).
nodeTree
;
var
view
=
_converse
.
chatboxviews
.
get
(
groupchat_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
groupchat_jid
);
spyOn
(
view
,
'
showErrorMessage
'
).
and
.
callThrough
();
_converse
.
connection
.
_dataRecv
(
test_utils
.
createRequest
(
presence
));
expect
(
view
.
el
.
querySelector
(
'
.chatroom-body .disconnect-container .disconnect-msg:last-child
'
).
textContent
)
...
...
tests/utils.js
View file @
f2c14557
...
...
@@ -101,22 +101,17 @@
return
utils
.
waitUntil
(()
=>
_converse
.
chatboxviews
.
get
(
jid
),
1000
);
};
utils
.
openChatRoomViaModal
=
function
(
_converse
,
jid
,
nick
=
''
)
{
utils
.
openChatRoomViaModal
=
async
function
(
_converse
,
jid
,
nick
=
''
)
{
// Opens a new chatroom
return
new
Promise
(
function
(
resolve
,
reject
)
{
utils
.
openControlBox
(
_converse
);
const
roomspanel
=
_converse
.
chatboxviews
.
get
(
'
controlbox
'
).
roomspanel
;
roomspanel
.
el
.
querySelector
(
'
.show-add-muc-modal
'
).
click
();
utils
.
closeControlBox
(
_converse
);
const
modal
=
roomspanel
.
add_room_modal
;
utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
)
.
then
(()
=>
{
await
utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1500
)
modal
.
el
.
querySelector
(
'
input[name="chatroom"]
'
).
value
=
jid
;
modal
.
el
.
querySelector
(
'
input[name="nickname"]
'
).
value
=
nick
;
modal
.
el
.
querySelector
(
'
form input[type="submit"]
'
).
click
();
resolve
();
});
}).
catch
(
_
.
partial
(
console
.
error
,
_
));
};
utils
.
openChatRoom
=
function
(
_converse
,
room
,
server
,
nick
)
{
...
...
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