mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 05:50:35 +03:00
Added test coverage for invalid member import emails
no issue - This test should serve as a control for new batched importer
This commit is contained in:
parent
a1e6b8f898
commit
ef41c57974
@ -57,6 +57,7 @@ const sanitizeInput = (members) => {
|
||||
sanitized,
|
||||
duplicateStripeCount
|
||||
};
|
||||
};
|
||||
|
||||
function serializeMemberLabels(labels) {
|
||||
if (_.isString(labels)) {
|
||||
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
|
2
test/utils/fixtures/csv/member-invalid-email.csv
Normal file
2
test/utils/fixtures/csv/member-invalid-email.csv
Normal file
@ -0,0 +1,2 @@
|
||||
email
|
||||
invalid_email_value
|
|
Loading…
Reference in New Issue
Block a user