refactor(subaccounts): renamed actions
MODIFY
src/notification/NotificationHandler.ts
src/notification/NotificationHandler.ts
@@ -1411,12 +1411,12 @@ export default class NotificationHandler {
try {
// Save
await NotificationHandler.saveNotification(
- tenant, notificationSource.channel, notificationID, ServerAction.BILLING_ACTIVATE_SUB_ACCOUNT, { user });
+ tenant, notificationSource.channel, notificationID, ServerAction.BILLING_SUB_ACCOUNT_ACTIVATE, { user });
// Send
void notificationSource.notificationTask.sendBillingSubAccountActivationNotification(
sourceData, user, tenant, NotificationSeverity.INFO);
} catch (error) {
- await Logging.logActionExceptionMessage(tenant.id, ServerAction.BILLING_ACTIVATE_SUB_ACCOUNT, error);
+ await Logging.logActionExceptionMessage(tenant.id, ServerAction.BILLING_SUB_ACCOUNT_ACTIVATE, error);
}
}
}

MODIFY
src/server/rest/v1/router/api/BillingRouter.ts
src/server/rest/v1/router/api/BillingRouter.ts
@@ -154,7 +154,7 @@ export default class BillingRouter {
private buildRouteBillingActivateSubAccount(): void {
this.router.patch(`/${RESTServerRoute.REST_BILLING_ACTIVATE_SUB_ACCOUNT}`, (req: Request, res: Response, next: NextFunction) => {
req.params.subAccountID = req.params.id;
- void RouterUtils.handleRestServerAction(BillingService.handleActivateSubAccount.bind(this), ServerAction.BILLING_ACTIVATE_SUB_ACCOUNT, req, res, next);
+ void RouterUtils.handleRestServerAction(BillingService.handleActivateSubAccount.bind(this), ServerAction.BILLING_SUB_ACCOUNT_ACTIVATE, req, res, next);
});
}
}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -453,7 +453,7 @@ export enum ServerAction {
BILLING_TEST_DATA_CLEANUP = 'BillingTestDataCleanup',
BILLING_BILL_PENDING_TRANSACTION = 'BillingBillPendingTransaction',
BILLING_SUB_ACCOUNT_CREATE = 'BillingCreateSubAccount',
- BILLING_ACTIVATE_SUB_ACCOUNT = 'BillingCreateSubAccount',
+ BILLING_SUB_ACCOUNT_ACTIVATE = 'BillingSubAccountActivate',
PRICING = 'Pricing',
PRICING_DEFINITION = 'PricingDefinition',

MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
@@ -408,8 +408,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should create a sub account and activate it', async () => {
const response = await billingTestHelper.userService.billingApi.createSubAccount({
- userID: billingTestHelper.userContext.id,
- siteID: billingTestHelper.siteContext.getSite().id,
+ userID: billingTestHelper.userContext.id
});
expect(response.status).to.be.eq(StatusCodes.CREATED);
@@ -425,8 +424,7 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
it('should not activate a sub account twice', async () => {
const response = await billingTestHelper.userService.billingApi.createSubAccount({
- userID: billingTestHelper.userContext.id,
- siteID: billingTestHelper.siteContext.getSite().id,
+ userID: billingTestHelper.userContext.id
});
expect(response.status).to.be.eq(StatusCodes.CREATED);
@@ -501,6 +499,11 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
});
expect(response.status).to.be.eq(StatusCodes.FORBIDDEN);
});
+
+ it('should not activate an inexistent sub account', async () => {
+ const activationResponse = await billingTestHelper.userService.billingApi.activateSubAccount({ accountID: 'xxx' });
+ expect(activationResponse.status).to.be.eq(HTTPError.OBJECT_DOES_NOT_EXIST_ERROR);
+ });
});
describe('Negative tests as an admin user', () => {

refactor(subaccounts): renamed actions