Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Oct 9, 2023
1 parent cd73f22 commit 062bdb4
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion apps/meteor/tests/end-to-end/api/livechat/22-mac.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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', () => {
Expand Down

0 comments on commit 062bdb4

Please sign in to comment.