tests: streamline webhook tests cleanup by restoring default global preferences

This commit is contained in:
juancarmore 2025-08-27 17:46:38 +02:00
parent 8f7462c39a
commit b249fdde27
2 changed files with 13 additions and 19 deletions

View File

@ -1,6 +1,8 @@
import { afterAll, afterEach, beforeAll, describe, expect, it } from '@jest/globals';
import { Request } from 'express';
import { container } from '../../../../src/config/dependency-injector.config.js';
import { MEET_INITIAL_WEBHOOK_ENABLED, MEET_INITIAL_WEBHOOK_URL } from '../../../../src/environment.js';
import { MeetStorageService } from '../../../../src/services/index.js';
import { expectValidationError } from '../../../helpers/assertion-helpers.js';
import {
getWebbhookPreferences,
@ -10,21 +12,14 @@ import {
} from '../../../helpers/request-helpers.js';
import { startWebhookServer, stopWebhookServer } from '../../../helpers/test-scenarios.js';
const restoreDefaultWebhookPreferences = async () => {
const defaultPreferences = {
enabled: MEET_INITIAL_WEBHOOK_ENABLED === 'true',
url: MEET_INITIAL_WEBHOOK_URL
};
await updateWebbhookPreferences(defaultPreferences);
};
describe('Webhook Preferences API Tests', () => {
beforeAll(() => {
startTestServer();
});
afterEach(async () => {
await restoreDefaultWebhookPreferences();
const storageService = container.get(MeetStorageService);
await storageService['initializeGlobalPreferences']();
});
describe('Update webhook preferences', () => {

View File

@ -3,25 +3,24 @@ import { Request } from 'express';
import http from 'http';
import { container } from '../../../src/config/dependency-injector.config.js';
import { MeetStorageService } from '../../../src/services/index.js';
import { MeetRecordingInfo, MeetRecordingStatus } from '../../../src/typings/ce/recording.model.js';
import { MeetWebhookEvent, MeetWebhookEventType } from '../../../src/typings/ce/webhook.model.js';
import {
startTestServer,
deleteAllRecordings,
sleep,
endMeeting,
updateWebbhookPreferences,
deleteAllRooms,
deleteRoom,
disconnectFakeParticipants
disconnectFakeParticipants,
endMeeting,
sleep,
startTestServer,
updateWebbhookPreferences
} from '../../helpers/request-helpers.js';
import { MeetWebhookEvent, MeetWebhookEventType } from '../../../src/typings/ce/webhook.model.js';
import {
setupSingleRoom,
setupSingleRoomWithRecording,
startWebhookServer,
stopWebhookServer
} from '../../helpers/test-scenarios.js';
import { MeetRecordingInfo, MeetRecordingStatus } from '../../../src/typings/ce/recording.model.js';
describe('Webhook Integration Tests', () => {
let receivedWebhooks: { headers: http.IncomingHttpHeaders; body: MeetWebhookEvent }[] = [];
@ -51,8 +50,8 @@ describe('Webhook Integration Tests', () => {
afterAll(async () => {
await stopWebhookServer();
const defaultPreferences = await storageService['getDefaultPreferences']();
await updateWebbhookPreferences(defaultPreferences.webhooksPreferences);
await storageService['initializeGlobalPreferences']();
await disconnectFakeParticipants();
await Promise.all([deleteAllRooms(), deleteAllRecordings()]);
});