diff --git a/src/test/integration/logs.test.ts b/src/test/integration/logs.test.ts index a4e68c581..69fdd3225 100644 --- a/src/test/integration/logs.test.ts +++ b/src/test/integration/logs.test.ts @@ -116,11 +116,11 @@ describe('LogDatabase CRUD', () => { await new Promise((resolve) => setTimeout(resolve, 1000)) // Delay to allow log to be processed // Define the time frame for the log retrieval - const startTime = new Date(Date.now() - 5000) // 5 seconds ago + const startTime = new Date(Date.now() - 3000) // 3 seconds ago const endTime = new Date() // current time // Retrieve the latest log entry - let logs = await database.logs.retrieveMultipleLogs(startTime, endTime, 10) + let logs = await database.logs.retrieveMultipleLogs(startTime, endTime, 200) logs = logs.filter((log) => log.message === newLogEntry.message) expect(logs?.length).to.equal(1) @@ -145,11 +145,15 @@ describe('LogDatabase CRUD', () => { await new Promise((resolve) => setTimeout(resolve, 1000)) // Delay to allow log to be processed // Define the time frame for the log retrieval - const startTime = new Date(Date.now() - 5000) // 5 seconds ago + const startTime = new Date(Date.now() - 3000) // 3 seconds ago const endTime = new Date() // current time + // we cannot predict the amount of logs wriiten on DB (Typesense adds tons on its own), so we need: + // 1 ) set a smaller interval + // 2 ) retrieve a bigger number of logs + // 3 ) filter the appropriate message // Retrieve the latest log entry - let logs = await database.logs.retrieveMultipleLogs(startTime, endTime, 10) + let logs = await database.logs.retrieveMultipleLogs(startTime, endTime, 200) logs = logs.filter((log) => log.message.includes(newLogEntry.message)) expect(logs?.length).to.equal(1)