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
53b3f2d0
Commit
53b3f2d0
authored
Oct 26, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix failing tests and rewrite to use async/await
parent
65190834
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
641 additions
and
675 deletions
+641
-675
spec/bookmarks.js
spec/bookmarks.js
+214
-209
spec/chatbox.js
spec/chatbox.js
+80
-106
spec/chatroom.js
spec/chatroom.js
+25
-26
spec/http-file-upload.js
spec/http-file-upload.js
+259
-263
spec/notification.js
spec/notification.js
+42
-39
spec/roster.js
spec/roster.js
+18
-31
spec/spoilers.js
spec/spoilers.js
+3
-0
tests/runner.js
tests/runner.js
+0
-1
No files found.
spec/bookmarks.js
View file @
53b3f2d0
This diff is collapsed.
Click to expand it.
spec/chatbox.js
View file @
53b3f2d0
This diff is collapsed.
Click to expand it.
spec/chatroom.js
View file @
53b3f2d0
...
...
@@ -2329,35 +2329,34 @@
}));
it
(
"
can be minimized by clicking a DOM element with class 'toggle-chatbox-button'
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
function
(
done
,
_converse
)
{
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
async
function
(
done
,
_converse
)
{
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
)
.
then
(()
=>
{
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
),
trimmed_chatboxes
=
_converse
.
minimized_chats
;
await
test_utils
.
openChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
),
trimmed_chatboxes
=
_converse
.
minimized_chats
;
spyOn
(
view
,
'
minimize
'
).
and
.
callThrough
();
spyOn
(
view
,
'
maximize
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
emit
'
);
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
view
.
el
.
querySelector
(
'
.toggle-chatbox-button
'
).
click
();
expect
(
view
.
minimize
).
toHaveBeenCalled
();
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
chatBoxMinimized
'
,
jasmine
.
any
(
Object
));
expect
(
u
.
isVisible
(
view
.
el
)).
toBeFalsy
();
expect
(
view
.
model
.
get
(
'
minimized
'
)).
toBeTruthy
();
expect
(
view
.
minimize
).
toHaveBeenCalled
();
var
trimmedview
=
trimmed_chatboxes
.
get
(
view
.
model
.
get
(
'
id
'
));
trimmedview
.
el
.
querySelector
(
"
a.restore-chat
"
).
click
();
expect
(
view
.
maximize
).
toHaveBeenCalled
();
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
chatBoxMaximized
'
,
jasmine
.
any
(
Object
));
expect
(
view
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
expect
(
_converse
.
emit
.
calls
.
count
(),
3
);
done
();
spyOn
(
view
,
'
minimize
'
).
and
.
callThrough
();
spyOn
(
view
,
'
maximize
'
).
and
.
callThrough
();
spyOn
(
_converse
,
'
emit
'
);
view
.
delegateEvents
();
// We need to rebind all events otherwise our spy won't be called
view
.
el
.
querySelector
(
'
.toggle-chatbox-button
'
).
click
();
expect
(
view
.
minimize
).
toHaveBeenCalled
();
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
chatBoxMinimized
'
,
jasmine
.
any
(
Object
));
expect
(
u
.
isVisible
(
view
.
el
)).
toBeFalsy
();
expect
(
view
.
model
.
get
(
'
minimized
'
)).
toBeTruthy
();
expect
(
view
.
minimize
).
toHaveBeenCalled
();
await
test_utils
.
waitUntil
(()
=>
trimmed_chatboxes
.
get
(
view
.
model
.
get
(
'
id
'
)));
const
trimmedview
=
trimmed_chatboxes
.
get
(
view
.
model
.
get
(
'
id
'
));
trimmedview
.
el
.
querySelector
(
"
a.restore-chat
"
).
click
();
expect
(
view
.
maximize
).
toHaveBeenCalled
();
expect
(
_converse
.
emit
).
toHaveBeenCalledWith
(
'
chatBoxMaximized
'
,
jasmine
.
any
(
Object
));
expect
(
view
.
model
.
get
(
'
minimized
'
)).
toBeFalsy
();
expect
(
_converse
.
emit
.
calls
.
count
(),
3
);
done
();
});
}));
it
(
"
can be closed again by clicking a DOM element with class 'close-chatbox-button'
"
,
...
...
spec/http-file-upload.js
View file @
53b3f2d0
This diff is collapsed.
Click to expand it.
spec/notification.js
View file @
53b3f2d0
...
...
@@ -159,47 +159,50 @@
it
(
"
is played when the current user is mentioned in a chat room
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
).
then
(
function
()
{
_converse
.
play_sounds
=
true
;
spyOn
(
_converse
,
'
playSoundNotification
'
);
var
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
if
(
!
$
(
view
.
el
).
find
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
var
text
=
'
This message will play a sound because it mentions dummy
'
;
var
message
=
$msg
({
from
:
'
lounge@localhost/otheruser
'
,
id
:
'
1
'
,
to
:
'
dummy@localhost
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
text
);
view
.
model
.
onMessage
(
message
.
nodeTree
);
expect
(
_converse
.
playSoundNotification
).
toHaveBeenCalled
();
text
=
"
This message won't play a sound
"
;
message
=
$msg
({
from
:
'
lounge@localhost/otheruser
'
,
id
:
'
2
'
,
to
:
'
dummy@localhost
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
text
);
view
.
model
.
onMessage
(
message
.
nodeTree
);
expect
(
_converse
.
playSoundNotification
,
1
);
_converse
.
play_sounds
=
false
;
text
=
"
This message won't play a sound because it is sent by dummy
"
;
message
=
$msg
({
from
:
'
lounge@localhost/dummy
'
,
id
:
'
3
'
,
to
:
'
dummy@localhost
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
text
);
view
.
model
.
onMessage
(
message
.
nodeTree
);
expect
(
_converse
.
playSoundNotification
,
1
);
_converse
.
play_sounds
=
false
;
done
();
});
await
test_utils
.
openAndEnterChatRoom
(
_converse
,
'
lounge
'
,
'
localhost
'
,
'
dummy
'
);
_converse
.
play_sounds
=
true
;
spyOn
(
_converse
,
'
playSoundNotification
'
);
const
view
=
_converse
.
chatboxviews
.
get
(
'
lounge@localhost
'
);
if
(
!
view
.
el
.
querySelectorAll
(
'
.chat-area
'
).
length
)
{
view
.
renderChatArea
();
}
let
text
=
'
This message will play a sound because it mentions dummy
'
;
let
message
=
$msg
({
from
:
'
lounge@localhost/otheruser
'
,
id
:
'
1
'
,
to
:
'
dummy@localhost
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
text
);
view
.
model
.
onMessage
(
message
.
nodeTree
);
await
test_utils
.
waitUntil
(()
=>
_converse
.
playSoundNotification
.
calls
.
count
());
expect
(
_converse
.
playSoundNotification
).
toHaveBeenCalled
();
text
=
"
This message won't play a sound
"
;
message
=
$msg
({
from
:
'
lounge@localhost/otheruser
'
,
id
:
'
2
'
,
to
:
'
dummy@localhost
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
text
);
view
.
model
.
onMessage
(
message
.
nodeTree
);
expect
(
_converse
.
playSoundNotification
,
1
);
_converse
.
play_sounds
=
false
;
text
=
"
This message won't play a sound because it is sent by dummy
"
;
message
=
$msg
({
from
:
'
lounge@localhost/dummy
'
,
id
:
'
3
'
,
to
:
'
dummy@localhost
'
,
type
:
'
groupchat
'
}).
c
(
'
body
'
).
t
(
text
);
view
.
model
.
onMessage
(
message
.
nodeTree
);
expect
(
_converse
.
playSoundNotification
,
1
);
_converse
.
play_sounds
=
false
;
done
();
}));
});
});
...
...
spec/roster.js
View file @
53b3f2d0
...
...
@@ -10,28 +10,21 @@
const
u
=
converse
.
env
.
utils
;
const
checkHeaderToggling
=
function
(
group
)
{
var
$group
=
$
(
group
);
const
checkHeaderToggling
=
async
function
(
group
)
{
var
toggle
=
group
.
querySelector
(
'
a.group-toggle
'
);
expect
(
u
.
isVisible
(
$group
[
0
]
)).
toBeTruthy
();
expect
(
$group
.
find
(
'
ul.collapsed
'
).
length
).
toBe
(
0
);
expect
(
u
.
isVisible
(
group
)).
toBeTruthy
();
expect
(
group
.
querySelectorAll
(
'
ul.collapsed
'
).
length
).
toBe
(
0
);
expect
(
u
.
hasClass
(
'
fa-caret-right
'
,
toggle
.
firstElementChild
)).
toBeFalsy
();
expect
(
u
.
hasClass
(
'
fa-caret-down
'
,
toggle
.
firstElementChild
)).
toBeTruthy
();
toggle
.
click
();
return
test_utils
.
waitUntil
(
function
()
{
return
$group
.
find
(
'
ul.collapsed
'
).
length
===
1
;
},
500
).
then
(
function
()
{
expect
(
u
.
hasClass
(
'
fa-caret-right
'
,
toggle
.
firstElementChild
)).
toBeTruthy
();
expect
(
u
.
hasClass
(
'
fa-caret-down
'
,
toggle
.
firstElementChild
)).
toBeFalsy
();
toggle
.
click
();
return
test_utils
.
waitUntil
(
function
()
{
return
$group
.
find
(
'
li
'
).
length
===
$group
.
find
(
'
li:visible
'
).
length
},
500
);
}).
then
(
function
()
{
expect
(
u
.
hasClass
(
'
fa-caret-right
'
,
toggle
.
firstElementChild
)).
toBeFalsy
();
expect
(
u
.
hasClass
(
'
fa-caret-down
'
,
toggle
.
firstElementChild
)).
toBeTruthy
();
});
await
test_utils
.
waitUntil
(()
=>
group
.
querySelectorAll
(
'
ul.collapsed
'
).
length
===
1
);
expect
(
u
.
hasClass
(
'
fa-caret-right
'
,
toggle
.
firstElementChild
)).
toBeTruthy
();
expect
(
u
.
hasClass
(
'
fa-caret-down
'
,
toggle
.
firstElementChild
)).
toBeFalsy
();
toggle
.
click
();
await
test_utils
.
waitUntil
(()
=>
group
.
querySelectorAll
(
'
li
'
).
length
===
$
(
group
).
find
(
'
li:visible
'
).
length
);
expect
(
u
.
hasClass
(
'
fa-caret-right
'
,
toggle
.
firstElementChild
)).
toBeFalsy
();
expect
(
u
.
hasClass
(
'
fa-caret-down
'
,
toggle
.
firstElementChild
)).
toBeTruthy
();
};
...
...
@@ -501,7 +494,7 @@
it
(
"
remembers whether it is closed or opened
"
,
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
function
(
done
,
_converse
)
{
async
function
(
done
,
_converse
)
{
_converse
.
roster_groups
=
true
;
test_utils
.
openControlBox
();
...
...
@@ -524,20 +517,14 @@
});
}
});
var
view
=
_converse
.
rosterview
.
get
(
'
colleagues
'
);
var
$toggle
=
$
(
view
.
el
).
find
(
'
a.group-toggle
'
);
const
view
=
_converse
.
rosterview
.
get
(
'
colleagues
'
);
const
toggle
=
view
.
el
.
querySelector
(
'
a.group-toggle
'
);
expect
(
view
.
model
.
get
(
'
state
'
)).
toBe
(
'
opened
'
);
$toggle
[
0
].
click
();
return
test_utils
.
waitUntil
(
function
()
{
return
view
.
model
.
get
(
'
state
'
)
===
'
closed
'
;
},
500
).
then
(
function
()
{
$toggle
[
0
].
click
();
return
test_utils
.
waitUntil
(
function
()
{
return
view
.
model
.
get
(
'
state
'
)
===
'
opened
'
;
},
500
)
}).
then
(
function
()
{
done
();
});
toggle
.
click
();
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
get
(
'
state
'
)
===
'
closed
'
);
toggle
.
click
();
await
test_utils
.
waitUntil
(()
=>
view
.
model
.
get
(
'
state
'
)
===
'
opened
'
);
done
();
}));
});
...
...
spec/spoilers.js
View file @
53b3f2d0
...
...
@@ -105,6 +105,7 @@
spyOn
(
view
,
'
onMessageSubmitted
'
).
and
.
callThrough
();
spyOn
(
_converse
.
connection
,
'
send
'
);
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.toggle-compose-spoiler
'
));
let
spoiler_toggle
=
view
.
el
.
querySelector
(
'
.toggle-compose-spoiler
'
);
spoiler_toggle
.
click
();
...
...
@@ -178,6 +179,8 @@
await
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
await
test_utils
.
waitUntilDiscoConfirmed
(
_converse
,
contact_jid
+
'
/phone
'
,
[],
[
Strophe
.
NS
.
SPOILER
]);
const
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
await
test_utils
.
waitUntil
(()
=>
view
.
el
.
querySelector
(
'
.toggle-compose-spoiler
'
));
let
spoiler_toggle
=
view
.
el
.
querySelector
(
'
.toggle-compose-spoiler
'
);
spoiler_toggle
.
click
();
...
...
tests/runner.js
View file @
53b3f2d0
...
...
@@ -179,7 +179,6 @@ require.config(config);
var
specs
=
[
"
jasmine
"
,
//"spec/transcripts",
//"spec/otr",
"
spec/spoilers
"
,
"
spec/profiling
"
,
"
spec/utils
"
,
...
...
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