Repository: SAP/luigi (js)

Issue:
getUserSettings should return empty object instead of null
Currently `getUserSettings` returns null but it should return empty object.
Fix for classic luigi-client and luigi-client wc.

Pull request description:
Fixes getUserSettings method
**Description**

Changes proposed in this pull request:

- fixes fixes 'getUserSettings' method
- fixes related unit tests

**Related issue(s)**

Resolves #3434


Patch:
diff --git a/client/src/lifecycleManager.js b/client/src/lifecycleManager.js
index ea3fc9e3..6a4c9364 100644
--- a/client/src/lifecycleManager.js
+++ b/client/src/lifecycleManager.js
@@ -530,7 +530,7 @@ class LifecycleManager extends LuigiClientBase {
    * const userSettings = LuigiClient.getUserSettings()
    */
   getUserSettings() {
-    return this.currentContext.internal.userSettings;
+    return this.currentContext.internal.userSettings || {};
   }
 
   /**
diff --git a/core/src/services/web-components.js b/core/src/services/web-components.js
index 93d8d9ba..57d89b15 100644
--- a/core/src/services/web-components.js
+++ b/core/src/services/web-components.js
@@ -573,15 +573,16 @@ class WebComponentSvcClass {
     return new Promise((resolve, reject) => {
       if (wc.userSettingsGroup) {
         const userSettingsGroupName = wc.userSettingsGroup;
+
         LuigiConfig.readUserSettings().then(storedUserSettingsData => {
           const hasUserSettings =
             userSettingsGroupName && typeof storedUserSettingsData === 'object' && storedUserSettingsData !== null;
+          const userSettings = hasUserSettings ? storedUserSettingsData[userSettingsGroupName] : {};
 
-          const userSettings = hasUserSettings ? storedUserSettingsData[userSettingsGroupName] : null;
           resolve(userSettings);
         });
       } else {
-        reject(null);
+        reject({});
       }
     });
   }
diff --git a/docs/luigi-compound-container-api.md b/docs/luigi-compound-container-api.md
index 5a805eca..f78c61f4 100644
--- a/docs/luigi-compound-container-api.md
+++ b/docs/luigi-compound-container-api.md
@@ -16,7 +16,7 @@ meta -->
 
 # Luigi Compound Container API
 
-This document outlines the parameters provided by the Luigi Compound Container. Luigi Compound Container provides the possibility to insert multiple webcomponent-based microfrontends in one container 
+This document outlines the parameters provided by the Luigi Compound Container. Luigi Compound Container provides the possibility to insert multiple webcomponent-based microfrontends in one container
 
 ## API Reference
 
@@ -30,8 +30,8 @@ Type: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Globa
 
 ### compoundConfig
 
-The configuration for the compound microfrontend
-Take a look at <https://docs.luigi-project.io/docs/navigation-parameters-reference/?section=compound>
+The configuration for the compound microfrontend.
+Take a look at the [compound parameter](https://docs.luigi-project.io/docs/navigation-parameters-reference/?section=compound) for details.
 
 Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
 
@@ -149,7 +149,7 @@ Type: ([boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Glo
 
 #### Parameters
 
--   `WebComponentSettings` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** 
+-   `WebComponentSettings` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?**
     -   `WebComponentSettings.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** : string, like module.
     -   `WebComponentSettings.selfRegistered` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** : if it is true, the web component bundle will be added via script tag.
     -   `WebComponentSettings.tagName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** : tag name where web component is added to DOM.
@@ -173,7 +173,7 @@ Function that updates the context of the compound microfrontend.
 containerElement.updateContext({newContextData: 'some data'})
 ```
 
-Returns **void** 
+Returns **void**
 
 **Meta**
 
@@ -183,7 +183,7 @@ Returns **void**
 
 Manually triggers the micro frontend rendering process when using the defer-init attribute.
 
-Returns **void** 
+Returns **void**
 
 **Meta**
 


Test patch:
diff --git a/core/test/services/web-components.spec.js b/core/test/services/web-components.spec.js
index b9c1a2b2..40ed59f1 100644
--- a/core/test/services/web-components.spec.js
+++ b/core/test/services/web-components.spec.js
@@ -530,7 +530,7 @@ describe('WebComponentService', function() {
       };
       sb.stub(LuigiConfig, 'readUserSettings').resolves();
       WebComponentService.getUserSettingsForWc(wc).then(userSettings => {
-        expect(userSettings).equal(null);
+        expect(userSettings).to.deep.equal({});
       });
     });
   });