utbilling - test minor changes
MODIFY
test/api/BillingStripeIntegrationTest.ts
test/api/BillingStripeIntegrationTest.ts
@@ -26,18 +26,15 @@ describe('Billing Stripe Service', function() {
describe('Where the admin user', () => {
before(async () => {
- testData.billingImpl = await testData.setBillingSystemValidCredentials();
});
after(async () => {
- // TODO - cleanup test data!
- // Cleanup of the utbilling tenant is useless if we cannot cleanup the utbilling stripe account as well
+ // Cleanup of the utbilling tenant is useless
+ // Anyway, there is no way to cleanup the utbilling stripe account!
});
it('Should add a payment method to BILLING-TEST user', async () => {
- const customerID: string = testData.billingUser.billingData.customerID;
- const stripe_test_token = 'tok_visa';
- await testData.assignPaymentMethod(customerID, stripe_test_token);
+ await testData.assignPaymentMethod('tok_visa');
});
it('should create and pay a first invoice for BILLING-TEST user', async () => {
@@ -58,9 +55,7 @@ describe('Billing Stripe Service', function() {
});
it('Should add a different payment method to BILLING-TEST user', async () => {
- const customerID: string = testData.billingUser.billingData.customerID;
- const stripe_test_token = 'tok_fr';
- await testData.assignPaymentMethod(customerID, stripe_test_token);
+ await testData.assignPaymentMethod('tok_fr');
});
it('should create and pay a second invoice for BILLING-TEST user', async () => {

MODIFY
test/api/BillingStripeTestData.ts
test/api/BillingStripeTestData.ts
@@ -58,10 +58,9 @@ export default class StripeIntegrationTestData {
assert(userData && userData.id, 'response should not be null');
// Let's get the newly created user
this.dynamicUser = await UserStorage.getUser(this.getTenantID(), userData.id);
- assert(this.dynamicUser && this.dynamicUser?.billingData?.customerID, 'Customer ID should be set');
// Let's get access to the STRIPE implementation - StripeBillingIntegration instance
this.billingImpl = await this.setBillingSystemValidCredentials();
- this.billingUser = await this.billingImpl.getUser(this.dynamicUser.billingData.customerID);
+ this.billingUser = await this.billingImpl.getUser(this.getCustomerID());
expect(this.billingUser, 'Billing user should not ber null');
}
@@ -130,10 +129,10 @@ export default class StripeIntegrationTestData {
return true;
}
- public async assignPaymentMethod(customerID: string, stripe_test_token: string) : Promise<IStripeSource> {
+ public async assignPaymentMethod(stripe_test_token: string) : Promise<IStripeSource> {
const concreteImplementation : StripeBillingIntegration = this.billingImpl as StripeBillingIntegration;
const stripeInstance = await concreteImplementation.getStripeInstance();
- const source = await stripeInstance.customers.createSource(customerID, {
+ const source = await stripeInstance.customers.createSource(this.getCustomerID(), {
source: stripe_test_token
});
expect(source).to.not.be.null;
@@ -168,4 +167,10 @@ export default class StripeIntegrationTestData {
assert(tenantId, 'Tenant ID cannot be null');
return tenantId;
}
+
+ public getCustomerID(): string {
+ const customerID = this.dynamicUser?.billingData?.customerID;
+ assert(customerID, 'customer ID cannot be null');
+ return customerID;
+ }
}

utbilling - test minor changes