Fixed failing members import tests

refs 05f6faf846

- The logic in "Stripe" error detection depended on error's message string matching, which is not a good practice in general. Had fixed it do to exact match on "context" of the error we throw internally and left more extensive comment about why things are implemented the way they are.
This commit is contained in:
Nazar Gargol 2020-07-01 19:03:12 +12:00
parent 0ee92639dd
commit d03f674a2f

View File

@ -231,8 +231,10 @@ const members = {
});
}
// NOTE: failed to link Stripe customer/plan/subscription
const isStripeLinkingError = error.message && error.message.match(/customer|plan|subscription|Stripe account/g);
// NOTE: failed to link Stripe customer/plan/subscription or have thrown custom Stripe connection error.
// It's a bit ugly doing regex matching to detect errors, but it's the easiest way that works without
// introducing additional logic/data format into current error handling
const isStripeLinkingError = error.message && (error.message.match(/customer|plan|subscription/g) || error.context === i18n.t('errors.api.members.stripeNotConnected.context'));
if (model && isStripeLinkingError) {
if (error.message.indexOf('customer') && error.code === 'resource_missing') {
error.message = `Member not imported. ${error.message}`;