Fix failing unit tests about overriding too late

The fix was to defer injection. The error was made possible in master by git-merging a PR which was
falsely green.

Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
Iku-tursoandJanne Savolainen committed 2023-03-06 14:06:44 +02:00
1 parent c6799e1478
commit bf8449fda7
1 file changed
+14 -15
@@ -21,17 +21,7 @@ import logErrorInjectable from "../../../common/log-error.injectable";
const telemetryDecoratorInjectable = getInjectable({
id: "telemetry-decorator",
instantiate: (diForDecorator) => {
const emitTelemetry = diForDecorator.inject(emitTelemetryInjectable);
const logError = diForDecorator.inject(logErrorInjectable);
const whiteList = diForDecorator.inject(
telemetryWhiteListForFunctionsInjectable,
);
const whiteListMap = getWhiteListMap(whiteList);
return {
instantiate: (diForDecorator) => ({
decorate:
(instantiateToBeDecorated: any) =>
(di: DiContainerForInjection, instantiationParameter: any) => {
@@ -43,10 +33,20 @@ const telemetryDecoratorInjectable = getInjectable({
assert(currentContext);
const whiteListed = whiteListMap.get(
currentContext.injectable.id,
const emitTelemetry = diForDecorator.inject(
emitTelemetryInjectable,
);
const logError = diForDecorator.inject(logErrorInjectable);
const whiteList = diForDecorator.inject(
telemetryWhiteListForFunctionsInjectable,
);
const whiteListMap = getWhiteListMap(whiteList);
const whiteListed = whiteListMap.get(currentContext.injectable.id);
if (whiteListed) {
let params;
@@ -76,8 +76,7 @@ const telemetryDecoratorInjectable = getInjectable({
return instance;
},
};
},
}),
decorable: false,
// Todo: this is required because of imperfect typing in injectable.