snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 1s
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
import { expect } from 'chai';
|
||||
import p from 'proxyquire';
|
||||
import sinon from 'sinon';
|
||||
|
||||
const modelsMock = {
|
||||
Users: {
|
||||
findOneById: sinon.stub(),
|
||||
},
|
||||
LivechatVisitors: {
|
||||
findOneById: sinon.stub(),
|
||||
},
|
||||
};
|
||||
|
||||
const settingsGetMock = {
|
||||
get: sinon.stub(),
|
||||
};
|
||||
|
||||
const { parseTranscriptRequest } = p.noCallThru().load('../../../../../server/lib/omnichannel/parseTranscriptRequest', {
|
||||
'@rocket.chat/models': modelsMock,
|
||||
'../../settings': { settings: settingsGetMock },
|
||||
});
|
||||
|
||||
describe('parseTranscriptRequest', () => {
|
||||
beforeEach(() => {
|
||||
settingsGetMock.get.reset();
|
||||
modelsMock.Users.findOneById.reset();
|
||||
modelsMock.LivechatVisitors.findOneById.reset();
|
||||
});
|
||||
|
||||
it('should return `options` param with no changes when Livechat_enable_transcript setting is true', async () => {
|
||||
settingsGetMock.get.withArgs('Livechat_enable_transcript').returns(true);
|
||||
const options = await parseTranscriptRequest({} as any, {} as any);
|
||||
expect(options).to.be.deep.equal({});
|
||||
});
|
||||
|
||||
it('should return `options` param with no changes when send always is disabled', async () => {
|
||||
settingsGetMock.get.withArgs('Livechat_enable_transcript').returns(false);
|
||||
settingsGetMock.get.withArgs('Livechat_transcript_send_always').returns(false);
|
||||
const options = await parseTranscriptRequest({} as any, {} as any);
|
||||
expect(options).to.be.deep.equal({});
|
||||
});
|
||||
|
||||
it('should return `options` param with no changes when visitor is not provided and its not found on db', async () => {
|
||||
settingsGetMock.get.withArgs('Livechat_enable_transcript').returns(false);
|
||||
settingsGetMock.get.withArgs('Livechat_transcript_send_always').returns(true);
|
||||
modelsMock.LivechatVisitors.findOneById.resolves(null);
|
||||
|
||||
const options = await parseTranscriptRequest({ v: { _id: '123' } } as any, {} as any);
|
||||
expect(options).to.be.deep.equal({});
|
||||
});
|
||||
|
||||
it('should return `options` param with no changes when visitor is passed but no email is found', async () => {
|
||||
settingsGetMock.get.withArgs('Livechat_enable_transcript').returns(false);
|
||||
settingsGetMock.get.withArgs('Livechat_transcript_send_always').returns(true);
|
||||
modelsMock.LivechatVisitors.findOneById.resolves({} as any);
|
||||
|
||||
const options = await parseTranscriptRequest({ v: { _id: '123' } } as any, {} as any, { _id: '123' } as any);
|
||||
expect(options).to.be.deep.equal({});
|
||||
});
|
||||
|
||||
it('should return `options` param with no changes when visitor is fetched from db, but no email is found', async () => {
|
||||
settingsGetMock.get.withArgs('Livechat_enable_transcript').returns(false);
|
||||
settingsGetMock.get.withArgs('Livechat_transcript_send_always').returns(true);
|
||||
modelsMock.LivechatVisitors.findOneById.resolves({} as any);
|
||||
|
||||
const options = await parseTranscriptRequest({ v: { _id: '123' } } as any, {} as any);
|
||||
expect(options).to.be.deep.equal({});
|
||||
});
|
||||
|
||||
it('should return `options` param with no changes when no user is passed, room is not being served and rocketcat is not present', async () => {
|
||||
settingsGetMock.get.withArgs('Livechat_enable_transcript').returns(false);
|
||||
settingsGetMock.get.withArgs('Livechat_transcript_send_always').returns(true);
|
||||
modelsMock.Users.findOneById.resolves(null);
|
||||
modelsMock.LivechatVisitors.findOneById.resolves({ visitorEmails: [{ address: 'abc@rocket.chat' }] } as any);
|
||||
|
||||
const options = await parseTranscriptRequest({ v: { _id: '123' } } as any, {} as any);
|
||||
expect(options).to.be.deep.equal({});
|
||||
});
|
||||
|
||||
it('should return `options` param with `transcriptRequest` key attached when user is passed', async () => {
|
||||
settingsGetMock.get.withArgs('Livechat_enable_transcript').returns(false);
|
||||
settingsGetMock.get.withArgs('Livechat_transcript_send_always').returns(true);
|
||||
modelsMock.LivechatVisitors.findOneById.resolves({ visitorEmails: [{ address: 'abc@rocket.chat' }] } as any);
|
||||
|
||||
const options = await parseTranscriptRequest({ v: { _id: '123' } } as any, {} as any, undefined, { _id: '123' } as any);
|
||||
|
||||
expect(modelsMock.LivechatVisitors.findOneById.getCall(0).firstArg).to.be.equal('123');
|
||||
expect(options).to.have.property('emailTranscript').that.is.an('object');
|
||||
expect(options.emailTranscript.requestData).to.have.property('email', 'abc@rocket.chat');
|
||||
expect(options.emailTranscript.requestData).to.have.property('subject', '');
|
||||
expect(options.emailTranscript.requestData.requestedBy).to.be.deep.equal({ _id: '123' });
|
||||
});
|
||||
|
||||
it('should return `options` param with `transcriptRequest` key attached when no user is passed, but theres an agent serving the room', async () => {
|
||||
settingsGetMock.get.withArgs('Livechat_enable_transcript').returns(false);
|
||||
settingsGetMock.get.withArgs('Livechat_transcript_send_always').returns(true);
|
||||
modelsMock.Users.findOneById.resolves({ _id: '123', username: 'kevsxxx', name: 'Kev' } as any);
|
||||
modelsMock.LivechatVisitors.findOneById.resolves({ visitorEmails: [{ address: 'abc@rocket.chat' }] } as any);
|
||||
|
||||
const options = await parseTranscriptRequest({ v: { _id: '123' }, servedBy: { _id: '123' } } as any, {} as any);
|
||||
|
||||
expect(modelsMock.Users.findOneById.getCall(0).firstArg).to.be.equal('123');
|
||||
expect(options).to.have.property('emailTranscript').that.is.an('object');
|
||||
expect(options.emailTranscript.requestData).to.have.property('email', 'abc@rocket.chat');
|
||||
expect(options.emailTranscript.requestData).to.have.property('subject', '');
|
||||
expect(options.emailTranscript.requestData.requestedBy).to.be.deep.equal({ _id: '123', username: 'kevsxxx', name: 'Kev' });
|
||||
});
|
||||
|
||||
it('should return `options` param with `transcriptRequest` key attached when no user is passed, no agent is serving but rocket.cat is present', async () => {
|
||||
settingsGetMock.get.withArgs('Livechat_enable_transcript').returns(false);
|
||||
settingsGetMock.get.withArgs('Livechat_transcript_send_always').returns(true);
|
||||
modelsMock.Users.findOneById.resolves({ _id: 'rocket.cat', username: 'rocket.cat', name: 'Rocket Cat' } as any);
|
||||
modelsMock.LivechatVisitors.findOneById.resolves({ visitorEmails: [{ address: 'abc@rocket.chat' }] } as any);
|
||||
|
||||
const options = await parseTranscriptRequest({ v: { _id: '123' } } as any, {} as any);
|
||||
|
||||
expect(modelsMock.Users.findOneById.getCall(0).firstArg).to.be.equal('rocket.cat');
|
||||
expect(options).to.have.property('emailTranscript').that.is.an('object');
|
||||
expect(options.emailTranscript.requestData).to.have.property('email', 'abc@rocket.chat');
|
||||
expect(options.emailTranscript.requestData).to.have.property('subject', '');
|
||||
expect(options.emailTranscript.requestData.requestedBy).to.be.deep.equal({
|
||||
_id: 'rocket.cat',
|
||||
username: 'rocket.cat',
|
||||
name: 'Rocket Cat',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user