mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 03:14:03 +03:00
15da07f324
refs: https://github.com/TryGhost/Team/issues/1446 - changed mail API tests to use the new e2e test framework - added the missing retry test - which has the wrong response format :( mail
61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
const {agentProvider, fixtureManager, matchers, mockManager} = require('../../utils/e2e-framework');
|
|
const {anyEtag} = matchers;
|
|
|
|
describe('Mail API', function () {
|
|
let agent;
|
|
|
|
before(async function () {
|
|
agent = await agentProvider.getAdminAPIAgent();
|
|
await fixtureManager.init('invites');
|
|
await agent.loginAsOwner();
|
|
});
|
|
|
|
beforeEach(function () {
|
|
mockManager.mockMail({message: 'sent'});
|
|
});
|
|
|
|
afterEach(function () {
|
|
mockManager.restore();
|
|
});
|
|
|
|
it('Can send mail', async function () {
|
|
await agent
|
|
.post('mail/')
|
|
.body({
|
|
mail: [{
|
|
message: {
|
|
to: 'joe@example.com',
|
|
subject: 'testemail',
|
|
html: '<p>This</p>'
|
|
}
|
|
}]
|
|
})
|
|
.expectStatus(200)
|
|
.matchBodySnapshot()
|
|
.matchHeaderSnapshot({
|
|
etag: anyEtag
|
|
});
|
|
|
|
mockManager.assert.sentEmail({
|
|
to: 'joe@example.com',
|
|
subject: 'testemail'
|
|
});
|
|
});
|
|
|
|
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'
|
|
});
|
|
});
|
|
});
|