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
527555ba
Commit
527555ba
authored
May 10, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing spec file
parent
09db3edd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
2 deletions
+101
-2
spec/user-details-modal.js
spec/user-details-modal.js
+100
-0
src/converse-muc.js
src/converse-muc.js
+1
-2
No files found.
spec/user-details-modal.js
0 → 100644
View file @
527555ba
(
function
(
root
,
factory
)
{
define
([
"
jasmine
"
,
"
utils
"
,
"
converse-core
"
,
"
mock
"
,
"
test-utils
"
],
factory
);
}
(
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
u
=
converse
.
env
.
utils
;
return
describe
(
"
The User Details Modal
"
,
function
()
{
it
(
"
can be used to remove a contact
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
expect
(
u
.
isVisible
(
show_modal_button
)).
toBeTruthy
();
show_modal_button
.
click
();
const
modal
=
view
.
user_details_modal
;
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
1000
)
.
then
(
function
()
{
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
spyOn
(
view
.
model
.
contact
,
'
removeFromRoster
'
).
and
.
callFake
(
function
(
callback
)
{
callback
();
});
const
remove_contact_button
=
modal
.
el
.
querySelector
(
'
button.remove-contact
'
);
expect
(
u
.
isVisible
(
remove_contact_button
)).
toBeTruthy
();
remove_contact_button
.
click
();
return
test_utils
.
waitUntil
(()
=>
modal
.
el
.
getAttribute
(
'
aria-hidden
'
),
1000
);
}).
then
(
function
()
{
const
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
show_modal_button
.
click
();
const
remove_contact_button
=
modal
.
el
.
querySelector
(
'
button.remove-contact
'
);
expect
(
_
.
isNull
(
remove_contact_button
)).
toBeTruthy
();
done
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}));
it
(
"
shows an alert when an error happened while removing the contact
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
const
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
expect
(
u
.
isVisible
(
show_modal_button
)).
toBeTruthy
();
show_modal_button
.
click
();
const
modal
=
view
.
user_details_modal
;
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
2000
)
.
then
(
function
()
{
spyOn
(
window
,
'
confirm
'
).
and
.
returnValue
(
true
);
spyOn
(
view
.
model
.
contact
,
'
removeFromRoster
'
).
and
.
callFake
(
function
(
callback
,
errback
)
{
errback
();
});
const
remove_contact_button
=
modal
.
el
.
querySelector
(
'
button.remove-contact
'
);
expect
(
u
.
isVisible
(
remove_contact_button
)).
toBeTruthy
();
remove_contact_button
.
click
();
return
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
document
.
querySelector
(
'
.alert-danger
'
)),
2000
);
}).
then
(
function
()
{
expect
(
document
.
querySelector
(
'
.alert-danger .modal-title
'
).
textContent
).
toBe
(
"
Error
"
);
expect
(
document
.
querySelector
(
'
.modal:not(#user-profile-modal) .modal-body p
'
).
textContent
.
trim
())
.
toBe
(
"
Sorry, there was an error while trying to remove Max Frankfurter as a contact.
"
);
document
.
querySelector
(
'
.alert-danger button.close
'
).
click
();
const
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
show_modal_button
.
click
();
return
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
2000
)
}).
then
(
function
()
{
const
show_modal_button
=
view
.
el
.
querySelector
(
'
.show-user-details-modal
'
);
show_modal_button
.
click
();
const
modal
=
view
.
user_details_modal
;
return
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
modal
.
el
),
2000
)
}).
then
(
function
()
{
const
remove_contact_button
=
modal
.
el
.
querySelector
(
'
button.remove-contact
'
);
expect
(
u
.
isVisible
(
remove_contact_button
)).
toBeTruthy
();
done
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
}));
});
}));
src/converse-muc.js
View file @
527555ba
...
...
@@ -1042,8 +1042,7 @@
}
else
{
return
this
.
where
({
'
nick
'
:
data
.
nick
}).
pop
();
}
},
}
});
...
...
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