Updated test fixtures for multiple newsletters

- Updated the member fixtures to have 6 subscribed and 2 unsubscribed members
- Added an inactive newsletter
- Updated newsletter-member relations to reflect the 6 subscribed and 2 unsubscribed, but with different cases:
   - 3 subscribed to default
   - 1 subscribed to secondary only
   - 1 subscribed to default + secondary
   - 1 subscribed to secondary + inactive
   - 1 subscribed to inactive only (i.e. not subscribed)
   - 1 not subscribed at all

- With these changes, I needed to update the members snap as 2 members appear as subscribed:false in many tests
- I also needed to update some posts regression tests, as 2 less members get emailed in 2 tests
This commit is contained in:
Hannah Wolfe 2022-04-24 14:18:00 +01:00 committed by Matt Hanley
parent 48799e1c68
commit 9da57fa6bb
4 changed files with 110 additions and 35 deletions

View File

@ -494,7 +494,7 @@ Object {
"name": "Peter Venkman", "name": "Peter Venkman",
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -514,7 +514,7 @@ Object {
"name": "Dana Barrett", "name": "Dana Barrett",
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -537,7 +537,7 @@ exports[`Members API Can browse 2: [headers] 1`] = `
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "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", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "8426", "content-length": "8428",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
@ -1083,7 +1083,7 @@ Object {
"name": "Peter Venkman", "name": "Peter Venkman",
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -1103,7 +1103,7 @@ Object {
"name": "Dana Barrett", "name": "Dana Barrett",
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -1126,7 +1126,7 @@ exports[`Members API Can filter by paid status 2: [headers] 1`] = `
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "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", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "6891", "content-length": "6893",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
@ -1152,7 +1152,7 @@ Object {
"name": "Peter Venkman", "name": "Peter Venkman",
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -1175,7 +1175,7 @@ exports[`Members API Can filter using contains operators 2: [headers] 1`] = `
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "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", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "664", "content-length": "665",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
@ -1261,7 +1261,7 @@ Object {
"name": "Peter Venkman", "name": "Peter Venkman",
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -1281,7 +1281,7 @@ Object {
"name": "Dana Barrett", "name": "Dana Barrett",
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -1304,7 +1304,7 @@ exports[`Members API Can ignore any unknown includes 2: [headers] 1`] = `
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "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", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "6891", "content-length": "6893",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",
@ -1450,7 +1450,7 @@ Object {
"name": "Peter Venkman", "name": "Peter Venkman",
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -1470,7 +1470,7 @@ Object {
"name": "Dana Barrett", "name": "Dana Barrett",
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -1639,7 +1639,7 @@ Object {
"name": "Peter Venkman", "name": "Peter Venkman",
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -1659,7 +1659,7 @@ Object {
"name": "Dana Barrett", "name": "Dana Barrett",
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -2377,7 +2377,7 @@ Object {
"newsletters": Any<Array>, "newsletters": Any<Array>,
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -2398,7 +2398,7 @@ Object {
"newsletters": Any<Array>, "newsletters": Any<Array>,
"note": null, "note": null,
"status": "paid", "status": "paid",
"subscribed": true, "subscribed": false,
"subscriptions": Any<Array>, "subscriptions": Any<Array>,
"updated_at": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}T\\\\d\\{2\\}:\\\\d\\{2\\}:\\\\d\\{2\\}\\\\\\.000Z/, "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\\}/, "uuid": StringMatching /\\[a-f0-9\\]\\{8\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{4\\}-\\[a-f0-9\\]\\{12\\}/,
@ -2421,7 +2421,7 @@ exports[`Members API: with multiple newsletters Can browse 2: [headers] 1`] = `
Object { Object {
"access-control-allow-origin": "http://127.0.0.1:2369", "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", "cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "8562", "content-length": "8564",
"content-type": "application/json; charset=utf-8", "content-type": "application/json; charset=utf-8",
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/, "etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
"vary": "Origin, Accept-Encoding", "vary": "Origin, Accept-Encoding",

View File

@ -410,7 +410,7 @@ describe('Posts API (canary)', function () {
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private) .expect('Cache-Control', testUtils.cacheRules.private)
.expect(201); .expect(201);
should.exist(res.body.posts); should.exist(res.body.posts);
should.exist(res.body.posts[0].title); should.exist(res.body.posts[0].title);
res.body.posts[0].title.should.equal('Tags test 5'); res.body.posts[0].title.should.equal('Tags test 5');
@ -420,7 +420,7 @@ describe('Posts API (canary)', function () {
// Expected behaviour when creating a slug with spaces: // Expected behaviour when creating a slug with spaces:
res.body.posts[0].tags[0].name.should.equal('five-spaces'); res.body.posts[0].tags[0].name.should.equal('five-spaces');
// If we create another post again now that the five-spaces tag exists, // If we create another post again now that the five-spaces tag exists,
// we need to make sure it matches correctly and doesn't create a new tag again // we need to make sure it matches correctly and doesn't create a new tag again
const res2 = await request const res2 = await request
@ -435,7 +435,7 @@ describe('Posts API (canary)', function () {
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private) .expect('Cache-Control', testUtils.cacheRules.private)
.expect(201); .expect(201);
should.exist(res2.body.posts); should.exist(res2.body.posts);
should.exist(res2.body.posts[0].title); should.exist(res2.body.posts[0].title);
res2.body.posts[0].title.should.equal('Tags test 6'); res2.body.posts[0].title.should.equal('Tags test 6');
@ -458,7 +458,7 @@ describe('Posts API (canary)', function () {
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private) .expect('Cache-Control', testUtils.cacheRules.private)
.expect(201); .expect(201);
should.exist(res.body.posts); should.exist(res.body.posts);
should.exist(res.body.posts[0].title); should.exist(res.body.posts[0].title);
res.body.posts[0].title.should.equal('Tags test 7'); res.body.posts[0].title.should.equal('Tags test 7');
@ -466,7 +466,7 @@ describe('Posts API (canary)', function () {
res.body.posts[0].tags[0].slug.should.equal('six-spaces'); res.body.posts[0].tags[0].slug.should.equal('six-spaces');
res.body.posts[0].tags[0].name.should.equal('Not automated name for six spaces'); res.body.posts[0].tags[0].name.should.equal('Not automated name for six spaces');
// If we create another post again now that the five-spaces tag exists, // If we create another post again now that the five-spaces tag exists,
// we need to make sure it matches correctly and doesn't create a new tag again // we need to make sure it matches correctly and doesn't create a new tag again
const res2 = await request const res2 = await request
@ -481,7 +481,7 @@ describe('Posts API (canary)', function () {
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private) .expect('Cache-Control', testUtils.cacheRules.private)
.expect(201); .expect(201);
should.exist(res2.body.posts); should.exist(res2.body.posts);
should.exist(res2.body.posts[0].title); should.exist(res2.body.posts[0].title);
res2.body.posts[0].title.should.equal('Tags test 8'); res2.body.posts[0].title.should.equal('Tags test 8');
@ -504,14 +504,14 @@ describe('Posts API (canary)', function () {
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private) .expect('Cache-Control', testUtils.cacheRules.private)
.expect(201); .expect(201);
should.exist(res.body.posts); should.exist(res.body.posts);
should.exist(res.body.posts[0].title); should.exist(res.body.posts[0].title);
res.body.posts[0].title.should.equal('Tags test 9'); res.body.posts[0].title.should.equal('Tags test 9');
res.body.posts[0].tags.length.should.equal(1); res.body.posts[0].tags.length.should.equal(1);
res.body.posts[0].tags[0].slug.should.equal(tooLongSlug.substring(0, 185)); res.body.posts[0].tags[0].slug.should.equal(tooLongSlug.substring(0, 185));
// If we create another post again now that the very long tag exists, // If we create another post again now that the very long tag exists,
// we need to make sure it matches correctly and doesn't create a new tag again // we need to make sure it matches correctly and doesn't create a new tag again
const res2 = await request const res2 = await request
@ -526,7 +526,7 @@ describe('Posts API (canary)', function () {
.expect('Content-Type', /json/) .expect('Content-Type', /json/)
.expect('Cache-Control', testUtils.cacheRules.private) .expect('Cache-Control', testUtils.cacheRules.private)
.expect(201); .expect(201);
should.exist(res2.body.posts); should.exist(res2.body.posts);
should.exist(res2.body.posts[0].title); should.exist(res2.body.posts[0].title);
res2.body.posts[0].title.should.equal('Tags test 10'); res2.body.posts[0].title.should.equal('Tags test 10');
@ -604,7 +604,7 @@ describe('Posts API (canary)', function () {
publishedRes.body.posts[0].status.should.equal('sent'); publishedRes.body.posts[0].status.should.equal('sent');
should.exist(publishedRes.body.posts[0].email); should.exist(publishedRes.body.posts[0].email);
publishedRes.body.posts[0].email.email_count.should.equal(8); publishedRes.body.posts[0].email.email_count.should.equal(6);
}); });
it('publishes a post while setting email_only flag sends an email', async function () { it('publishes a post while setting email_only flag sends an email', async function () {
@ -647,7 +647,7 @@ describe('Posts API (canary)', function () {
publishedRes.body.posts[0].status.should.equal('sent'); publishedRes.body.posts[0].status.should.equal('sent');
should.exist(publishedRes.body.posts[0].email); should.exist(publishedRes.body.posts[0].email);
publishedRes.body.posts[0].email.email_count.should.equal(5); publishedRes.body.posts[0].email.email_count.should.equal(3);
}); });
it('read-only value do not cause errors when edited', function () { it('read-only value do not cause errors when edited', function () {

View File

@ -465,7 +465,7 @@ const fixtures = {
return models.Product.add(archivedProduct, context.internal); return models.Product.add(archivedProduct, context.internal);
}, },
insertMembersAndLabelsAndProducts: function insertMembersAndLabelsAndProducts() { insertMembersAndLabelsAndProducts: function insertMembersAndLabelsAndProducts(newsletters = false) {
return Promise.map(DataGenerator.forKnex.labels, function (label) { return Promise.map(DataGenerator.forKnex.labels, function (label) {
return models.Label.add(label, context.internal); return models.Label.add(label, context.internal);
}).then(function () { }).then(function () {
@ -504,6 +504,15 @@ const fixtures = {
member.labels = memberLabelRelations; member.labels = memberLabelRelations;
if (newsletters) {
let memberNewsletterRelations = _.filter(DataGenerator.forKnex.members_newsletters, {member_id: member.id});
memberNewsletterRelations = _.map(memberNewsletterRelations, function (memberNewsletterRelation) {
return _.find(DataGenerator.forKnex.newsletters, {id: memberNewsletterRelation.newsletter_id});
});
member.newsletters = memberNewsletterRelations;
}
// TODO: replace with full member/product associations // TODO: replace with full member/product associations
if (member.email === 'with-product@test.com') { if (member.email === 'with-product@test.com') {
member.products = [{slug: product.get('slug')}]; member.products = [{slug: product.get('slug')}];
@ -634,11 +643,14 @@ const toDoList = {
return fixtures.insertOne('Member', 'members', 'createMember'); return fixtures.insertOne('Member', 'members', 'createMember');
}, },
members: function insertMembersAndLabelsAndProducts() { members: function insertMembersAndLabelsAndProducts() {
return fixtures.insertMembersAndLabelsAndProducts(); return fixtures.insertMembersAndLabelsAndProducts(false);
}, },
newsletters: function insertNewsletters() { newsletters: function insertNewsletters() {
return fixtures.insertNewsletters(); return fixtures.insertNewsletters();
}, },
'members:newsletters': function insertMembersAndLabelsAndProductsAndNewsletters() {
return fixtures.insertMembersAndLabelsAndProducts(true);
},
'members:emails': function insertEmailsAndRecipients() { 'members:emails': function insertEmailsAndRecipients() {
return fixtures.insertEmailsAndRecipients(); return fixtures.insertEmailsAndRecipients();
}, },

View File

@ -354,14 +354,16 @@ DataGenerator.Content = {
email: 'vip-paid@test.com', email: 'vip-paid@test.com',
name: 'Peter Venkman', name: 'Peter Venkman',
uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b346', uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b346',
status: 'paid' status: 'paid',
subscribed: false
}, },
{ {
id: ObjectId().toHexString(), id: ObjectId().toHexString(),
email: 'with-product@test.com', email: 'with-product@test.com',
name: 'Dana Barrett', name: 'Dana Barrett',
uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b347', uuid: 'f6f91461-d7d8-4a3f-aa5d-8e582c40b347',
status: 'paid' status: 'paid',
subscribed: false
} }
], ],
@ -399,6 +401,23 @@ DataGenerator.Content = {
show_header_title: true, show_header_title: true,
show_badge: true, show_badge: true,
sort_order: 2 sort_order: 2
},
{
id: ObjectId().toHexString(),
name: 'Old newsletter',
slug: 'old-newsletter',
description: '',
sender_name: 'Jamie',
sender_email: 'jamie@example.com',
sender_reply_to: 'newsletter',
status: 'inactive',
subscribe_on_signup: true,
title_font_category: 'serif',
body_font_category: 'serif',
show_header_icon: true,
show_header_title: true,
show_badge: true,
sort_order: 2
} }
], ],
@ -1233,9 +1252,53 @@ DataGenerator.forKnex = (function () {
const members_newsletters = [ const members_newsletters = [
{ {
id: ObjectId().toHexString(), id: ObjectId().toHexString(),
member_id: DataGenerator.Content.posts[0].id, member_id: DataGenerator.Content.members[0].id,
newsletter_id: DataGenerator.Content.tags[0].id newsletter_id: DataGenerator.Content.newsletters[0].id
},
{
id: ObjectId().toHexString(),
member_id: DataGenerator.Content.members[1].id,
newsletter_id: DataGenerator.Content.newsletters[0].id
},
{
id: ObjectId().toHexString(),
member_id: DataGenerator.Content.members[2].id,
newsletter_id: DataGenerator.Content.newsletters[0].id
},
{
id: ObjectId().toHexString(),
member_id: DataGenerator.Content.members[3].id,
newsletter_id: DataGenerator.Content.newsletters[1].id
},
// Member index 4 (comped@test.com), subscribed to two active newsletters
{
id: ObjectId().toHexString(),
member_id: DataGenerator.Content.members[4].id,
newsletter_id: DataGenerator.Content.newsletters[0].id
},
{
id: ObjectId().toHexString(),
member_id: DataGenerator.Content.members[4].id,
newsletter_id: DataGenerator.Content.newsletters[1].id
},
// Member index 5 (vip@test.com), subscribed to an active and inactive newsletter
{
id: ObjectId().toHexString(),
member_id: DataGenerator.Content.members[5].id,
newsletter_id: DataGenerator.Content.newsletters[1].id
},
{
id: ObjectId().toHexString(),
member_id: DataGenerator.Content.members[5].id,
newsletter_id: DataGenerator.Content.newsletters[2].id
},
// Member index 6 (vip-paid@test.com), subscribed to an inactive newsletter
{
id: ObjectId().toHexString(),
member_id: DataGenerator.Content.members[6].id,
newsletter_id: DataGenerator.Content.newsletters[2].id
} }
// Member index 7 (with-product@test.com), subscribed to no newsletter
]; ];
const posts_authors = [ const posts_authors = [