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
890dbca8
Commit
890dbca8
authored
Aug 02, 2018
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tests failing on Travis
parent
b027f0f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
51 deletions
+47
-51
spec/chatbox.js
spec/chatbox.js
+42
-42
spec/messages.js
spec/messages.js
+5
-9
No files found.
spec/chatbox.js
View file @
890dbca8
...
@@ -922,63 +922,63 @@
...
@@ -922,63 +922,63 @@
describe
(
"
An inactive notifciation
"
,
function
()
{
describe
(
"
An inactive notifciation
"
,
function
()
{
it
(
"
is sent if the user has stopped typing since 2 minutes
"
,
it
(
"
is sent if the user has stopped typing since 2 minutes
"
,
mock
.
initConverseWithPromises
(
mock
.
initConverseWithPromises
(
null
,
[
'
rosterGroupsFetched
'
],
{},
null
,
[
'
rosterGroupsFetched
'
,
'
chatBoxesFetched
'
],
{},
function
(
done
,
_converse
)
{
function
(
done
,
_converse
)
{
// Make the timeouts shorter so that we can test
_converse
.
TIMEOUTS
.
PAUSED
=
200
;
_converse
.
TIMEOUTS
.
INACTIVE
=
200
;
var
view
,
contact_jid
;
test_utils
.
createContacts
(
_converse
,
'
current
'
);
test_utils
.
createContacts
(
_converse
,
'
current
'
);
_converse
.
emit
(
'
rosterContactsFetched
'
);
let
view
;
const
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openControlBox
();
test_utils
.
openControlBox
();
test_utils
.
waitUntil
(
function
()
{
test_utils
.
waitUntil
(()
=>
_converse
.
rosterview
.
el
.
querySelectorAll
(
'
.roster-group
'
).
length
,
500
)
return
$
(
_converse
.
rosterview
.
el
).
find
(
'
.roster-group
'
).
length
;
.
then
(()
=>
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
))
},
500
).
then
(
function
()
{
.
then
(()
=>
{
// Make the timeouts shorter so that we can test
_converse
.
TIMEOUTS
.
PAUSED
=
200
;
_converse
.
TIMEOUTS
.
INACTIVE
=
200
;
contact_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
test_utils
.
openChatBoxFor
(
_converse
,
contact_jid
);
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
return
test_utils
.
waitUntil
(()
=>
view
.
model
.
get
(
'
chat_state
'
)
===
'
active
'
,
500
);
return
test_utils
.
waitUntil
(()
=>
view
.
model
.
get
(
'
chat_state
'
)
===
'
active
'
,
500
);
}).
then
(
function
()
{
}).
then
(
()
=>
{
console
.
log
(
'
chat_state set to active
'
);
console
.
log
(
'
chat_state set to active
'
);
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
expect
(
view
.
model
.
get
(
'
chat_state
'
)).
toBe
(
'
active
'
);
expect
(
view
.
model
.
get
(
'
chat_state
'
)).
toBe
(
'
active
'
);
view
.
keyPressed
({
view
.
keyPressed
({
target
:
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
),
target
:
view
.
el
.
querySelector
(
'
textarea.chat-textarea
'
),
keyCode
:
1
keyCode
:
1
});
});
return
test_utils
.
waitUntil
(()
=>
view
.
model
.
get
(
'
chat_state
'
)
===
'
composing
'
,
500
);
return
test_utils
.
waitUntil
(()
=>
view
.
model
.
get
(
'
chat_state
'
)
===
'
composing
'
,
500
);
}).
then
(
function
()
{
}).
then
(
()
=>
{
console
.
log
(
'
chat_state set to composing
'
);
console
.
log
(
'
chat_state set to composing
'
);
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
view
=
_converse
.
chatboxviews
.
get
(
contact_jid
);
expect
(
view
.
model
.
get
(
'
chat_state
'
)).
toBe
(
'
composing
'
);
expect
(
view
.
model
.
get
(
'
chat_state
'
)).
toBe
(
'
composing
'
);
spyOn
(
_converse
.
connection
,
'
send
'
);
spyOn
(
_converse
.
connection
,
'
send
'
);
return
test_utils
.
waitUntil
(()
=>
view
.
model
.
get
(
'
chat_state
'
)
===
'
paused
'
,
500
);
return
test_utils
.
waitUntil
(()
=>
view
.
model
.
get
(
'
chat_state
'
)
===
'
paused
'
,
500
);
}).
then
(
function
()
{
}).
then
(()
=>
{
console
.
log
(
'
chat_state set to paused
'
);
return
test_utils
.
waitUntil
(()
=>
view
.
model
.
get
(
'
chat_state
'
)
===
'
inactive
'
,
500
);
return
test_utils
.
waitUntil
(()
=>
view
.
model
.
get
(
'
chat_state
'
)
===
'
inactive
'
,
500
);
}).
then
(
function
()
{
}).
then
(
()
=>
{
console
.
log
(
'
chat_state set to inactive
'
);
console
.
log
(
'
chat_state set to inactive
'
);
expect
(
_converse
.
connection
.
send
).
toHaveBeenCalled
();
expect
(
_converse
.
connection
.
send
).
toHaveBeenCalled
();
var
calls
=
_
.
filter
(
_converse
.
connection
.
send
.
calls
.
all
(),
function
(
call
)
{
var
calls
=
_
.
filter
(
_converse
.
connection
.
send
.
calls
.
all
(),
function
(
call
)
{
return
call
.
args
[
0
]
instanceof
Strophe
.
Builder
;
return
call
.
args
[
0
]
instanceof
Strophe
.
Builder
;
});
});
expect
(
calls
.
length
).
toBe
(
2
);
expect
(
calls
.
length
).
toBe
(
2
);
var
$stanza
=
$
(
calls
[
0
].
args
[
0
].
tree
());
var
stanza
=
calls
[
0
].
args
[
0
].
tree
();
expect
(
$stanza
.
attr
(
'
to
'
)).
toBe
(
contact_jid
);
expect
(
stanza
.
getAttribute
(
'
to
'
)).
toBe
(
contact_jid
);
expect
(
$stanza
.
children
().
length
).
toBe
(
3
);
expect
(
stanza
.
children
.
length
).
toBe
(
3
);
expect
(
$stanza
.
children
().
get
(
0
).
tagName
).
toBe
(
'
paused
'
);
expect
(
stanza
.
children
[
0
].
tagName
).
toBe
(
'
paused
'
);
expect
(
$stanza
.
children
().
get
(
1
).
tagName
).
toBe
(
'
no-store
'
);
expect
(
stanza
.
children
[
1
].
tagName
).
toBe
(
'
no-store
'
);
expect
(
$stanza
.
children
().
get
(
2
).
tagName
).
toBe
(
'
no-permanent-store
'
);
expect
(
stanza
.
children
[
2
].
tagName
).
toBe
(
'
no-permanent-store
'
);
$stanza
=
$
(
_converse
.
connection
.
send
.
calls
.
mostRecent
().
args
[
0
].
tree
());
stanza
=
_converse
.
connection
.
send
.
calls
.
mostRecent
().
args
[
0
].
tree
();
expect
(
$stanza
.
attr
(
'
to
'
)).
toBe
(
contact_jid
);
expect
(
stanza
.
getAttribute
(
'
to
'
)).
toBe
(
contact_jid
);
expect
(
$stanza
.
children
().
length
).
toBe
(
3
);
expect
(
stanza
.
children
.
length
).
toBe
(
3
);
expect
(
$stanza
.
children
().
get
(
0
).
tagName
).
toBe
(
'
inactive
'
);
expect
(
stanza
.
children
[
0
].
tagName
).
toBe
(
'
inactive
'
);
expect
(
$stanza
.
children
().
get
(
1
).
tagName
).
toBe
(
'
no-store
'
);
expect
(
stanza
.
children
[
1
].
tagName
).
toBe
(
'
no-store
'
);
expect
(
$stanza
.
children
().
get
(
2
).
tagName
).
toBe
(
'
no-permanent-store
'
);
expect
(
stanza
.
children
[
2
].
tagName
).
toBe
(
'
no-permanent-store
'
);
done
();
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
))
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
))
.
then
(
done
);
}));
}));
it
(
"
is sent when the user a minimizes a chat box
"
,
it
(
"
is sent when the user a minimizes a chat box
"
,
...
@@ -1429,16 +1429,16 @@
...
@@ -1429,16 +1429,16 @@
var
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
var
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
_converse
.
chatboxes
.
onMessage
(
msg
);
_converse
.
chatboxes
.
onMessage
(
msg
);
var
msgIndicatorS
elector
=
'
a.open-chat:contains("
'
+
chatbox
.
get
(
'
fullname
'
)
+
'
") .msgs-indicator
'
,
var
s
elector
=
'
a.open-chat:contains("
'
+
chatbox
.
get
(
'
fullname
'
)
+
'
") .msgs-indicator
'
,
$msgIndicator
=
$
(
$
(
_converse
.
rosterview
.
el
).
find
(
msgIndicatorSelector
)
);
indicator_el
=
sizzle
(
selector
,
_converse
.
rosterview
.
el
).
pop
(
);
expect
(
$msgIndicator
.
text
()
).
toBe
(
'
1
'
);
expect
(
indicator_el
.
textContent
).
toBe
(
'
1
'
);
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread too
'
);
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread too
'
);
_converse
.
chatboxes
.
onMessage
(
msg
);
_converse
.
chatboxes
.
onMessage
(
msg
);
$msgIndicator
=
$
(
$
(
_converse
.
rosterview
.
el
).
find
(
msgIndicatorSelector
)
);
indicator_el
=
sizzle
(
selector
,
_converse
.
rosterview
.
el
).
pop
(
);
expect
(
$msgIndicator
.
text
()
).
toBe
(
'
2
'
);
expect
(
indicator_el
.
textContent
).
toBe
(
'
2
'
);
done
();
done
();
});
});
}));
}));
...
@@ -1462,16 +1462,16 @@
...
@@ -1462,16 +1462,16 @@
var
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
var
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread
'
);
_converse
.
chatboxes
.
onMessage
(
msg
);
_converse
.
chatboxes
.
onMessage
(
msg
);
var
msgIndicatorS
elector
=
'
a.open-chat:contains("
'
+
chatbox
.
get
(
'
fullname
'
)
+
'
") .msgs-indicator
'
,
var
s
elector
=
'
a.open-chat:contains("
'
+
chatbox
.
get
(
'
fullname
'
)
+
'
") .msgs-indicator
'
,
$msgIndicator
=
$
(
$
(
_converse
.
rosterview
.
el
).
find
(
msgIndicatorSelector
)
);
indicator_el
=
sizzle
(
selector
,
_converse
.
rosterview
.
el
).
pop
(
);
expect
(
$msgIndicator
.
text
()
).
toBe
(
'
1
'
);
expect
(
indicator_el
.
textContent
).
toBe
(
'
1
'
);
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread too
'
);
msg
=
test_utils
.
createChatMessage
(
_converse
,
sender_jid
,
'
This message will be unread too
'
);
_converse
.
chatboxes
.
onMessage
(
msg
);
_converse
.
chatboxes
.
onMessage
(
msg
);
$msgIndicator
=
$
(
$
(
_converse
.
rosterview
.
el
).
find
(
msgIndicatorSelector
)
);
indicator_el
=
sizzle
(
selector
,
_converse
.
rosterview
.
el
).
pop
(
);
expect
(
$msgIndicator
.
text
()
).
toBe
(
'
2
'
);
expect
(
indicator_el
.
textContent
).
toBe
(
'
2
'
);
done
();
done
();
});
});
}));
}));
...
...
spec/messages.js
View file @
890dbca8
...
@@ -675,21 +675,17 @@
...
@@ -675,21 +675,17 @@
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
());
.
c
(
'
active
'
,
{
'
xmlns
'
:
'
http://jabber.org/protocol/chatstates
'
}).
tree
());
// Now check that the message appears inside the chatbox in the DOM
// Now check that the message appears inside the chatbox in the DOM
var
$chat_content
=
$
(
chatboxview
.
el
).
find
(
'
.chat-content
'
);
const
$chat_content
=
$
(
chatboxview
.
el
).
find
(
'
.chat-content
'
);
var
msg_txt
=
$chat_content
.
find
(
'
.chat-msg:last
'
).
find
(
'
.chat-msg__text
'
).
text
();
const
msg_txt
=
$chat_content
.
find
(
'
.chat-msg:last
'
).
find
(
'
.chat-msg__text
'
).
text
();
expect
(
msg_txt
).
toEqual
(
message
);
expect
(
msg_txt
).
toEqual
(
message
);
return
test_utils
.
waitUntil
(
function
()
{
return
test_utils
.
waitUntil
(()
=>
u
.
isVisible
(
chatboxview
.
el
.
querySelector
(
'
.new-msgs-indicator
'
)),
900
);
return
u
.
isVisible
(
chatboxview
.
el
.
querySelector
(
'
.new-msgs-indicator
'
));
}).
then
(()
=>
{
},
500
);
}).
then
(
function
()
{
expect
(
chatboxview
.
model
.
get
(
'
scrolled
'
)).
toBe
(
true
);
expect
(
chatboxview
.
model
.
get
(
'
scrolled
'
)).
toBe
(
true
);
expect
(
chatboxview
.
content
.
scrollTop
).
toBe
(
0
);
expect
(
chatboxview
.
content
.
scrollTop
).
toBe
(
0
);
expect
(
u
.
isVisible
(
chatboxview
.
el
.
querySelector
(
'
.new-msgs-indicator
'
))).
toBeTruthy
();
expect
(
u
.
isVisible
(
chatboxview
.
el
.
querySelector
(
'
.new-msgs-indicator
'
))).
toBeTruthy
();
// Scroll down again
// Scroll down again
chatboxview
.
content
.
scrollTop
=
chatboxview
.
content
.
scrollHeight
;
chatboxview
.
content
.
scrollTop
=
chatboxview
.
content
.
scrollHeight
;
return
test_utils
.
waitUntil
(
function
()
{
return
test_utils
.
waitUntil
(()
=>
!
u
.
isVisible
(
chatboxview
.
el
.
querySelector
(
'
.new-msgs-indicator
'
)),
900
);
return
!
u
.
isVisible
(
chatboxview
.
el
.
querySelector
(
'
.new-msgs-indicator
'
));
},
700
);
}).
then
(
done
);
}).
then
(
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