billing - test issues - troubleshoot timezone related issues
MODIFY
test/api/BillingTest.ts
test/api/BillingTest.ts
@@ -727,6 +727,8 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
async () => {
await billingTestHelper.initChargingStationContext2TestDaysOfTheWeek('TODAY');
await billingTestHelper.initChargingStationContext2TestDaysOfTheWeek('OTHER_DAYS');
+ // Check the charging station timezone
+ billingTestHelper.checkTimezone();
// A tariff applied immediately
await billingTestHelper.userService.billingApi.forceSynchronizeUser({ id: billingTestHelper.userContext.id });
const userWithBillingData = await billingTestHelper.billingImpl.getUser(billingTestHelper.userContext);
@@ -743,6 +745,8 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
await billingTestHelper.initChargingStationContext2TestTimeRestrictions('OTHER_HOURS', atThatParticularMoment);
await billingTestHelper.initChargingStationContext2TestTimeRestrictions('NEXT_HOUR', atThatParticularMoment);
await billingTestHelper.initChargingStationContext2TestTimeRestrictions('FOR_HALF_AN_HOUR', atThatParticularMoment);
+ // Check the charging station timezone
+ billingTestHelper.checkTimezone();
// A tariff applied immediately
await billingTestHelper.userService.billingApi.forceSynchronizeUser({ id: billingTestHelper.userContext.id });
const userWithBillingData = await billingTestHelper.billingImpl.getUser(billingTestHelper.userContext);
@@ -759,6 +763,8 @@ describeif(isBillingProperlyConfigured)('Billing', () => {
const atThatParticularMoment = moment();
await billingTestHelper.initChargingStationContext2TestTimeRestrictions('OTHER_HOURS', atThatParticularMoment);
await billingTestHelper.initChargingStationContext2TestTimeRestrictions('FROM_23:59', atThatParticularMoment);
+ // Check the charging station timezone
+ billingTestHelper.checkTimezone();
// A tariff applied immediately
await billingTestHelper.userService.billingApi.forceSynchronizeUser({ id: billingTestHelper.userContext.id });
const userWithBillingData = await billingTestHelper.billingImpl.getUser(billingTestHelper.userContext);

MODIFY
test/api/BillingTestHelper.ts
test/api/BillingTestHelper.ts
@@ -319,6 +319,13 @@ export default class BillingTestHelper {
return this.chargingStationContext;
}
+ public checkTimezone(): void {
+ const timezone = Utils.getTimezone(this.chargingStationContext.getChargingStation().coordinates);
+ // Simulated sessions last 2 hours - Some tests cannot work when the day is about to change!
+ assert(moment().tz(timezone).isoWeekday() === moment().add(2, 'hours').tz(timezone).isoWeekday(),
+ 'Timezone is set to ' + timezone + ' - test execution can not work in that context');
+ }
+
public async initChargingStationContext2TestTimeRestrictions(testMode = 'E', aParticularMoment: moment.Moment) : Promise<ChargingStationContext> {
// Charging Station Context
this.siteContext = this.tenantContext.getSiteContext(ContextDefinition.SITE_CONTEXTS.SITE_BASIC);

billing - test issues - troubleshoot timezone related issues