diff --git a/apps/meteor/tests/end-to-end/api/livechat/22-mac.ts b/apps/meteor/tests/end-to-end/api/livechat/22-mac.ts index 4d1d658d40be4..db31c30ac1d33 100644 --- a/apps/meteor/tests/end-to-end/api/livechat/22-mac.ts +++ b/apps/meteor/tests/end-to-end/api/livechat/22-mac.ts @@ -1,5 +1,7 @@ +import type { ILivechatVisitor } from '@rocket.chat/core-typings'; import { expect } from 'chai'; import { before, describe, it } from 'mocha'; +import moment from 'moment'; import { api, getCredentials, request, credentials } from '../../../data/api-data'; import { @@ -21,6 +23,7 @@ import { IS_EE } from '../../../e2e/config/constants'; }); describe('MAC rooms', () => { + let visitor: ILivechatVisitor; it('Should create an innactive room by default', async () => { const visitor = await createVisitor(); const room = await createLivechatRoom(visitor.token); @@ -30,7 +33,7 @@ import { IS_EE } from '../../../e2e/config/constants'; }); it('should mark room as active when agent sends a message', async () => { - const visitor = await createVisitor(); + visitor = await createVisitor(); const room = await createLivechatRoom(visitor.token); await sendAgentMessage(room._id); @@ -39,6 +42,29 @@ import { IS_EE } from '../../../e2e/config/constants'; expect(updatedRoom).to.have.nested.property('v.activity').and.to.be.an('array'); }); + + it('should mark multiple rooms as active when they come from same visitor', async () => { + const room = await createLivechatRoom(visitor.token); + + await sendAgentMessage(room._id); + + const updatedRoom = await getLivechatRoomInfo(room._id); + + expect(updatedRoom).to.have.nested.property('v.activity').and.to.be.an('array'); + }); + + it('visitor should be marked as active for period', async () => { + const { body } = await request + .get(api(`livechat/visitors.info?visitorId=${visitor._id}`)) + .set(credentials) + .expect('Content-Type', 'application/json') + .expect(200); + + expect(body).to.have.nested.property('visitor').and.to.be.an('object'); + expect(body.visitor).to.have.nested.property('activity').and.to.be.an('array'); + expect(body.visitor.activity).to.have.lengthOf(1); + expect(body.visitor.activity[0]).to.equal(moment.utc().format('YYYY-MM')); + }); }); describe('MAC check', () => {