Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
RocketChat
Rocket.Chat.js.SDK
Commits
b02f4b0d
Commit
b02f4b0d
authored
Jun 01, 2018
by
Tim Kinnane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(tests): Make sendFromUser wait for message
Related #10
parent
7c001690
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
65 deletions
+91
-65
coverage/lcov.info
coverage/lcov.info
+62
-61
src/lib/api.ts
src/lib/api.ts
+1
-1
src/utils/testing.ts
src/utils/testing.ts
+28
-3
No files found.
coverage/lcov.info
View file @
b02f4b0d
...
...
@@ -36,20 +36,20 @@ FN:218,(anonymous_42)
FN:218,(anonymous_43)
FNF:34
FNH:16
FNDA:
3
3,loggedIn
FNDA:
2
4,getQueryString
FNDA:
1
5,(anonymous_9)
FNDA:
6
3,loggedIn
FNDA:
5
4,getQueryString
FNDA:
7
5,(anonymous_9)
FNDA:8,setAuth
FNDA:
4
5,getHeaders
FNDA:
7
5,getHeaders
FNDA:11,clearHeaders
FNDA:
4
7,success
FNDA:
7
7,success
FNDA:21,post
FNDA:21,(anonymous_16)
FNDA:21,(anonymous_17)
FNDA:0,(anonymous_18)
FNDA:
2
1,get
FNDA:
2
1,(anonymous_21)
FNDA:
2
1,(anonymous_22)
FNDA:
5
1,get
FNDA:
5
1,(anonymous_21)
FNDA:
5
1,(anonymous_22)
FNDA:0,(anonymous_23)
FNDA:20,login
FNDA:21,logout
...
...
@@ -75,30 +75,30 @@ DA:2,1
DA:3,1
DA:17,1
DA:25,1
DA:26,
3
3
DA:26,
6
3
DA:30,1
DA:31,1
DA:37,1
DA:42,1
DA:43,
2
4
DA:44,
1
4
DA:45,
1
5
DA:48,
1
5
DA:43,
5
4
DA:44,
4
4
DA:45,
7
5
DA:48,
7
5
DA:53,1
DA:54,1
DA:57,1
DA:58,8
DA:59,8
DA:63,1
DA:64,
4
5
DA:65,
3
5
DA:64,
7
5
DA:65,
6
5
DA:70,1
DA:72,
3
4
DA:72,
6
4
DA:76,1
DA:77,11
DA:78,11
DA:82,1
DA:83,
4
7
DA:83,
7
7
DA:104,1
DA:110,21
DA:111,21
...
...
@@ -115,19 +115,19 @@ DA:122,21
DA:124,0
DA:125,0
DA:136,1
DA:142,
2
1
DA:143,
2
1
DA:144,
2
1
DA:145,
2
1
DA:146,
2
1
DA:147,
2
1
DA:148,
2
1
DA:149,
2
1
DA:150,
2
1
DA:151,
2
1
DA:142,
5
1
DA:143,
5
1
DA:144,
5
1
DA:145,
5
1
DA:146,
5
1
DA:147,
5
1
DA:148,
5
1
DA:149,
5
1
DA:150,
5
1
DA:151,
5
1
DA:152,0
DA:154,
2
1
DA:155,
2
1
DA:154,
5
1
DA:155,
5
1
DA:157,0
DA:166,1
DA:170,20
...
...
@@ -161,33 +161,33 @@ DA:217,0
DA:218,0
LF:89
LH:77
BRDA:38,0,0,
1
BRDA:38,0,1,
0
BRDA:38,0,0,
0
BRDA:38,0,1,
1
BRDA:43,1,0,10
BRDA:43,1,1,
1
4
BRDA:43,2,0,
2
4
BRDA:43,2,1,
1
6
BRDA:43,2,2,
1
6
BRDA:43,1,1,
4
4
BRDA:43,2,0,
5
4
BRDA:43,2,1,
4
6
BRDA:43,2,2,
4
6
BRDA:46,3,0,2
BRDA:46,3,1,
1
3
BRDA:46,3,1,
7
3
BRDA:63,4,0,1
BRDA:64,5,0,10
BRDA:64,5,1,
3
5
BRDA:64,5,1,
6
5
BRDA:65,6,0,1
BRDA:65,6,1,
3
4
BRDA:66,7,0,
3
5
BRDA:66,7,1,
3
4
BRDA:66,7,2,
3
4
BRDA:66,7,3,
3
4
BRDA:92,8,0,
4
5
BRDA:65,6,1,
6
4
BRDA:66,7,0,
6
5
BRDA:66,7,1,
6
4
BRDA:66,7,2,
6
4
BRDA:66,7,3,
6
4
BRDA:92,8,0,
7
5
BRDA:92,8,1,2
BRDA:85,9,0,
4
7
BRDA:85,9,1,
4
7
BRDA:85,9,2,
2
9
BRDA:85,9,3,
4
6
BRDA:85,9,0,
7
7
BRDA:85,9,1,
7
7
BRDA:85,9,2,
5
9
BRDA:85,9,3,
7
6
BRDA:85,9,4,18
BRDA:85,9,5,
2
9
BRDA:85,9,6,
2
7
BRDA:85,9,5,
5
9
BRDA:85,9,6,
5
7
BRDA:85,9,7,2
BRDA:85,9,8,0
BRDA:85,9,9,0
...
...
@@ -200,15 +200,15 @@ BRDA:116,13,0,0
BRDA:116,13,1,21
BRDA:117,14,0,0
BRDA:117,14,1,21
BRDA:139,15,0,1
BRDA:139,15,0,
3
1
BRDA:144,16,0,1
BRDA:144,16,1,
2
0
BRDA:144,17,0,
2
1
BRDA:144,17,1,
2
0
BRDA:144,16,1,
5
0
BRDA:144,17,0,
5
1
BRDA:144,17,1,
5
0
BRDA:149,18,0,0
BRDA:149,18,1,
2
1
BRDA:149,18,1,
5
1
BRDA:150,19,0,0
BRDA:150,19,1,
2
1
BRDA:150,19,1,
5
1
BRDA:166,20,0,6
BRDA:171,21,0,13
BRDA:171,21,1,7
...
...
@@ -218,12 +218,13 @@ BRDA:180,23,0,8
BRDA:180,23,1,0
BRDA:180,24,0,8
BRDA:180,24,1,8
BRDA:180,24,2,8
BRDA:197,25,0,13
BRDA:197,25,1,8
BRDA:213,26,0,0
BRDA:216,27,0,0
BRF:6
1
BRH:
49
BRF:6
2
BRH:
50
end_of_record
TN:
SF:/Volumes/x/code/rocketchat/Rocket.Chat.js.SDK/src/lib/driver.ts
...
...
@@ -606,7 +607,7 @@ FNDA:0,(anonymous_3)
FNDA:0,(anonymous_4)
FNDA:2,replaceLog
FNDA:2,silence
FNDA:2
1
4,(anonymous_7)
FNDA:2
7
4,(anonymous_7)
FNDA:205,(anonymous_8)
FNDA:0,(anonymous_9)
FNDA:0,(anonymous_10)
...
...
@@ -619,7 +620,7 @@ DA:18,0
DA:22,1
DA:25,2
DA:29,2
DA:30,2
1
4
DA:30,2
7
4
DA:31,205
DA:32,0
DA:33,0
...
...
@@ -749,13 +750,13 @@ BRDA:3,0,1,9
BRDA:4,1,0,9
BRDA:4,1,1,9
BRDA:8,2,0,9
BRDA:8,2,1,
6
BRDA:8,2,1,
5
BRDA:10,3,0,2
BRDA:10,3,1,7
BRDA:10,4,0,2
BRDA:10,4,1,0
BRDA:11,5,0,7
BRDA:11,5,1,
5
BRDA:11,5,1,
4
BRDA:16,6,0,2
BRDA:16,6,1,7
BRDA:16,7,0,2
...
...
src/lib/api.ts
View file @
b02f4b0d
...
...
@@ -177,7 +177,7 @@ export async function login (user: ILoginCredentials = {
}
}
const
result
=
await
post
(
'
login
'
,
user
,
false
)
if
(
result
.
data
&&
result
.
data
.
authToken
)
{
if
(
result
&&
result
.
data
&&
result
.
data
.
authToken
)
{
currentLogin
=
{
result
:
result
,
// keep to return if login requested again for same user
username
:
user
.
username
,
// keep to compare with following login attempt
...
...
src/utils/testing.ts
View file @
b02f4b0d
...
...
@@ -7,7 +7,8 @@ import {
INewUserAPI
,
IUserResultAPI
,
IRoomResultAPI
,
IChannelResultAPI
IChannelResultAPI
,
IMessageReceiptAPI
}
from
'
./interfaces
'
/** Define common attributes for DRY tests */
...
...
@@ -38,12 +39,36 @@ export async function createChannel (
}
/** Send message from mock user to channel for tests to listen and respond */
/** @todo Sometimes the post request completes before the change event emits
* the message to the streamer. That's why the interval is used for proof
* of receipt. It would be better for the endpoint to not resolve until
* server side handling is complete. Would require PR to core.
*/
export
async
function
sendFromUser
(
payload
:
any
):
Promise
<
IMessageResultAPI
>
{
const
testChannel
=
await
channelInfo
(
testChannelName
)
const
messageDefaults
:
IMessageAPI
=
{
roomId
:
testChannel
.
channel
.
_id
}
const
roomId
=
testChannel
.
channel
.
_id
const
messageDefaults
:
IMessageAPI
=
{
roomId
}
const
data
:
IMessageAPI
=
Object
.
assign
({},
messageDefaults
,
payload
)
await
login
({
username
:
mockUser
.
username
,
password
:
mockUser
.
password
})
return
post
(
'
chat.postMessage
'
,
data
,
true
)
const
oldest
=
new
Date
().
toISOString
()
const
result
=
await
post
(
'
chat.postMessage
'
,
data
,
true
)
const
proof
=
new
Promise
((
resolve
,
reject
)
=>
{
let
looked
=
0
const
look
=
setInterval
(
async
()
=>
{
const
{
messages
}
=
await
get
(
'
channels.history
'
,
{
roomId
,
oldest
})
const
found
=
messages
.
some
((
message
:
IMessageReceiptAPI
)
=>
{
return
result
.
message
.
_id
===
message
.
_id
})
if
(
found
||
looked
>
10
)
{
clearInterval
(
look
)
if
(
found
)
resolve
()
else
reject
()
}
looked
++
},
100
)
})
await
proof
return
result
}
/** Update message sent from mock user */
...
...
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