-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added api test to upload by reference
- Loading branch information
Showing
1 changed file
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,8 @@ test('API tests', async t => { | |
auth: { | ||
user: testAccount.user, | ||
pass: testAccount.pass | ||
} | ||
}, | ||
resyncDelay: 60 * 1000 | ||
}, | ||
smtp: { | ||
host: testAccount.smtp.host, | ||
|
@@ -342,6 +343,72 @@ test('API tests', async t => { | |
assert.deepEqual(messageUpdatedWebhook.data.changes.flags.added, ['\\Seen']); | ||
}); | ||
|
||
await t.test('upload by reference', async () => { | ||
await server | ||
.post(`/v1/account/${defaultAccountId}/message`) | ||
.send({ | ||
path: 'Inbox', | ||
reference: { | ||
message: message2.id, | ||
action: 'forward', | ||
inline: true, | ||
forwardAttachments: true, | ||
messageId: '<invalid@value>' | ||
}, | ||
to: [ | ||
{ | ||
name: 'Test Received', | ||
address: '[email protected]' | ||
} | ||
], | ||
text: 'Hallo hallo! π', | ||
html: '<b>Hallo hallo! π</b>', | ||
messageId: '<[email protected]>' | ||
}) | ||
// fails message-id test | ||
.expect(404); | ||
|
||
const response = await server | ||
.post(`/v1/account/${defaultAccountId}/message`) | ||
.send({ | ||
path: 'Inbox', | ||
reference: { | ||
message: message2.id, | ||
action: 'forward', | ||
inline: true, | ||
forwardAttachments: true, | ||
messageId: '<[email protected]>' | ||
}, | ||
to: [ | ||
{ | ||
name: 'Test Received', | ||
address: '[email protected]' | ||
} | ||
], | ||
text: 'Hallo hallo! π', | ||
html: '<b>Hallo hallo! π</b>', | ||
messageId: '<[email protected]>' | ||
}) | ||
.expect(200); | ||
|
||
assert.ok(response.body.id); | ||
|
||
let received = false; | ||
let messageNewWebhook = false; | ||
while (!received) { | ||
await new Promise(r => setTimeout(r, 1000)); | ||
let webhooks = webhooksServer.webhooks.get(defaultAccountId); | ||
messageNewWebhook = webhooks.find(wh => wh.path === 'INBOX' && wh.event === 'messageNew' && wh.data.messageId === '<[email protected]>'); | ||
if (messageNewWebhook) { | ||
received = true; | ||
} | ||
} | ||
|
||
assert.ok(/Begin forwarded message/.test(messageNewWebhook.data.text.plain)); | ||
assert.strictEqual(messageNewWebhook.data.attachments[0].filename, 'transparent.gif'); | ||
assert.strictEqual(messageNewWebhook.data.subject, 'Fwd: Test message π€£'); | ||
}); | ||
|
||
await t.test('move message to another folder', async () => { | ||
const response = await server | ||
.put(`/v1/account/${defaultAccountId}/message/${message2.id}/move`) | ||
|