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
20 changes: 18 additions & 2 deletions .github/workflows/ci-test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
# if building for production on develop branch or release, add suffix for coverage images
DOCKER_TAG_SUFFIX_ROCKETCHAT: ${{ inputs.coverage == matrix.mongodb-version && (github.event_name == 'release' || github.ref == 'refs/heads/develop') && '-cov' || '' }}
MONGODB_VERSION: ${{ matrix.mongodb-version }}
COVERAGE_DIR: '/tmp/coverage/${{ inputs.type }}'
COVERAGE_DIR: '/tmp/coverage/${{ startsWith(inputs.type, ''api'') && ''api'' || inputs.type }}'
COVERAGE_FILE_NAME: '${{ inputs.type }}-${{ matrix.shard }}.json'
COVERAGE_REPORTER: ${{ inputs.coverage == matrix.mongodb-version && 'json' || '' }}

Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
run: echo "DEBUG_LOG_LEVEL=2" >> $GITHUB_ENV

- name: Start httpbin container and wait for it to be ready
if: inputs.type == 'api'
if: inputs.type == 'api' || inputs.type == 'api-livechat'
run: |
docker compose -f docker-compose-ci.yml up -d httpbin

Expand Down Expand Up @@ -227,6 +227,22 @@ jobs:
ls -la $COVERAGE_DIR
exit $s

- name: E2E Test API (Livechat)
if: inputs.type == 'api-livechat'
working-directory: ./apps/meteor
env:
WEBHOOK_TEST_URL: 'http://httpbin'
IS_EE: ${{ inputs.release == 'ee' && 'true' || '' }}
run: |
set -o xtrace

npm run testapi:livechat

docker compose -f ../../docker-compose-ci.yml stop

ls -la $COVERAGE_DIR
exit $s

- name: E2E Test UI (${{ matrix.shard }}/${{ inputs.total-shard }})
if: inputs.type == 'ui'
env:
Expand Down
49 changes: 46 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ jobs:
- type: ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'production' || '' }}

steps:

- uses: actions/checkout@v6

- uses: ./.github/actions/meteor-build
Expand Down Expand Up @@ -511,6 +510,22 @@ jobs:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}

test-api-livechat:
name: 🔨 Test API Livechat (CE)
needs: [checks, build-gh-docker-publish, release-versions]

uses: ./.github/workflows/ci-test-e2e.yml
with:
type: api-livechat
release: ce
node-version: ${{ needs.release-versions.outputs.node-version }}
deno-version: ${{ needs.release-versions.outputs.deno-version }}
lowercase-repo: ${{ needs.release-versions.outputs.lowercase-repo }}
gh-docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
secrets:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}

test-ui:
name: 🔨 Test UI (CE)
needs: [checks, build-gh-docker-publish, release-versions]
Expand Down Expand Up @@ -556,6 +571,26 @@ jobs:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}

test-api-livechat-ee:
name: 🔨 Test API Livechat (EE)
needs: [checks, build-gh-docker-publish, release-versions]

uses: ./.github/workflows/ci-test-e2e.yml
with:
type: api-livechat
release: ee
transporter: 'nats://nats:4222'
enterprise-license: ${{ needs.release-versions.outputs.enterprise-license }}
mongodb-version: "['8.0']"
coverage: '8.0'
node-version: ${{ needs.release-versions.outputs.node-version }}
deno-version: ${{ needs.release-versions.outputs.deno-version }}
lowercase-repo: ${{ needs.release-versions.outputs.lowercase-repo }}
gh-docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
secrets:
CR_USER: ${{ secrets.CR_USER }}
CR_PAT: ${{ secrets.CR_PAT }}

test-ui-ee:
name: 🔨 Test UI (EE)
needs: [checks, build-gh-docker-publish, release-versions]
Expand Down Expand Up @@ -682,7 +717,7 @@ jobs:
report-coverage:
name: 📊 Report Coverage
runs-on: ubuntu-24.04
needs: [release-versions, test-api-ee, test-ui-ee]
needs: [release-versions, test-api-ee, test-api-livechat-ee, test-ui-ee]

steps:
- uses: actions/checkout@v6
Expand Down Expand Up @@ -734,7 +769,7 @@ jobs:
tests-done:
name: ✅ Tests Done
runs-on: ubuntu-24.04-arm
needs: [checks, test-unit, test-api, test-ui, test-api-ee, test-ui-ee, test-federation-matrix]
needs: [checks, test-unit, test-api, test-ui, test-api-ee, test-ui-ee, test-api-livechat, test-api-livechat-ee, test-federation-matrix]
if: always()
steps:
- name: Test finish aggregation
Expand Down Expand Up @@ -763,6 +798,14 @@ jobs:
exit 1
fi

if [[ '${{ needs.test-api-livechat.result }}' != 'success' ]]; then
exit 1
fi

if [[ '${{ needs.test-api-livechat-ee.result }}' != 'success' ]]; then
exit 1
fi

if [[ '${{ needs.test-federation-matrix.result }}' != 'success' ]]; then
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/.mocharc.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ module.exports = /** @satisfies {import('mocha').MochaOptions} */ ({
bail: true,
retries: 0,
file: 'tests/end-to-end/teardown.ts',
spec: ['tests/end-to-end/api/**/*', 'tests/end-to-end/apps/*'],
spec: ['tests/end-to-end/api/*.ts', 'tests/end-to-end/api/helpers/**/*', 'tests/end-to-end/api/methods/**/*', 'tests/end-to-end/apps/*'],
});
14 changes: 14 additions & 0 deletions apps/meteor/.mocharc.api.livechat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

/*
* Mocha configuration for Livechat REST API integration tests.
*/

module.exports = /** @satisfies {import('mocha').MochaOptions} */ ({
...require('./.mocharc.base.json'), // see https://github.com/mochajs/mocha/issues/3916
timeout: 10000,
bail: true,
retries: 0,
file: 'tests/end-to-end/teardown.ts',
spec: ['tests/end-to-end/api/livechat/**/*'],
});
1 change: 1 addition & 0 deletions apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"test:e2e:federation": "playwright test --config=playwright-federation.config.ts",
"test:e2e:nyc": "nyc report --reporter=lcovonly",
"testapi": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha --config ./.mocharc.api.js",
"testapi:livechat": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha --config ./.mocharc.api.livechat.js",
"testunit": "yarn .testunit:definition && yarn .testunit:jest && yarn .testunit:server:cov",
"testunit-watch": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' mocha --watch --config ./.mocharc.js",
"typecheck": "meteor lint && cross-env NODE_OPTIONS=\"--max-old-space-size=8192\" tsc --noEmit --skipLibCheck",
Expand Down
8 changes: 6 additions & 2 deletions apps/meteor/tests/end-to-end/api/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { retry } from './helpers/retry';
import { api, credentials, getCredentials, methodCall, request } from '../../data/api-data';
import { sendSimpleMessage } from '../../data/chat.helper';
import { CI_MAX_ROOMS_PER_GUEST as maxRoomsPerGuest } from '../../data/constants';
import { closeOmnichannelRoom, createAgent, createLivechatRoom, createVisitor } from '../../data/livechat/rooms';
import { closeOmnichannelRoom, createAgent, createLivechatRoom, createVisitor, makeAgentAvailable } from '../../data/livechat/rooms';
import { updatePermission, updateSetting } from '../../data/permissions.helper';
import { createRoom, deleteRoom } from '../../data/rooms.helper';
import { password } from '../../data/user';
Expand Down Expand Up @@ -3389,6 +3389,10 @@ describe('Meteor.methods', () => {
let userCredentials: Credentials;

before(async () => {
await updateSetting('Livechat_enabled', true);
await createAgent();
await makeAgentAvailable();

const visitor = await createVisitor();
room = await createLivechatRoom(visitor.token);
await closeOmnichannelRoom(room._id);
Expand All @@ -3398,7 +3402,7 @@ describe('Meteor.methods', () => {
userCredentials = await login(user.username, password);
});

after(() => Promise.all([deleteUser(user)]));
after(() => Promise.all([deleteUser(user), updateSetting('Livechat_enabled', false)]));

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