Support reporting token on envelope
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import * as sinon from 'sinon';
|
||||
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
||||
import { Job } from '../../../jobs/Job';
|
||||
import { UUID } from '../../../types/UUID';
|
||||
|
||||
import { addReportSpamJob } from '../../../jobs/helpers/addReportSpamJob';
|
||||
|
||||
@@ -11,6 +11,12 @@ describe('addReportSpamJob', () => {
|
||||
let getMessageServerGuidsForSpam: sinon.SinonStub;
|
||||
let jobQueue: { add: sinon.SinonStub };
|
||||
|
||||
const conversation = {
|
||||
id: 'convo',
|
||||
type: 'private' as const,
|
||||
uuid: UUID.generate().toString(),
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
getMessageServerGuidsForSpam = sinon.stub().resolves(['abc', 'xyz']);
|
||||
jobQueue = {
|
||||
@@ -31,7 +37,10 @@ describe('addReportSpamJob', () => {
|
||||
|
||||
it('does nothing if the conversation lacks a UUID', async () => {
|
||||
await addReportSpamJob({
|
||||
conversation: getDefaultConversation({ uuid: undefined }),
|
||||
conversation: {
|
||||
...conversation,
|
||||
uuid: undefined,
|
||||
},
|
||||
getMessageServerGuidsForSpam,
|
||||
jobQueue,
|
||||
});
|
||||
@@ -44,7 +53,7 @@ describe('addReportSpamJob', () => {
|
||||
getMessageServerGuidsForSpam.resolves([]);
|
||||
|
||||
await addReportSpamJob({
|
||||
conversation: getDefaultConversation(),
|
||||
conversation,
|
||||
getMessageServerGuidsForSpam,
|
||||
jobQueue,
|
||||
});
|
||||
@@ -52,9 +61,7 @@ describe('addReportSpamJob', () => {
|
||||
sinon.assert.notCalled(jobQueue.add);
|
||||
});
|
||||
|
||||
it('enqueues a job', async () => {
|
||||
const conversation = getDefaultConversation();
|
||||
|
||||
it('enqueues a job without a token', async () => {
|
||||
await addReportSpamJob({
|
||||
conversation,
|
||||
getMessageServerGuidsForSpam,
|
||||
@@ -68,6 +75,28 @@ describe('addReportSpamJob', () => {
|
||||
sinon.assert.calledWith(jobQueue.add, {
|
||||
uuid: conversation.uuid,
|
||||
serverGuids: ['abc', 'xyz'],
|
||||
token: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it('enqueues a job with a token', async () => {
|
||||
await addReportSpamJob({
|
||||
conversation: {
|
||||
...conversation,
|
||||
reportingToken: 'uvw',
|
||||
},
|
||||
getMessageServerGuidsForSpam,
|
||||
jobQueue,
|
||||
});
|
||||
|
||||
sinon.assert.calledOnce(getMessageServerGuidsForSpam);
|
||||
sinon.assert.calledWith(getMessageServerGuidsForSpam, conversation.id);
|
||||
|
||||
sinon.assert.calledOnce(jobQueue.add);
|
||||
sinon.assert.calledWith(jobQueue.add, {
|
||||
uuid: conversation.uuid,
|
||||
serverGuids: ['abc', 'xyz'],
|
||||
token: 'uvw',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user