Skip to content

Commit 3c30636

Browse files
authored
test: Separate livechat API tests (#39114)
1 parent a5aac0c commit 3c30636

File tree

6 files changed

+86
-8
lines changed

6 files changed

+86
-8
lines changed

.github/workflows/ci-test-e2e.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
# if building for production on develop branch or release, add suffix for coverage images
7575
DOCKER_TAG_SUFFIX_ROCKETCHAT: ${{ inputs.coverage == matrix.mongodb-version && (github.event_name == 'release' || github.ref == 'refs/heads/develop') && '-cov' || '' }}
7676
MONGODB_VERSION: ${{ matrix.mongodb-version }}
77-
COVERAGE_DIR: '/tmp/coverage/${{ inputs.type }}'
77+
COVERAGE_DIR: '/tmp/coverage/${{ startsWith(inputs.type, ''api'') && ''api'' || inputs.type }}'
7878
COVERAGE_FILE_NAME: '${{ inputs.type }}-${{ matrix.shard }}.json'
7979
COVERAGE_REPORTER: ${{ inputs.coverage == matrix.mongodb-version && 'json' || '' }}
8080

@@ -169,7 +169,7 @@ jobs:
169169
run: echo "DEBUG_LOG_LEVEL=2" >> $GITHUB_ENV
170170

171171
- name: Start httpbin container and wait for it to be ready
172-
if: inputs.type == 'api'
172+
if: inputs.type == 'api' || inputs.type == 'api-livechat'
173173
run: |
174174
docker compose -f docker-compose-ci.yml up -d httpbin
175175
@@ -227,6 +227,22 @@ jobs:
227227
ls -la $COVERAGE_DIR
228228
exit $s
229229
230+
- name: E2E Test API (Livechat)
231+
if: inputs.type == 'api-livechat'
232+
working-directory: ./apps/meteor
233+
env:
234+
WEBHOOK_TEST_URL: 'http://httpbin'
235+
IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }}
236+
run: |
237+
set -o xtrace
238+
239+
npm run testapi:livechat
240+
241+
docker compose -f ../../docker-compose-ci.yml stop
242+
243+
ls -la $COVERAGE_DIR
244+
exit $s
245+
230246
- name: E2E Test UI (${{ matrix.shard }}/${{ inputs.total-shard }})
231247
if: inputs.type == 'ui'
232248
env:

.github/workflows/ci.yml

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ jobs:
253253
- type: ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'production' || '' }}
254254

255255
steps:
256-
257256
- uses: actions/checkout@v6
258257

259258
- uses: ./.github/actions/meteor-build
@@ -511,6 +510,22 @@ jobs:
511510
CR_USER: ${{ secrets.CR_USER }}
512511
CR_PAT: ${{ secrets.CR_PAT }}
513512

513+
test-api-livechat:
514+
name: 🔨 Test API Livechat (CE)
515+
needs: [checks, build-gh-docker-publish, release-versions]
516+
517+
uses: ./.github/workflows/ci-test-e2e.yml
518+
with:
519+
type: api-livechat
520+
release: ce
521+
node-version: ${{ needs.release-versions.outputs.node-version }}
522+
deno-version: ${{ needs.release-versions.outputs.deno-version }}
523+
lowercase-repo: ${{ needs.release-versions.outputs.lowercase-repo }}
524+
gh-docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
525+
secrets:
526+
CR_USER: ${{ secrets.CR_USER }}
527+
CR_PAT: ${{ secrets.CR_PAT }}
528+
514529
test-ui:
515530
name: 🔨 Test UI (CE)
516531
needs: [checks, build-gh-docker-publish, release-versions]
@@ -556,6 +571,26 @@ jobs:
556571
CR_USER: ${{ secrets.CR_USER }}
557572
CR_PAT: ${{ secrets.CR_PAT }}
558573

574+
test-api-livechat-ee:
575+
name: 🔨 Test API Livechat (EE)
576+
needs: [checks, build-gh-docker-publish, release-versions]
577+
578+
uses: ./.github/workflows/ci-test-e2e.yml
579+
with:
580+
type: api-livechat
581+
release: ee
582+
transporter: 'nats://nats:4222'
583+
enterprise-license: ${{ needs.release-versions.outputs.enterprise-license }}
584+
mongodb-version: "['8.0']"
585+
coverage: '8.0'
586+
node-version: ${{ needs.release-versions.outputs.node-version }}
587+
deno-version: ${{ needs.release-versions.outputs.deno-version }}
588+
lowercase-repo: ${{ needs.release-versions.outputs.lowercase-repo }}
589+
gh-docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
590+
secrets:
591+
CR_USER: ${{ secrets.CR_USER }}
592+
CR_PAT: ${{ secrets.CR_PAT }}
593+
559594
test-ui-ee:
560595
name: 🔨 Test UI (EE)
561596
needs: [checks, build-gh-docker-publish, release-versions]
@@ -682,7 +717,7 @@ jobs:
682717
report-coverage:
683718
name: 📊 Report Coverage
684719
runs-on: ubuntu-24.04
685-
needs: [release-versions, test-api-ee, test-ui-ee]
720+
needs: [release-versions, test-api-ee, test-api-livechat-ee, test-ui-ee]
686721

687722
steps:
688723
- uses: actions/checkout@v6
@@ -734,7 +769,7 @@ jobs:
734769
tests-done:
735770
name: ✅ Tests Done
736771
runs-on: ubuntu-24.04-arm
737-
needs: [checks, test-unit, test-api, test-ui, test-api-ee, test-ui-ee, test-federation-matrix]
772+
needs: [checks, test-unit, test-api, test-ui, test-api-ee, test-ui-ee, test-api-livechat, test-api-livechat-ee, test-federation-matrix]
738773
if: always()
739774
steps:
740775
- name: Test finish aggregation
@@ -763,6 +798,14 @@ jobs:
763798
exit 1
764799
fi
765800
801+
if [[ '${{ needs.test-api-livechat.result }}' != 'success' ]]; then
802+
exit 1
803+
fi
804+
805+
if [[ '${{ needs.test-api-livechat-ee.result }}' != 'success' ]]; then
806+
exit 1
807+
fi
808+
766809
if [[ '${{ needs.test-federation-matrix.result }}' != 'success' ]]; then
767810
exit 1
768811
fi

apps/meteor/.mocharc.api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ module.exports = /** @satisfies {import('mocha').MochaOptions} */ ({
1010
bail: true,
1111
retries: 0,
1212
file: 'tests/end-to-end/teardown.ts',
13-
spec: ['tests/end-to-end/api/**/*', 'tests/end-to-end/apps/*'],
13+
spec: ['tests/end-to-end/api/*.ts', 'tests/end-to-end/api/helpers/**/*', 'tests/end-to-end/api/methods/**/*', 'tests/end-to-end/apps/*'],
1414
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
/*
4+
* Mocha configuration for Livechat REST API integration tests.
5+
*/
6+
7+
module.exports = /** @satisfies {import('mocha').MochaOptions} */ ({
8+
...require('./.mocharc.base.json'), // see https://github.com/mochajs/mocha/issues/3916
9+
timeout: 10000,
10+
bail: true,
11+
retries: 0,
12+
file: 'tests/end-to-end/teardown.ts',
13+
spec: ['tests/end-to-end/api/livechat/**/*'],
14+
});

apps/meteor/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"test:e2e:federation": "playwright test --config=playwright-federation.config.ts",
5656
"test:e2e:nyc": "nyc report --reporter=lcovonly",
5757
"testapi": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha --config ./.mocharc.api.js",
58+
"testapi:livechat": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha --config ./.mocharc.api.livechat.js",
5859
"testunit": "yarn .testunit:definition && yarn .testunit:jest && yarn .testunit:server:cov",
5960
"testunit-watch": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha --watch --config ./.mocharc.js",
6061
"typecheck": "meteor lint && cross-env NODE_OPTIONS=\"--max-old-space-size=8192\" tsc --noEmit --skipLibCheck",

apps/meteor/tests/end-to-end/api/methods.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { retry } from './helpers/retry';
88
import { api, credentials, getCredentials, methodCall, request } from '../../data/api-data';
99
import { sendSimpleMessage } from '../../data/chat.helper';
1010
import { CI_MAX_ROOMS_PER_GUEST as maxRoomsPerGuest } from '../../data/constants';
11-
import { closeOmnichannelRoom, createAgent, createLivechatRoom, createVisitor } from '../../data/livechat/rooms';
11+
import { closeOmnichannelRoom, createAgent, createLivechatRoom, createVisitor, makeAgentAvailable } from '../../data/livechat/rooms';
1212
import { updatePermission, updateSetting } from '../../data/permissions.helper';
1313
import { createRoom, deleteRoom } from '../../data/rooms.helper';
1414
import { password } from '../../data/user';
@@ -3389,6 +3389,10 @@ describe('Meteor.methods', () => {
33893389
let userCredentials: Credentials;
33903390

33913391
before(async () => {
3392+
await updateSetting('Livechat_enabled', true);
3393+
await createAgent();
3394+
await makeAgentAvailable();
3395+
33923396
const visitor = await createVisitor();
33933397
room = await createLivechatRoom(visitor.token);
33943398
await closeOmnichannelRoom(room._id);
@@ -3398,7 +3402,7 @@ describe('Meteor.methods', () => {
33983402
userCredentials = await login(user.username, password);
33993403
});
34003404

3401-
after(() => Promise.all([deleteUser(user)]));
3405+
after(() => Promise.all([deleteUser(user), updateSetting('Livechat_enabled', false)]));
34023406

34033407
it('should not allow an agent to join a closed livechat room', async () => {
34043408
await request

0 commit comments

Comments
 (0)