Added breaking test for sending welcome emails
ref https://linear.app/tryghost/issue/ONC-274 This test checks that a welcome email is not sent when adding a member via the Admin API if the site is in need of email verification, regardless of whether or not the flag to send an email is set. It is currently failing to demonstrate the whole in our logic.
This commit is contained in:
parent
b012da023d
commit
3adc0c0441
@ -5589,6 +5589,86 @@ Object {
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`Members API Does not send a signup email when email verification is required 1: [body] 1`] = `
|
||||||
|
Object {
|
||||||
|
"members": Array [
|
||||||
|
Object {
|
||||||
|
"attribution": Object {
|
||||||
|
"id": null,
|
||||||
|
"referrer_medium": "Ghost Admin",
|
||||||
|
"referrer_source": "Created manually",
|
||||||
|
"referrer_url": null,
|
||||||
|
"title": null,
|
||||||
|
"type": null,
|
||||||
|
"url": null,
|
||||||
|
},
|
||||||
|
"avatar_image": null,
|
||||||
|
"comped": false,
|
||||||
|
"created_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
|
"email": "member_not_getting_confirmation@test.com",
|
||||||
|
"email_count": 0,
|
||||||
|
"email_open_rate": null,
|
||||||
|
"email_opened_count": 0,
|
||||||
|
"email_suppression": Object {
|
||||||
|
"info": null,
|
||||||
|
"suppressed": false,
|
||||||
|
},
|
||||||
|
"geolocation": null,
|
||||||
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
|
"labels": Array [],
|
||||||
|
"last_seen_at": null,
|
||||||
|
"name": "Do not Send Me Confirmation",
|
||||||
|
"newsletters": Array [
|
||||||
|
Object {
|
||||||
|
"description": null,
|
||||||
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
|
"name": "Default Newsletter",
|
||||||
|
"status": "active",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"description": null,
|
||||||
|
"id": StringMatching /\\[a-f0-9\\]\\{24\\}/,
|
||||||
|
"name": "Daily newsletter",
|
||||||
|
"status": "active",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"note": null,
|
||||||
|
"status": "free",
|
||||||
|
"subscribed": true,
|
||||||
|
"subscriptions": Array [],
|
||||||
|
"tiers": Array [],
|
||||||
|
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/,
|
||||||
|
"uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Members API Does not send a signup email when email verification is required 2: [headers] 1`] = `
|
||||||
|
Object {
|
||||||
|
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||||
|
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||||
|
"content-length": "901",
|
||||||
|
"content-type": "application/json; charset=utf-8",
|
||||||
|
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||||
|
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||||
|
"location": Any<String>,
|
||||||
|
"vary": "Accept-Version, Origin, Accept-Encoding",
|
||||||
|
"x-powered-by": "Express",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`Members API Does not send a signup email when email verification is required 3: [headers] 1`] = `
|
||||||
|
Object {
|
||||||
|
"access-control-allow-origin": "http://127.0.0.1:2369",
|
||||||
|
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
|
||||||
|
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
|
||||||
|
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
|
||||||
|
"vary": "Accept-Version, Origin",
|
||||||
|
"x-powered-by": "Express",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`Members API Errors when fetching stats with unknown days param value 1: [body] 1`] = `
|
exports[`Members API Errors when fetching stats with unknown days param value 1: [body] 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"errors": Array [
|
"errors": Array [
|
||||||
|
@ -1018,6 +1018,85 @@ describe('Members API', function () {
|
|||||||
.expectStatus(200);
|
.expectStatus(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Does not send a signup email when email verification is required', async function () {
|
||||||
|
mockManager.mockSetting('email_verification_required', true);
|
||||||
|
|
||||||
|
const member = {
|
||||||
|
name: 'Do not Send Me Confirmation',
|
||||||
|
email: 'member_not_getting_confirmation@test.com',
|
||||||
|
newsletters: [
|
||||||
|
newsletters[0],
|
||||||
|
newsletters[1]
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
const {body} = await agent
|
||||||
|
.post('/members/?send_email=true&email_type=signup')
|
||||||
|
.body({members: [member]})
|
||||||
|
.expectStatus(201)
|
||||||
|
.matchBodySnapshot({
|
||||||
|
members: [
|
||||||
|
buildMemberWithoutIncludesSnapshot({
|
||||||
|
newsletters: 2
|
||||||
|
})
|
||||||
|
]
|
||||||
|
})
|
||||||
|
.matchHeaderSnapshot({
|
||||||
|
'content-version': anyContentVersion,
|
||||||
|
etag: anyEtag,
|
||||||
|
location: anyString
|
||||||
|
});
|
||||||
|
|
||||||
|
const newMember = body.members[0];
|
||||||
|
|
||||||
|
emailMockReceiver
|
||||||
|
.assertSentEmailCount(0);
|
||||||
|
|
||||||
|
await assertMemberEvents({
|
||||||
|
eventType: 'MemberStatusEvent',
|
||||||
|
memberId: newMember.id,
|
||||||
|
asserts: [
|
||||||
|
{
|
||||||
|
from_status: null,
|
||||||
|
to_status: 'free'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
await assertMemberEvents({
|
||||||
|
eventType: 'MemberSubscribeEvent',
|
||||||
|
memberId: newMember.id,
|
||||||
|
asserts: [
|
||||||
|
{
|
||||||
|
subscribed: true,
|
||||||
|
source: 'admin',
|
||||||
|
newsletter_id: newsletters[0].id
|
||||||
|
},
|
||||||
|
{
|
||||||
|
subscribed: true,
|
||||||
|
source: 'admin',
|
||||||
|
newsletter_id: newsletters[1].id
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// @TODO: do we really need to delete this member here?
|
||||||
|
await agent
|
||||||
|
.delete(`members/${body.members[0].id}/`)
|
||||||
|
.matchHeaderSnapshot({
|
||||||
|
'content-version': anyContentVersion,
|
||||||
|
etag: anyEtag
|
||||||
|
})
|
||||||
|
.expectStatus(204);
|
||||||
|
|
||||||
|
// There should be no MemberSubscribeEvent remaining.
|
||||||
|
await assertMemberEvents({
|
||||||
|
eventType: 'MemberSubscribeEvent',
|
||||||
|
memberId: newMember.id,
|
||||||
|
asserts: []
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Add should fail when passing incorrect email_type query parameter', async function () {
|
it('Add should fail when passing incorrect email_type query parameter', async function () {
|
||||||
const newMember = {
|
const newMember = {
|
||||||
name: 'test',
|
name: 'test',
|
||||||
|
Loading…
Reference in New Issue
Block a user