From c6720c7f04814b28b2a16ca323ffccaab314e4d5 Mon Sep 17 00:00:00 2001 From: Michal Orlik Date: Thu, 20 Jun 2024 15:55:52 +0200 Subject: [PATCH] test fixes --- src/systems/raffles.ts | 12 +++++++----- .../community#192_exclude_user_from_permission.js | 1 + ...t#4175_raffleAnnounceShouldContainTotalEntries.js | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/systems/raffles.ts b/src/systems/raffles.ts index 659ef3926a88..6ed8cd139556 100644 --- a/src/systems/raffles.ts +++ b/src/systems/raffles.ts @@ -193,16 +193,18 @@ class Raffles extends System { announceNewEntriesCount = 0; } - async announce () { + async announce (skipLock = false) { if (!isDbConnected) { return; } - if (announceMutex.isLocked()) { - return; + if (!skipLock) { + if (announceMutex.isLocked()) { + return; + } + await announceMutex.acquire(); + setTimeout(() => announceMutex.release(), 60000); } - await announceMutex.acquire(); - setTimeout(() => announceMutex.release(), 60000); const raffle = await AppDataSource.getRepository(Raffle).findOne({ where: { winner: IsNull(), isClosed: false }, relations: ['participants'] }); const isTimeToAnnounce = new Date().getTime() - new Date(this.lastAnnounce).getTime() >= (this.raffleAnnounceInterval * 60 * 1000); diff --git a/test/tests/permissions/community#192_exclude_user_from_permission.js b/test/tests/permissions/community#192_exclude_user_from_permission.js index 37d47ea9fb08..bfa242cead54 100644 --- a/test/tests/permissions/community#192_exclude_user_from_permission.js +++ b/test/tests/permissions/community#192_exclude_user_from_permission.js @@ -41,6 +41,7 @@ describe('Permissions - https://community.sogebot.xyz/t/spotify-user-banlist/192 userIds: [], excludeUserIds: ['7'], filters: [], + scopes: [], }); }); diff --git a/test/tests/raffles/feat#4175_raffleAnnounceShouldContainTotalEntries.js b/test/tests/raffles/feat#4175_raffleAnnounceShouldContainTotalEntries.js index 9a2c6aee1562..86a66f172dcb 100644 --- a/test/tests/raffles/feat#4175_raffleAnnounceShouldContainTotalEntries.js +++ b/test/tests/raffles/feat#4175_raffleAnnounceShouldContainTotalEntries.js @@ -68,7 +68,7 @@ describe('Raffles - announce should contain total entries #4175 - @func3', () => raffles.lastAnnounceMessageCount = 0; raffles.lastAnnounce = 0; raffles.raffleAnnounceMessageInterval = 0; - await raffles.announce(); + await raffles.announce(true); await message.isSentRaw('Raffle is running (150 entries). To enter type "!winme <1-100>". Raffle is opened for everyone.', { userName: '__bot__' }) }); });