Fix views tests

This commit is contained in:
Chocobozzz 2025-01-17 16:00:49 +01:00
parent 200e9dbd3c
commit d16d2e6744
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 14 additions and 7 deletions

View File

@ -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)
})

View File

@ -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