Skip to content

Commit

Permalink
Fix views tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobozzz committed Jan 17, 2025
1 parent 200e9db commit d16d2e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/tests/src/api/live/live-socket-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,22 @@ describe('Test live socket messages', function () {
expect(localLastVideoViews).to.equal(0)
expect(remoteLastVideoViews).to.equal(0)

await servers[0].views.simulateView({ id: liveVideoUUID })
await servers[1].views.simulateView({ id: liveVideoUUID })

await wait(3000)

await servers[0].views.simulateView({ id: liveVideoUUID })
await servers[1].views.simulateView({ id: liveVideoUUID })

const interval = setInterval(async () => {
try {
await servers[0].views.simulateView({ id: liveVideoUUID, sessionId: 'session1' })
await servers[1].views.simulateView({ id: liveVideoUUID, sessionId: 'session2' })
} catch (err) {
console.error('Cannot simulate view', err)
}
}, 1000)

await wait(6000)
await waitJobs(servers)

expect(localLastVideoViews).to.equal(2)
expect(remoteLastVideoViews).to.equal(2)

clearInterval(interval)
await stopFfmpeg(ffmpegCommand)
})

Expand Down
4 changes: 4 additions & 0 deletions server/core/middlewares/validators/videos/video-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export const videoViewValidator = [
.customSanitizer(toIntOrNull)
.isInt(),

body('sessionId')
.optional()
.isAlphanumeric(),

async (req: express.Request, res: express.Response, next: express.NextFunction) => {
if (areValidationErrors(req, res, { tags })) return
if (!await doesVideoExist(req.params.videoId, res, 'unsafe-only-immutable-attributes')) return
Expand Down

0 comments on commit d16d2e6

Please sign in to comment.