1 jest.setTimeout(120000);
16 let recipient_id: number;
18 beforeAll(async () => {
20 let follow = await followBeta(alpha);
22 recipient_id = follow.community_view.creator.id;
25 afterAll(async () => {
26 await unfollowRemotes(alpha);
29 test('Create a private message', async () => {
30 let pmRes = await createPrivateMessage(alpha, recipient_id);
31 expect(pmRes.private_message_view.private_message.content).toBeDefined();
32 expect(pmRes.private_message_view.private_message.local).toBe(true);
33 expect(pmRes.private_message_view.creator.local).toBe(true);
34 expect(pmRes.private_message_view.recipient.local).toBe(false);
37 let betaPms = await listPrivateMessages(beta);
38 expect(betaPms.private_messages[0].private_message.content).toBeDefined();
39 expect(betaPms.private_messages[0].private_message.local).toBe(false);
40 expect(betaPms.private_messages[0].creator.local).toBe(false);
41 expect(betaPms.private_messages[0].recipient.local).toBe(true);
44 test('Update a private message', async () => {
45 let updatedContent = 'A jest test federated private message edited';
47 let pmRes = await createPrivateMessage(alpha, recipient_id);
48 let pmUpdated = await editPrivateMessage(
50 pmRes.private_message_view.private_message.id
52 expect(pmUpdated.private_message_view.private_message.content).toBe(
57 let betaPms = await listPrivateMessages(beta);
58 expect(betaPms.private_messages[0].private_message.content).toBe(
63 test('Delete a private message', async () => {
64 let pmRes = await createPrivateMessage(alpha, recipient_id);
66 let betaPms1 = await listPrivateMessages(beta);
67 let deletedPmRes = await deletePrivateMessage(
70 pmRes.private_message_view.private_message.id
72 expect(deletedPmRes.private_message_view.private_message.deleted).toBe(true);
75 // The GetPrivateMessages filters out deleted,
76 // even though they are in the actual database.
77 // no reason to show them
78 let betaPms2 = await listPrivateMessages(beta);
79 expect(betaPms2.private_messages.length).toBe(
80 betaPms1.private_messages.length - 1
85 let undeletedPmRes = await deletePrivateMessage(
88 pmRes.private_message_view.private_message.id
90 expect(undeletedPmRes.private_message_view.private_message.deleted).toBe(
95 let betaPms3 = await listPrivateMessages(beta);
96 expect(betaPms3.private_messages.length).toBe(
97 betaPms1.private_messages.length