Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/bot/src/bot/start/initializer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const birthdaySchedulerStopMock = jest.fn()
const modDigestSchedulerStopMock = jest.fn()
const aiDevToolkitStopMock = jest.fn()
const dependencyCheckStopMock = jest.fn()
const weeklyDigestStartMock = jest.fn()
const weeklyDigestStopMock = jest.fn()
const criativariaLiveNotifStopMock = jest.fn()
const stopTwitchServiceMock = jest.fn()

jest.mock('@lucky/shared/utils', () => ({
Expand Down Expand Up @@ -114,6 +117,20 @@ jest.mock('../../services/DependencyCheckService', () => ({
},
}))

jest.mock('../../services/WeeklyDigestService', () => ({
weeklyDigestService: {
start: (...args: unknown[]) => weeklyDigestStartMock(...args),
Comment thread
LucasSantana-Dev marked this conversation as resolved.
stop: (...args: unknown[]) => weeklyDigestStopMock(...args),
},
}))

jest.mock('../../services/CriativariaLiveNotificationService', () => ({
criativariaLiveNotificationService: {
start: jest.fn(),
stop: (...args: unknown[]) => criativariaLiveNotifStopMock(...args),
Comment thread
LucasSantana-Dev marked this conversation as resolved.
Comment thread
LucasSantana-Dev marked this conversation as resolved.
},
}))

jest.mock('../../twitch', () => ({
stopTwitchService: (...args: unknown[]) => stopTwitchServiceMock(...args),
}))
Expand Down Expand Up @@ -430,6 +447,7 @@ describe('BotInitializer', () => {
expect(modDigestSchedulerStopMock).toHaveBeenCalled()
expect(aiDevToolkitStopMock).toHaveBeenCalled()
expect(dependencyCheckStopMock).toHaveBeenCalled()
expect(weeklyDigestStopMock).toHaveBeenCalled()
expect(stopTwitchServiceMock).toHaveBeenCalled()
expect(musicWatchdogStopMock).toHaveBeenCalled()
expect(musicWatchdogStopPeriodicScanMock).toHaveBeenCalled()
Expand All @@ -445,6 +463,7 @@ describe('BotInitializer', () => {
['modDigestSchedulerService.stop', modDigestSchedulerStopMock],
['aiDevToolkitService.stop', aiDevToolkitStopMock],
['dependencyCheckService.stop', dependencyCheckStopMock],
['weeklyDigestService.stop', weeklyDigestStopMock],
['stopTwitchService', stopTwitchServiceMock],
['stopOrphanSessionMonitor', musicWatchdogStopMock],
['stopPeriodicScan', musicWatchdogStopPeriodicScanMock],
Expand Down
11 changes: 11 additions & 0 deletions packages/bot/src/bot/start/initializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import { aiDevToolkitService } from '../../services/AiDevToolkitService'
import { dependencyCheckService } from '../../services/DependencyCheckService'
import { criativariaLiveNotificationService } from '../../services/CriativariaLiveNotificationService'
import { weeklyDigestService } from '../../services/WeeklyDigestService'
import { stopTwitchService } from '../../twitch'
import { stopBatchJobWorker } from '../../workers/batchJobWorker'
import { setClient } from '../clientStore'
Expand Down Expand Up @@ -136,6 +137,7 @@
await startClient({ client: this.client })
startMetricsServer(this.client)
await setupWebMusicHandler(this.client)
weeklyDigestService.start(this.client)
}
this.setInitializationState()

Expand Down Expand Up @@ -185,7 +187,7 @@
return this.isInitialized
}

async shutdown(): Promise<void> {

Check warning on line 190 in packages/bot/src/bot/start/initializer.ts

View workflow job for this annotation

GitHub Actions / Checks

Async method 'shutdown' has a complexity of 17. Maximum allowed is 15
// Stop presence rotation first (following #1157 pattern)
try {
stopPresenceRotation()
Expand Down Expand Up @@ -240,6 +242,15 @@
})
}

try {
weeklyDigestService.stop()
} catch (error) {
errorLog({
message: 'Error stopping weekly digest service:',
error,
})
}

try {
stopTwitchService()
} catch (error) {
Expand Down
Loading
Loading