Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
LINAGORA
L
LGS
Labs
hublot
Commits
e11eb7fd
Commit
e11eb7fd
authored
Oct 13, 2017
by
Yoann HOUPERT
Browse files
Add disconnect test
parent
3d51d240
Pipeline
#3627
passed with stage
in 46 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
6 deletions
+57
-6
client/controller/controller.js
client/controller/controller.js
+5
-1
client/controller/controller.test.js
client/controller/controller.test.js
+11
-0
client/robot/robot.js
client/robot/robot.js
+9
-3
client/robot/robot.test.js
client/robot/robot.test.js
+32
-2
No files found.
client/controller/controller.js
View file @
e11eb7fd
...
@@ -49,8 +49,12 @@ robotController = {
...
@@ -49,8 +49,12 @@ robotController = {
});
});
},
},
getDisconnectButton
:
()
=>
{
return
document
.
getElementsByClassName
(
'
conference-user-control-bar
'
)[
0
].
childNodes
[
0
].
childNodes
[
2
].
childNodes
[
0
];
// Check issue #53
},
disconnect
:
()
=>
{
disconnect
:
()
=>
{
angular
.
element
(
document
.
getElementsByClassName
(
'
conference-user-control-bar
'
)[
0
].
childNodes
[
0
].
childNodes
[
2
].
childNodes
[
0
]
).
scope
().
leaveConference
();
angular
.
element
(
robotController
.
getDisconnectButton
()
).
scope
().
leaveConference
();
},
},
onAttendeePush
:
()
=>
{},
onAttendeePush
:
()
=>
{},
...
...
client/controller/controller.test.js
View file @
e11eb7fd
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
// Let's do some simple mocking of client-side services
// Let's do some simple mocking of client-side services
const
angular
=
{
const
angular
=
{
disconnected
:
false
,
registeredEvents
:
{},
registeredEvents
:
{},
element
:
()
=>
({
element
:
()
=>
({
scope
:
()
=>
({
scope
:
()
=>
({
...
@@ -10,6 +11,9 @@ const angular = {
...
@@ -10,6 +11,9 @@ const angular = {
$on
:
(
event
,
f
)
=>
{
$on
:
(
event
,
f
)
=>
{
angular
.
registeredEvents
[
event
]
=
f
;
angular
.
registeredEvents
[
event
]
=
f
;
}
}
},
leaveConference
:
()
=>
{
angular
.
disconnected
=
true
;
}
}
}),
}),
injector
:
()
=>
({
injector
:
()
=>
({
...
@@ -65,6 +69,7 @@ describe('client/controller', () => {
...
@@ -65,6 +69,7 @@ describe('client/controller', () => {
const
participants
=
global
.
robotController
.
getParticipants
();
const
participants
=
global
.
robotController
.
getParticipants
();
expect
(
participants
).
not
.
toEqual
(
expect
.
arrayContaining
([
'
nostream
'
]));
expect
(
participants
).
not
.
toEqual
(
expect
.
arrayContaining
([
'
nostream
'
]));
expect
(
participants
).
toHaveLength
(
3
);
});
});
test
(
'
should return the Streams of the participant
'
,
()
=>
{
test
(
'
should return the Streams of the participant
'
,
()
=>
{
...
@@ -116,4 +121,10 @@ describe('client/controller', () => {
...
@@ -116,4 +121,10 @@ describe('client/controller', () => {
expect
(
eventFired
).
toBe
(
true
);
expect
(
eventFired
).
toBe
(
true
);
});
});
test
(
'
should be disconnected on disconnect
'
,
()
=>
{
global
.
robotController
.
getDisconnectButton
=
()
=>
{};
// Mock of hubl.in getDisconnectButton
global
.
robotController
.
disconnect
();
expect
(
angular
.
disconnected
).
toBe
(
true
);
});
});
});
client/robot/robot.js
View file @
e11eb7fd
...
@@ -13,6 +13,7 @@ robotController.external.load(config);
...
@@ -13,6 +13,7 @@ robotController.external.load(config);
robot
=
{
robot
=
{
recordedParticipantsWS
:
{},
recordedParticipantsWS
:
{},
participantsMediaRecorders
:
{},
participantsMediaRecorders
:
{},
isDisconnected
:
false
,
processAudio
(
stream
,
callback
,
interval
)
{
processAudio
(
stream
,
callback
,
interval
)
{
const
mediaRecorder
=
new
MediaRecorder
(
stream
);
const
mediaRecorder
=
new
MediaRecorder
(
stream
);
...
@@ -89,8 +90,8 @@ robot = {
...
@@ -89,8 +90,8 @@ robot = {
},
},
checkDisconnect
()
{
checkDisconnect
()
{
if
(
robotController
.
getParticipant
Number
().
length
===
1
)
{
if
(
robotController
.
getParticipant
s
().
length
===
1
)
{
robot
Controller
.
disconnect
();
robot
.
stop
();
}
}
},
},
...
@@ -131,7 +132,12 @@ robot = {
...
@@ -131,7 +132,12 @@ robot = {
}
}
// Wait 5 minute before leaving a room if alone
// Wait 5 minute before leaving a room if alone
setTimeout
(
robot
.
checkDisconnect
(),
300000
);
setTimeout
(
robot
.
checkDisconnect
,
300000
);
},
stop
:
()
=>
{
robot
.
isDisconnected
=
true
;
robotController
.
disconnect
();
}
}
};
};
...
...
client/robot/robot.test.js
View file @
e11eb7fd
...
@@ -41,6 +41,13 @@ describe('client/robot', () => {
...
@@ -41,6 +41,13 @@ describe('client/robot', () => {
};
};
global
.
MediaRecorder
.
instances
=
{};
global
.
MediaRecorder
.
instances
=
{};
global
.
_setTimeoutCalls
=
[];
global
.
setTimeout
=
function
(
f
,
timeout
)
{
global
.
_setTimeoutCalls
.
push
([
f
,
timeout
]);
};
global
.
isDisconnected
=
false
;
global
.
robotController
=
{
global
.
robotController
=
{
external
:
{
external
:
{
load
:
()
=>
{}
load
:
()
=>
{}
...
@@ -52,8 +59,9 @@ describe('client/robot', () => {
...
@@ -52,8 +59,9 @@ describe('client/robot', () => {
'
someid2
'
'
someid2
'
],
],
getRemoteStream
:
id
=>
({
type
:
'
RemoteStream
'
,
id
}),
getRemoteStream
:
id
=>
({
type
:
'
RemoteStream
'
,
id
}),
getParticipantNumber
:
()
=>
3
,
disconnect
:
()
=>
{
disconnect
:
()
=>
{}
global
.
isDisconnected
=
true
;
}
};
};
global
.
robotLib
=
{
global
.
robotLib
=
{
...
@@ -74,6 +82,11 @@ describe('client/robot', () => {
...
@@ -74,6 +82,11 @@ describe('client/robot', () => {
expect
(
global
.
robot
).
toBeDefined
();
expect
(
global
.
robot
).
toBeDefined
();
});
});
test
(
'
should set a timeout for disconnection
'
,
()
=>
{
global
.
robot
.
start
();
expect
(
global
.
_setTimeoutCalls
).
toEqual
(
expect
.
arrayContaining
([[
global
.
robot
.
checkDisconnect
,
300000
]]));
});
test
(
'
should return a started mediaRecorder on `processAudio`
'
,
()
=>
{
test
(
'
should return a started mediaRecorder on `processAudio`
'
,
()
=>
{
const
res
=
global
.
robot
.
processAudio
({
const
res
=
global
.
robot
.
processAudio
({
type
:
'
stream
'
type
:
'
stream
'
...
@@ -134,6 +147,23 @@ describe('client/robot', () => {
...
@@ -134,6 +147,23 @@ describe('client/robot', () => {
expect
(
sttMock
.
wsMock
.
status
).
toBe
(
'
closed
'
);
expect
(
sttMock
.
wsMock
.
status
).
toBe
(
'
closed
'
);
});
});
test
(
'
should not disconnected with more than one user
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robotController
.
onAttendeeRemove
({},
{
easyrtcid
:
'
someid1
'
});
expect
(
global
.
isDisconnected
).
toBe
(
false
);
});
test
(
'
should disconnected without user
'
,
()
=>
{
global
.
robotController
.
getParticipants
=
function
()
{
// Redefine getParticipants for one user
return
[
global
.
robotController
.
getMyId
()];
};
global
.
robot
.
start
();
global
.
robotController
.
onAttendeeRemove
({},
{
easyrtcid
:
'
someid1
'
});
expect
(
global
.
isDisconnected
).
toBe
(
true
);
});
test
(
'
should try to reopen a stt ws on error
'
,
()
=>
{
test
(
'
should try to reopen a stt ws on error
'
,
()
=>
{
global
.
robot
.
start
();
global
.
robot
.
start
();
...
...
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