Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Aug 30, 2023
1 parent b8ca610 commit 1f867ea
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion apps/meteor/tests/end-to-end/api/livechat/09-visitors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { faker } from '@faker-js/faker';
import type { ILivechatVisitor } from '@rocket.chat/core-typings';
import { expect } from 'chai';
import { before, describe, it } from 'mocha';
import type { Response } from 'supertest';
import moment from 'moment';
import { type Response } from 'supertest';

import { getCredentials, api, request, credentials } from '../../../data/api-data';
import { createCustomField, deleteCustomField } from '../../../data/livechat/custom-fields';
Expand Down Expand Up @@ -334,6 +335,27 @@ describe('LIVECHAT - visitors', function () {
});
});

it('should return visitor activity field when visitor was active on month', async () => {
// Activity is determined by a conversation in which an agent has engaged (sent a message)
// For a visitor to be considered active, they must have had a conversation in the last 30 days
const period = moment().format('YYYY-MM');
const { visitor, room } = await startANewLivechatRoomAndTakeIt();
// agent should send a message on the room
await request
.post(api('chat.sendMessage'))
.set(credentials)
.send({
message: {
rid: room._id,
msg: 'test',
},
});

const activeVisitor = await getLivechatVisitorByToken(visitor.token);
expect(activeVisitor).to.have.property('activity');
expect(activeVisitor.activity).to.include(period);
});

it("should return a 'error-removing-visitor' error when removeGuest's result is false", async () => {
await request
.delete(api('livechat/visitor/123'))
Expand Down

0 comments on commit 1f867ea

Please sign in to comment.