From 9d4452dddfb15104e1135d9252f6f5bbb87ba97b Mon Sep 17 00:00:00 2001 From: Carlos Santos <4a.santos@gmail.com> Date: Tue, 6 May 2025 17:20:58 +0200 Subject: [PATCH] backend: Add webhook integration tests and update CI workflow for webhooks --- .github/workflows/integration-test.yaml | 52 +++++++++++++++++++ backend/package.json | 1 + .../{api => }/webhooks/webhook.test.ts | 12 ++--- 3 files changed, 59 insertions(+), 6 deletions(-) rename backend/tests/integration/{api => }/webhooks/webhook.test.ts (95%) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 1ace05d..46fb703 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -109,6 +109,58 @@ jobs: fail_on_failure: true require_tests: true + test-webhooks: + name: Webhook Tests + runs-on: ov-actions-runner + steps: + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Setup yarn # Needed for the redlock package + run: npm install -g yarn + - name: Install wait-on + run: npm install -g wait-on + - name: Install LK CLI + run: curl -sSL https://get.livekit.io/cli | bash + - name: Checkout OpenVidu Local Deployment + uses: actions/checkout@v4 + with: + repository: OpenVidu/openvidu-local-deployment + ref: development + path: openvidu-local-deployment + - name: Configure Local Deployment + shell: bash + run: | + cd openvidu-local-deployment/community + ./configure_lan_private_ip_linux.sh + docker compose up -d + + - name: Wait for OpenVidu Local Deployment to Start + run: wait-on --timeout 60000 http://localhost:7880 + - uses: actions/checkout@v4 + - name: Setup OpenVidu Meet + run: | + ./prepare.sh + cd backend + npm install + npm run start:prod & + - name: Wait for OpenVidu Meet to Start + run: wait-on --timeout 30000 http://localhost:6080/meet/health + - name: Run tests + run: | + cd backend + npm run test:integration-webhooks + env: + JEST_JUNIT_OUTPUT_DIR: './reports/' + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: always() + with: + report_paths: '**/reports/junit.xml' + fail_on_failure: true + require_tests: true + test-security: name: Security API Tests runs-on: ov-actions-runner diff --git a/backend/package.json b/backend/package.json index 13cd63b..41c8581 100644 --- a/backend/package.json +++ b/backend/package.json @@ -39,6 +39,7 @@ "test:integration": "node --experimental-vm-modules node_modules/.bin/jest --runInBand --forceExit --testPathPattern \"tests/integration\" --ci --reporters=default --reporters=jest-junit", "test:integration-rooms": "node --experimental-vm-modules node_modules/.bin/jest --runInBand --forceExit --testPathPattern \"tests/integration/api/rooms\" --ci --reporters=default --reporters=jest-junit", "test:integration-recordings": "node --experimental-vm-modules node_modules/.bin/jest --runInBand --forceExit --testPathPattern \"tests/integration/api/recordings\" --ci --reporters=default --reporters=jest-junit", + "test:integration-webhooks": "node --experimental-vm-modules node_modules/.bin/jest --runInBand --forceExit --testPathPattern \"tests/integration/webhooks\" --ci --reporters=default --reporters=jest-junit", "test:integration-security": "node --experimental-vm-modules node_modules/.bin/jest --runInBand --forceExit --testPathPattern \"tests/integration/api/security\" --ci --reporters=default --reporters=jest-junit", "lint:fix": "eslint src --fix", "format:code": "prettier --ignore-path .gitignore --write '**/*.{ts,js,json,md}'" diff --git a/backend/tests/integration/api/webhooks/webhook.test.ts b/backend/tests/integration/webhooks/webhook.test.ts similarity index 95% rename from backend/tests/integration/api/webhooks/webhook.test.ts rename to backend/tests/integration/webhooks/webhook.test.ts index 0258116..53fe2b3 100644 --- a/backend/tests/integration/api/webhooks/webhook.test.ts +++ b/backend/tests/integration/webhooks/webhook.test.ts @@ -1,24 +1,24 @@ import { afterAll, beforeAll, beforeEach, describe, expect, it } from '@jest/globals'; 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 { container } from '../../../src/config/dependency-injector.config.js'; +import { MeetStorageService } from '../../../src/services/index.js'; import { startTestServer, deleteAllRecordings, sleep, endMeeting, updateWebbhookPreferences -} from '../../../helpers/request-helpers'; -import { MeetWebhookEvent, MeetWebhookEventType } from '../../../../src/typings/ce/webhook.model.js'; +} 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'; +} 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 }[] = [];