1 jest.setTimeout(120000);
14 let recipient_id: number;
16 beforeAll(async () => {
18 let follow = await followBeta(alpha);
19 recipient_id = follow.community.creator_id;
22 afterAll(async () => {
23 await unfollowRemotes(alpha);
26 test('Create a private message', async () => {
27 let pmRes = await createPrivateMessage(alpha, recipient_id);
28 expect(pmRes.message.content).toBeDefined();
29 expect(pmRes.message.local).toBe(true);
30 expect(pmRes.message.creator_local).toBe(true);
31 expect(pmRes.message.recipient_local).toBe(false);
33 let betaPms = await listPrivateMessages(beta);
34 expect(betaPms.messages[0].content).toBeDefined();
35 expect(betaPms.messages[0].local).toBe(false);
36 expect(betaPms.messages[0].creator_local).toBe(false);
37 expect(betaPms.messages[0].recipient_local).toBe(true);
40 test('Update a private message', async () => {
41 let updatedContent = 'A jest test federated private message edited';
43 let pmRes = await createPrivateMessage(alpha, recipient_id);
44 let pmUpdated = await updatePrivateMessage(alpha, pmRes.message.id);
45 expect(pmUpdated.message.content).toBe(updatedContent);
47 let betaPms = await listPrivateMessages(beta);
48 expect(betaPms.messages[0].content).toBe(updatedContent);
51 test('Delete a private message', async () => {
52 let pmRes = await createPrivateMessage(alpha, recipient_id);
53 let betaPms1 = await listPrivateMessages(beta);
54 let deletedPmRes = await deletePrivateMessage(alpha, true, pmRes.message.id);
55 expect(deletedPmRes.message.deleted).toBe(true);
57 // The GetPrivateMessages filters out deleted,
58 // even though they are in the actual database.
59 // no reason to show them
60 let betaPms2 = await listPrivateMessages(beta);
61 expect(betaPms2.messages.length).toBe(betaPms1.messages.length - 1);
64 let undeletedPmRes = await deletePrivateMessage(
69 expect(undeletedPmRes.message.deleted).toBe(false);
71 let betaPms3 = await listPrivateMessages(beta);
72 expect(betaPms3.messages.length).toBe(betaPms1.messages.length);