import 'mocha'
import * as chai from 'chai'
-import { getLiveNotificationSocket } from '@shared/extra-utils/socket/socket-io'
import { VideoPrivacy, VideoState } from '@shared/models'
import {
cleanupTests,
{
const videoId = await getVideoIdFromUUID(servers[0].url, liveVideoUUID)
- const localSocket = getLiveNotificationSocket(servers[0].url)
+ const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket()
localSocket.on('state-change', data => localStateChanges.push(data.state))
localSocket.emit('subscribe', { videoId })
}
{
const videoId = await getVideoIdFromUUID(servers[1].url, liveVideoUUID)
- const remoteSocket = getLiveNotificationSocket(servers[1].url)
+ const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket()
remoteSocket.on('state-change', data => remoteStateChanges.push(data.state))
remoteSocket.emit('subscribe', { videoId })
}
{
const videoId = await getVideoIdFromUUID(servers[0].url, liveVideoUUID)
- const localSocket = getLiveNotificationSocket(servers[0].url)
+ const localSocket = servers[0].socketIOCommand.getLiveNotificationSocket()
localSocket.on('views-change', data => { localLastVideoViews = data.views })
localSocket.emit('subscribe', { videoId })
}
{
const videoId = await getVideoIdFromUUID(servers[1].url, liveVideoUUID)
- const remoteSocket = getLiveNotificationSocket(servers[1].url)
+ const remoteSocket = servers[1].socketIOCommand.getLiveNotificationSocket()
remoteSocket.on('views-change', data => { remoteLastVideoViews = data.views })
remoteSocket.emit('subscribe', { videoId })
}
const videoId = await getVideoIdFromUUID(servers[0].url, liveVideoUUID)
- const socket = getLiveNotificationSocket(servers[0].url)
+ const socket = servers[0].socketIOCommand.getLiveNotificationSocket()
socket.on('state-change', data => stateChanges.push(data.state))
socket.emit('subscribe', { videoId })
export * from './overviews'
export * from './search'
export * from './server'
+export * from './socket'
export * from './requests/check-api-params'
export * from './requests/requests'
import { OverviewsCommand } from '../overviews'
import { makeGetRequest } from '../requests/requests'
import { SearchCommand } from '../search'
+import { SocketIOCommand } from '../socket'
import { ConfigCommand } from './config-command'
import { ContactFormCommand } from './contact-form-command'
import { DebugCommand } from './debug-command'
redundancyCommand?: RedundancyCommand
statsCommand?: StatsCommand
configCommand?: ConfigCommand
+ socketIOCommand?: SocketIOCommand
}
function parallelTests () {
server.redundancyCommand = new RedundancyCommand(server)
server.statsCommand = new StatsCommand(server)
server.configCommand = new ConfigCommand(server)
+ server.socketIOCommand = new SocketIOCommand(server)
res(server)
})
--- /dev/null
+export * from './socket-io-command'
--- /dev/null
+import { io } from 'socket.io-client'
+import { AbstractCommand, OverrideCommandOptions } from '../shared'
+
+export class SocketIOCommand extends AbstractCommand {
+
+ getUserNotificationSocket (options: OverrideCommandOptions = {}) {
+ return io(this.server.url + '/user-notifications', {
+ query: { accessToken: this.server.accessToken }
+ })
+ }
+
+ getLiveNotificationSocket () {
+ return io(this.server.url + '/live-videos')
+ }
+}
+++ /dev/null
-import { io } from 'socket.io-client'
-
-function getUserNotificationSocket (serverUrl: string, accessToken: string) {
- return io(serverUrl + '/user-notifications', {
- query: { accessToken }
- })
-}
-
-function getLiveNotificationSocket (serverUrl: string) {
- return io(serverUrl + '/live-videos')
-}
-
-// ---------------------------------------------------------------------------
-
-export {
- getUserNotificationSocket,
- getLiveNotificationSocket
-}
import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests'
import { doubleFollow } from '../server/follows'
import { flushAndRunMultipleServers, ServerInfo } from '../server/servers'
-import { getUserNotificationSocket } from '../socket/socket-io'
import { setAccessTokensToServers, userLogin } from './login'
import { createUser, getMyUserInformation } from './users'
}
{
- const socket = getUserNotificationSocket(servers[0].url, userAccessToken)
+ const socket = servers[0].socketIOCommand.getUserNotificationSocket({ token: userAccessToken })
socket.on('new-notification', n => userNotifications.push(n))
}
{
- const socket = getUserNotificationSocket(servers[0].url, servers[0].accessToken)
+ const socket = servers[0].socketIOCommand.getUserNotificationSocket()
socket.on('new-notification', n => adminNotifications.push(n))
}
if (serversCount > 1) {
- const socket = getUserNotificationSocket(servers[1].url, servers[1].accessToken)
+ const socket = servers[1].socketIOCommand.getUserNotificationSocket()
socket.on('new-notification', n => adminNotificationsServer2.push(n))
}