test: added sub-account creation test
MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
@@ -89,7 +89,6 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
describe('Sub-accounts', () => {
it('Should create a sub-account with its associated activation link', async () => {
const subAccount = await stripeTestHelper.createSubAccount();
- expect(subAccount.id).to.exist;
expect(subAccount.accountID).to.exist;
expect(subAccount.activationLink).to.include('https://connect.stripe.com/setup/s/');
expect(subAccount.pending).to.be.true;
@@ -394,6 +393,18 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
expect(response.status).to.be.eq(StatusCodes.OK);
expect(response.data.result.length).to.be.gt(0);
});
+
+ it('should create a sub account', async () => {
+ const response = await billingTestHelper.userService.billingApi.createSubAccount({
+ userID: billingTestHelper.userContext.id,
+ });
+ expect(response.status).to.be.eq(StatusCodes.CREATED);
+ expect(response.data.id).to.not.be.null;
+ expect(response.data.accountID).to.not.be.null;
+ expect(response.data.userID).to.eq(billingTestHelper.userContext.id);
+ expect(response.data.activationLink).to.not.be.null;
+ expect(response.data.pending).to.be.true;
+ });
});
describe('Where basic user', () => {
@@ -453,6 +464,13 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
const itemsAfter = await billingTestHelper.getNumberOfSessions(basicUser.id);
expect(itemsAfter).to.be.eq(itemsBefore + 1);
});
+
+ it('should not be able to create a sub account', async () => {
+ const response = await billingTestHelper.userService.billingApi.createSubAccount({
+ userID: billingTestHelper.userContext.id,
+ });
+ expect(response.status).to.be.eq(StatusCodes.FORBIDDEN);
+ });
});
describe('Negative tests as an admin user', () => {

MODIFY
test/api/client/BillingApi.ts
test/api/client/BillingApi.ts
@@ -51,4 +51,8 @@ export default class BillingApi extends CrudApi {
public async readInvoices(params, paging = TestConstants.DEFAULT_PAGING, ordering = TestConstants.DEFAULT_ORDERING) {
return super.readAll(params, paging, ordering, super.buildRestEndpointUrl(RESTServerRoute.REST_BILLING_INVOICES, params));
}
+
+ public async createSubAccount(params, paging = TestConstants.DEFAULT_PAGING, ordering = TestConstants.DEFAULT_ORDERING) {
+ return super.create(params, super.buildRestEndpointUrl(RESTServerRoute.REST_BILLING_SUB_ACCOUNTS));
+ }
}

test: added sub-account creation test