Fix flaky tests

This commit is contained in:
Chocobozzz
2026-08-04 08:58:25 +02:00
parent c2bd457557
commit 0f4144f841
2 changed files with 11 additions and 11 deletions
@@ -101,7 +101,7 @@ describe('Test live socket messages', function () {
}) })
it('Should correctly send views change notification', async function () { it('Should correctly send views change notification', async function () {
this.timeout(60000) this.timeout(90000)
let localLastVideoViewers = 0 let localLastVideoViewers = 0
let remoteLastVideoViewers = 0 let remoteLastVideoViewers = 0
@@ -146,11 +146,11 @@ describe('Test live socket messages', function () {
} }
}, 1000) }, 1000)
await wait(6000) const deadline = Date.now() + 30000
await waitJobs(servers) // oxlint-disable-next-line no-unmodified-loop-condition
while ((localLastVideoViewers !== 2 || remoteLastVideoViewers !== 2) && Date.now() < deadline) {
expect(localLastVideoViewers).to.equal(2) await wait(500)
expect(remoteLastVideoViewers).to.equal(2) }
clearInterval(interval) clearInterval(interval)
await stopFfmpeg(ffmpegCommand) await stopFfmpeg(ffmpegCommand)
@@ -460,7 +460,7 @@ describe('Test video channels', function () {
it('Should report correct channel views per days', async function () { it('Should report correct channel views per days', async function () {
{ {
const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true }) const { data } = await servers[0].channels.listByAccount({ accountName, token: servers[0].accessToken, withStats: true })
for (const channel of data) { for (const channel of data) {
expect(channel).to.haveOwnProperty('viewsPerDay') expect(channel).to.haveOwnProperty('viewsPerDay')
@@ -481,7 +481,7 @@ describe('Test video channels', function () {
// Wait the repeatable job // Wait the repeatable job
await wait(8000) await wait(8000)
const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true }) const { data } = await servers[0].channels.listByAccount({ accountName, token: servers[0].accessToken, withStats: true })
const channelWithView = data.find(channel => channel.id === servers[0].store.channel.id) const channelWithView = data.find(channel => channel.id === servers[0].store.channel.id)
expect(channelWithView.viewsPerDay.slice(-1)[0].views).to.equal(2) expect(channelWithView.viewsPerDay.slice(-1)[0].views).to.equal(2)
} }
@@ -490,7 +490,7 @@ describe('Test video channels', function () {
it('Should report correct total views count', async function () { it('Should report correct total views count', async function () {
// check if there's the property // check if there's the property
{ {
const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true }) const { data } = await servers[0].channels.listByAccount({ accountName, token: servers[0].accessToken, withStats: true })
for (const channel of data) { for (const channel of data) {
expect(channel).to.haveOwnProperty('totalViews') expect(channel).to.haveOwnProperty('totalViews')
@@ -500,14 +500,14 @@ describe('Test video channels', function () {
// Check if the totalViews count can be updated // Check if the totalViews count can be updated
{ {
const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true }) const { data } = await servers[0].channels.listByAccount({ accountName, token: servers[0].accessToken, withStats: true })
const channelWithView = data.find(channel => channel.id === servers[0].store.channel.id) const channelWithView = data.find(channel => channel.id === servers[0].store.channel.id)
expect(channelWithView.totalViews).to.equal(2) expect(channelWithView.totalViews).to.equal(2)
} }
}) })
it('Should report correct videos count', async function () { it('Should report correct videos count', async function () {
const { data } = await servers[0].channels.listByAccount({ accountName, withStats: true }) const { data } = await servers[0].channels.listByAccount({ accountName, token: servers[0].accessToken, withStats: true })
const totoChannel = data.find(c => c.name === 'toto_channel') const totoChannel = data.find(c => c.name === 'toto_channel')
const rootChannel = data.find(c => c.name === 'root_channel') const rootChannel = data.find(c => c.name === 'root_channel')