Fix views tests
This commit is contained in:
parent
200e9dbd3c
commit
d16d2e6744
|
@ -134,19 +134,22 @@ describe('Test live socket messages', function () {
|
||||||
expect(localLastVideoViews).to.equal(0)
|
expect(localLastVideoViews).to.equal(0)
|
||||||
expect(remoteLastVideoViews).to.equal(0)
|
expect(remoteLastVideoViews).to.equal(0)
|
||||||
|
|
||||||
await servers[0].views.simulateView({ id: liveVideoUUID })
|
const interval = setInterval(async () => {
|
||||||
await servers[1].views.simulateView({ id: liveVideoUUID })
|
try {
|
||||||
|
await servers[0].views.simulateView({ id: liveVideoUUID, sessionId: 'session1' })
|
||||||
await wait(3000)
|
await servers[1].views.simulateView({ id: liveVideoUUID, sessionId: 'session2' })
|
||||||
|
} catch (err) {
|
||||||
await servers[0].views.simulateView({ id: liveVideoUUID })
|
console.error('Cannot simulate view', err)
|
||||||
await servers[1].views.simulateView({ id: liveVideoUUID })
|
}
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
await wait(6000)
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
|
|
||||||
expect(localLastVideoViews).to.equal(2)
|
expect(localLastVideoViews).to.equal(2)
|
||||||
expect(remoteLastVideoViews).to.equal(2)
|
expect(remoteLastVideoViews).to.equal(2)
|
||||||
|
|
||||||
|
clearInterval(interval)
|
||||||
await stopFfmpeg(ffmpegCommand)
|
await stopFfmpeg(ffmpegCommand)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,10 @@ export const videoViewValidator = [
|
||||||
.customSanitizer(toIntOrNull)
|
.customSanitizer(toIntOrNull)
|
||||||
.isInt(),
|
.isInt(),
|
||||||
|
|
||||||
|
body('sessionId')
|
||||||
|
.optional()
|
||||||
|
.isAlphanumeric(),
|
||||||
|
|
||||||
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||||
if (areValidationErrors(req, res, { tags })) return
|
if (areValidationErrors(req, res, { tags })) return
|
||||||
if (!await doesVideoExist(req.params.videoId, res, 'unsafe-only-immutable-attributes')) return
|
if (!await doesVideoExist(req.params.videoId, res, 'unsafe-only-immutable-attributes')) return
|
||||||
|
|
Loading…
Reference in New Issue