bp - tests - troubleshooting - dump last errors
MODIFY
test/api/BillingTestHelper.ts
test/api/BillingTestHelper.ts
@@ -6,7 +6,6 @@ import { BillingSettings, BillingSettingsType, SettingDB } from '../../src/types
import { ChargePointErrorCode, ChargePointStatus, OCPPStatusNotificationRequest } from '../../src/types/ocpp/OCPPServer';
import ChargingStation, { ConnectorType } from '../../src/types/ChargingStation';
import PricingDefinition, { DayOfWeek, PricingDimension, PricingDimensions, PricingEntity, PricingRestriction } from '../../src/types/Pricing';
-import Tenant, { TenantComponents } from '../../src/types/Tenant';
import chai, { expect } from 'chai';
import AsyncTaskStorage from '../../src/storage/mongodb/AsyncTaskStorage';
@@ -28,6 +27,7 @@ import SiteContext from './context/SiteContext';
import { StatusCodes } from 'http-status-codes';
import Stripe from 'stripe';
import StripeBillingIntegration from '../../src/integration/billing/stripe/StripeBillingIntegration';
+import Tenant from '../../src/types/Tenant';
import TenantContext from './context/TenantContext';
import TestConstants from './client/utils/TestConstants';
import TestUtils from './TestUtils';
@@ -560,7 +560,7 @@ export default class BillingTestHelper {
// --------------------------------
// Check transaction rounded price
// --------------------------------
- const roundedPrice = Utils.createDecimal(transactionResponse.data.stop.roundedPrice);
+ const roundedPrice = Utils.createDecimal(transactionResponse.data.stop.roundedPrice as number);
assert(roundedPrice.equals(expectedPrice), `The rounded price should be: ${expectedPrice} - actual value: ${roundedPrice.toNumber()}`);
// ---------------------------
// Check priced dimensions
@@ -629,7 +629,7 @@ export default class BillingTestHelper {
const connectorId = 1;
// TODO - wrong type User vs UserContext?
const user = this.getCurrentUserContext() as any;
- const tagId = user?.tags?.[0]?.id;
+ const tagId = user?.tags?.[0]?.id as string;
assert(tagId, 'User must have a valid tag');
// # Begin
const startDate = moment(expectedStartDate);
@@ -813,7 +813,7 @@ export default class BillingTestHelper {
assert(response?.data?.status === 'Success', 'The operation should succeed');
assert(response?.data?.id, 'The ID should not be null');
- const pricingDefinitionId = response?.data?.id;
+ const pricingDefinitionId = response?.data?.id as string;
response = await this.adminUserService.pricingApi.readPricingDefinition(pricingDefinitionId);
assert(response?.data?.id === pricingDefinitionId, 'The ID should be: ' + pricingDefinitionId);
assert(response?.data?.entityName === chargingStation.id);
@@ -878,7 +878,7 @@ export default class BillingTestHelper {
assert(response?.data?.status === 'Success', 'The operation should succeed');
assert(response?.data?.id, 'The ID should not be null');
- const pricingDefinitionId = response?.data?.id;
+ const pricingDefinitionId = response?.data?.id as string;
response = await this.adminUserService.pricingApi.readPricingDefinition(pricingDefinitionId);
assert(response?.data?.id === pricingDefinitionId, 'The ID should be: ' + pricingDefinitionId);
assert(response?.data?.entityName === siteArea.name, 'The Site Area data should be retrieved as well');
@@ -888,8 +888,11 @@ export default class BillingTestHelper {
let response = await this.getCurrentUserService().billingApi.createBillingAccount({
businessOwnerID: this.getCurrentUserContext().id
});
+ if (response.status !== StatusCodes.OK) {
+ await this.dumpLastErrors();
+ }
expect(response.status).to.be.eq(StatusCodes.OK);
- const accountID = response.data?.id ;
+ const accountID = response.data?.id as string;
response = await this.getCurrentUserService().billingApi.readBillingAccount(accountID);
assert(response.status === StatusCodes.OK, 'Response status should be 200');
const billingAccount = response.data as BillingAccount ;
@@ -903,6 +906,9 @@ export default class BillingTestHelper {
// Send the onboarding mail to the business user
// ----------------------------------------------------
let response = await this.getCurrentUserService().billingApi.onboardBillingAccount(accountID);
+ if (response.status !== StatusCodes.OK) {
+ await this.dumpLastErrors();
+ }
expect(response.status).to.be.eq(StatusCodes.OK);
// --------------------------------------------------------------
// Account is now in a PENDING state
@@ -914,6 +920,9 @@ export default class BillingTestHelper {
// Generate the link to the onboarding page
// ----------------------------------------------------
response = await this.getCurrentUserService().billingApi.refreshBillingAccount({ accountID, TenantID: this.getTenantID() });
+ if (response.status !== StatusCodes.OK) {
+ await this.dumpLastErrors();
+ }
expect(response.status).to.be.eq(StatusCodes.OK);
// --------------------------------------------------------------
// Account is now still in a PENDING state
@@ -930,6 +939,9 @@ export default class BillingTestHelper {
// Let's assume the onboarding has been completed successfully
// --------------------------------------------------------------
response = await this.getCurrentUserService().billingApi.activateBillingAccount({ accountID, TenantID: this.getTenantID() });
+ if (response.status !== StatusCodes.OK) {
+ await this.dumpLastErrors();
+ }
expect(response.status).to.be.eq(StatusCodes.OK);
expect(response.data?.id).to.be.eq(accountID);
// --------------------------------------------------------------
@@ -987,6 +999,9 @@ export default class BillingTestHelper {
const transfer = await this.getLatestTransfer(BillingTransferStatus.DRAFT);
assert(transfer?.id, 'transfer ID should not be null');
let response = await this.getCurrentUserService().billingApi.finalizeTransfer(transfer.id);
+ if (response.status !== StatusCodes.OK) {
+ await this.dumpLastErrors();
+ }
expect(response.status).to.be.eq(StatusCodes.OK);
response = await this.adminUserService.billingApi.readTransfer(transfer.id);
expect(response.status).to.be.eq(StatusCodes.OK);
@@ -997,6 +1012,9 @@ export default class BillingTestHelper {
const transfer = await this.getLatestTransfer(BillingTransferStatus.FINALIZED);
assert(transfer?.id, 'transfer ID should not be null');
let response = await this.getCurrentUserService().billingApi.sendTransfer(transfer.id);
+ if (response.status !== StatusCodes.OK) {
+ await this.dumpLastErrors();
+ }
expect(response.status).to.be.eq(StatusCodes.OK);
response = await this.adminUserService.billingApi.readTransfer(transfer.id);
expect(response.status).to.be.eq(StatusCodes.OK);

bp - tests - troubleshooting - dump last errors