diff --git a/core/server/api/canary/members.js b/core/server/api/canary/members.js index 3c6145ea07..7b6f3b76bd 100644 --- a/core/server/api/canary/members.js +++ b/core/server/api/canary/members.js @@ -57,6 +57,7 @@ const sanitizeInput = (members) => { sanitized, duplicateStripeCount }; +}; function serializeMemberLabels(labels) { if (_.isString(labels)) { diff --git a/test/regression/api/canary/admin/members_spec.js b/test/regression/api/canary/admin/members_spec.js index e23dd6c918..213204f5be 100644 --- a/test/regression/api/canary/admin/members_spec.js +++ b/test/regression/api/canary/admin/members_spec.js @@ -447,6 +447,33 @@ describe('Members API', function () { jsonResponse.meta.stats.imported.count.should.equal(0); jsonResponse.meta.stats.invalid.count.should.equal(2); + + should.equal(jsonResponse.meta.stats.invalid.errors.length, 1); + jsonResponse.meta.stats.invalid.errors[0].message.should.equal('Missing Stripe connection'); + }); + }); + + it('Fails to import memmber with invalid values', function () { + return request + .post(localUtils.API.getApiQuery(`members/upload/`)) + .attach('membersfile', path.join(__dirname, '/../../../../utils/fixtures/csv/member-invalid-email.csv')) + .set('Origin', config.get('url')) + .expect('Content-Type', /json/) + .expect('Cache-Control', testUtils.cacheRules.private) + .expect(201) + .then((res) => { + should.not.exist(res.headers['x-cache-invalidate']); + const jsonResponse = res.body; + + should.exist(jsonResponse); + should.exist(jsonResponse.meta); + should.exist(jsonResponse.meta.stats); + + jsonResponse.meta.stats.imported.count.should.equal(0); + jsonResponse.meta.stats.invalid.count.should.equal(1); + + should.equal(jsonResponse.meta.stats.invalid.errors.length, 1); + jsonResponse.meta.stats.invalid.errors[0].message.should.equal('Validation (isEmail) failed for email'); }); }); diff --git a/test/utils/fixtures/csv/member-invalid-email.csv b/test/utils/fixtures/csv/member-invalid-email.csv new file mode 100644 index 0000000000..330109c06d --- /dev/null +++ b/test/utils/fixtures/csv/member-invalid-email.csv @@ -0,0 +1,2 @@ +email +invalid_email_value