2022-03-25 10:41:58 +00:00
|
|
|
const {agentProvider, fixtureManager, matchers, mockManager} = require('../../utils/e2e-framework');
|
|
|
|
const {anyEtag} = matchers;
|
2019-09-20 17:02:45 +02:00
|
|
|
|
2019-02-04 15:16:24 +01:00
|
|
|
describe('Mail API', function () {
|
2022-03-25 10:41:58 +00:00
|
|
|
let agent;
|
2018-10-12 19:44:05 +02:00
|
|
|
|
2020-11-30 14:25:22 +00:00
|
|
|
before(async function () {
|
2022-03-25 10:41:58 +00:00
|
|
|
agent = await agentProvider.getAdminAPIAgent();
|
|
|
|
await fixtureManager.init('invites');
|
|
|
|
await agent.loginAsOwner();
|
2018-10-12 19:44:05 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(function () {
|
2022-03-25 10:41:58 +00:00
|
|
|
mockManager.mockMail({message: 'sent'});
|
2018-10-12 19:44:05 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
2022-03-25 10:41:58 +00:00
|
|
|
mockManager.restore();
|
2018-10-12 19:44:05 +02:00
|
|
|
});
|
|
|
|
|
2020-11-30 14:25:22 +00:00
|
|
|
it('Can send mail', async function () {
|
2022-03-25 10:41:58 +00:00
|
|
|
await agent
|
|
|
|
.post('mail/')
|
|
|
|
.body({
|
2018-10-12 19:44:05 +02:00
|
|
|
mail: [{
|
|
|
|
message: {
|
|
|
|
to: 'joe@example.com',
|
|
|
|
subject: 'testemail',
|
|
|
|
html: '<p>This</p>'
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
})
|
2022-03-25 10:41:58 +00:00
|
|
|
.expectStatus(200)
|
|
|
|
.matchBodySnapshot()
|
|
|
|
.matchHeaderSnapshot({
|
|
|
|
etag: anyEtag
|
|
|
|
});
|
|
|
|
|
|
|
|
mockManager.assert.sentEmail({
|
|
|
|
to: 'joe@example.com',
|
|
|
|
subject: 'testemail'
|
|
|
|
});
|
|
|
|
});
|
2018-10-12 19:44:05 +02:00
|
|
|
|
2022-03-25 10:41:58 +00:00
|
|
|
it('Can send a test mail', async function () {
|
|
|
|
// @TODO: either remove this endpoint or fix its response body
|
|
|
|
await agent
|
|
|
|
.post('mail/test')
|
|
|
|
.expectStatus(200)
|
|
|
|
.matchBodySnapshot()
|
|
|
|
.matchHeaderSnapshot({
|
|
|
|
etag: anyEtag
|
|
|
|
});
|
|
|
|
|
|
|
|
mockManager.assert.sentEmail({
|
|
|
|
to: 'jbloggs@example.com',
|
|
|
|
subject: 'Test Ghost Email'
|
|
|
|
});
|
2018-10-12 19:44:05 +02:00
|
|
|
});
|
|
|
|
});
|