tests: streamline webhook tests cleanup by restoring default global preferences
This commit is contained in:
parent
8f7462c39a
commit
b249fdde27
@ -1,6 +1,8 @@
|
|||||||
import { afterAll, afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
import { afterAll, afterEach, beforeAll, describe, expect, it } from '@jest/globals';
|
||||||
import { Request } from 'express';
|
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 { 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 { expectValidationError } from '../../../helpers/assertion-helpers.js';
|
||||||
import {
|
import {
|
||||||
getWebbhookPreferences,
|
getWebbhookPreferences,
|
||||||
@ -10,21 +12,14 @@ import {
|
|||||||
} from '../../../helpers/request-helpers.js';
|
} from '../../../helpers/request-helpers.js';
|
||||||
import { startWebhookServer, stopWebhookServer } from '../../../helpers/test-scenarios.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', () => {
|
describe('Webhook Preferences API Tests', () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
startTestServer();
|
startTestServer();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await restoreDefaultWebhookPreferences();
|
const storageService = container.get(MeetStorageService);
|
||||||
|
await storageService['initializeGlobalPreferences']();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Update webhook preferences', () => {
|
describe('Update webhook preferences', () => {
|
||||||
|
|||||||
@ -3,25 +3,24 @@ import { Request } from 'express';
|
|||||||
import http from 'http';
|
import http from 'http';
|
||||||
import { container } from '../../../src/config/dependency-injector.config.js';
|
import { container } from '../../../src/config/dependency-injector.config.js';
|
||||||
import { MeetStorageService } from '../../../src/services/index.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 {
|
import {
|
||||||
startTestServer,
|
|
||||||
deleteAllRecordings,
|
deleteAllRecordings,
|
||||||
sleep,
|
|
||||||
endMeeting,
|
|
||||||
updateWebbhookPreferences,
|
|
||||||
deleteAllRooms,
|
deleteAllRooms,
|
||||||
deleteRoom,
|
deleteRoom,
|
||||||
disconnectFakeParticipants
|
disconnectFakeParticipants,
|
||||||
|
endMeeting,
|
||||||
|
sleep,
|
||||||
|
startTestServer,
|
||||||
|
updateWebbhookPreferences
|
||||||
} from '../../helpers/request-helpers.js';
|
} from '../../helpers/request-helpers.js';
|
||||||
import { MeetWebhookEvent, MeetWebhookEventType } from '../../../src/typings/ce/webhook.model.js';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
setupSingleRoom,
|
setupSingleRoom,
|
||||||
setupSingleRoomWithRecording,
|
setupSingleRoomWithRecording,
|
||||||
startWebhookServer,
|
startWebhookServer,
|
||||||
stopWebhookServer
|
stopWebhookServer
|
||||||
} from '../../helpers/test-scenarios.js';
|
} from '../../helpers/test-scenarios.js';
|
||||||
import { MeetRecordingInfo, MeetRecordingStatus } from '../../../src/typings/ce/recording.model.js';
|
|
||||||
|
|
||||||
describe('Webhook Integration Tests', () => {
|
describe('Webhook Integration Tests', () => {
|
||||||
let receivedWebhooks: { headers: http.IncomingHttpHeaders; body: MeetWebhookEvent }[] = [];
|
let receivedWebhooks: { headers: http.IncomingHttpHeaders; body: MeetWebhookEvent }[] = [];
|
||||||
@ -51,8 +50,8 @@ describe('Webhook Integration Tests', () => {
|
|||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await stopWebhookServer();
|
await stopWebhookServer();
|
||||||
const defaultPreferences = await storageService['getDefaultPreferences']();
|
await storageService['initializeGlobalPreferences']();
|
||||||
await updateWebbhookPreferences(defaultPreferences.webhooksPreferences);
|
|
||||||
await disconnectFakeParticipants();
|
await disconnectFakeParticipants();
|
||||||
await Promise.all([deleteAllRooms(), deleteAllRecordings()]);
|
await Promise.all([deleteAllRooms(), deleteAllRecordings()]);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user