pricing settings - adaptation of the tests
MODIFY
test/api/EncryptionSettingTest.ts
test/api/EncryptionSettingTest.ts
import chai, { expect } from 'chai';
import CentralServerService from './client/CentralServerService';
+import { HTTPError } from '../../src/types/HTTPError';
import { StatusCodes } from 'http-status-codes';
-import TestConstants from './client/utils/TestConstants';
import TestData from './client/utils/TestData';
import chaiSubset from 'chai-subset';
import config from '../config';
@@ -95,8 +95,8 @@ describe('Encryption Setting', function() {
}
}
}`);
- const update = await testData.centralService.updateEntity(testData.centralService.settingApi, testData.data);
- expect(update.status).to.equal(StatusCodes.OK);
+ const update = await testData.centralService.updateEntity(testData.centralService.settingApi, testData.data, false);
+ expect(update.status).to.equal(HTTPError.TENANT_COMPONENT_CHANGED);
// Retrieve the updated setting and check
read = await testData.centralService.settingApi.readByIdentifier({ 'Identifier': 'pricing' });
expect(read.status).to.equal(StatusCodes.OK);

MODIFY
test/api/SettingTest.ts
test/api/SettingTest.ts
@@ -207,7 +207,20 @@ describe('Setting', function() {
// Store the old setting
const oldSetting = read.data;
// Activate convergent charging
- testData.data = JSON.parse(`{"id":"${testData.credentials.tenantId}","name":"${ContextDefinition.TENANT_CONTEXTS.TENANT_WITH_ALL_COMPONENTS}","email":"${testData.credentials.email}","subdomain":"utall","components":{"ocpi":{"active":true,"type":"ocpi"},"organization":{"active":true,"type":null},"pricing":{"active":true,"type":"convergentCharging"},"refund":{"active":true,"type":"concur"},"statistics":{"active":true,"type":null},"analytics":{"active":true,"type":null}}}`);
+ testData.data = JSON.parse(`{
+ "id":"${testData.credentials.tenantId}",
+ "name":"${ContextDefinition.TENANT_CONTEXTS.TENANT_WITH_ALL_COMPONENTS}",
+ "email":"${testData.credentials.email}",
+ "subdomain":"utall",
+ "components":{
+ "ocpi":{ "active":true,"type":"ocpi" },
+ "organization":{ "active":true,"type":null },
+ "pricing":{ "active":true,"type":"convergentCharging" },
+ "refund":{ "active":true,"type":"concur" },
+ "statistics":{ "active":true,"type":null },
+ "analytics":{ "active":true,"type":null }
+ }
+ }`);
// Updating Tenant's components will trigger a logout
let activation = await testData.superCentralService.updateEntity(testData.centralService.tenantApi, testData.data);
expect(activation.status).to.equal(StatusCodes.OK);
@@ -231,12 +244,25 @@ describe('Setting', function() {
let update = await testData.centralService.updateEntity(testData.centralService.settingApi, testData.data);
expect(update.status).to.equal(StatusCodes.OK);
// Activate back simple pricing
- testData.data = JSON.parse(`{"id":"${testData.credentials.tenantId}","name":"${ContextDefinition.TENANT_CONTEXTS.TENANT_WITH_ALL_COMPONENTS}","email":"${testData.credentials.email}","subdomain":"utall","components":{"ocpi":{"active":true,"type":"ocpi"},"organization":{"active":true,"type":null},"pricing":{"active":true,"type":"simple"},"refund":{"active":true,"type":"concur"},"statistics":{"active":true,"type":null},"analytics":{"active":true,"type":null}}}`);
+ testData.data = JSON.parse(`{
+ "id":"${testData.credentials.tenantId}",
+ "name":"${ContextDefinition.TENANT_CONTEXTS.TENANT_WITH_ALL_COMPONENTS}",
+ "email":"${testData.credentials.email}",
+ "subdomain":"utall",
+ "components":{
+ "ocpi":{ "active":true,"type":"ocpi" },
+ "organization":{ "active":true,"type":null },
+ "pricing":{ "active":true,"type":"simple" },
+ "refund":{ "active":true,"type":"concur" },
+ "statistics":{ "active":true,"type":null },
+ "analytics":{"active":true,"type":null }
+ }
+ }`);
activation = await testData.superCentralService.updateEntity(testData.centralService.tenantApi, testData.data);
expect(activation.status).to.equal(StatusCodes.OK);
// Restore default simple pricing setting
- update = await testData.centralService.updateEntity(testData.centralService.settingApi, oldSetting);
- expect(update.status).to.equal(StatusCodes.OK);
+ update = await testData.centralService.updateEntity(testData.centralService.settingApi, oldSetting, false);
+ expect(update.status).to.equal(HTTPError.TENANT_COMPONENT_CHANGED);
});
describe('Crypto settings update tests', () => {

pricing settings - adaptation of the tests