backend-test-utils: sync feature compat unwrapping

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-12-26 12:12:04 +01:00
parent f866b86521
commit fb051f274e
2 changed files with 16 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-test-utils': patch
---
Sync feature installation compatibility logic with `@backstage/backend-app-api`.
@@ -209,10 +209,19 @@ function isPromise<T>(value: unknown | Promise<T>): value is Promise<T> {
);
}
// Same as in the backend-app-api, handles double defaults from dynamic imports
function unwrapFeature(
feature: BackendFeature | (() => BackendFeature),
feature: BackendFeature | { default: BackendFeature },
): BackendFeature {
return typeof feature === 'function' ? feature() : feature;
if ('$$type' in feature) {
return feature;
}
if ('default' in feature) {
return feature.default;
}
return feature;
}
const backendInstancesToCleanUp = new Array<Backend>();