This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git


The following commit(s) were added to refs/heads/master by this push:
     new 3f4af92d extra checks and strictness to make composer karma tests pass
3f4af92d is described below

commit 3f4af92d81335ee359fd0176bcfac9e92a891bcd
Author: Alex Heneveld <[email protected]>
AuthorDate: Tue Jun 28 10:33:07 2022 +0000

    extra checks and strictness to make composer karma tests pass
---
 .../app/components/util/model/entity.model.js       |  2 +-
 .../app/components/util/model/entity.model.spec.js  | 21 +++++++++++++--------
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git 
a/ui-modules/blueprint-composer/app/components/util/model/entity.model.js 
b/ui-modules/blueprint-composer/app/components/util/model/entity.model.js
index 4b380d24..b0c884c8 100644
--- a/ui-modules/blueprint-composer/app/components/util/model/entity.model.js
+++ b/ui-modules/blueprint-composer/app/components/util/model/entity.model.js
@@ -1358,7 +1358,7 @@ function cleanForJson(item, depth) {
     if (item instanceof Map) {
         let result = {};
         for (let [key, value] of item) {
-            if (value.hasOwnProperty(DSL.ENTITY_SPEC) && 
value[DSL.ENTITY_SPEC] instanceof Entity) {
+            if (value && value.hasOwnProperty(DSL.ENTITY_SPEC) && 
value[DSL.ENTITY_SPEC] instanceof Entity) {
                 let _jsonVal = {};
                 _jsonVal[DSL.ENTITY_SPEC] = value[DSL.ENTITY_SPEC].getData();
                 result[key] = _jsonVal;
diff --git 
a/ui-modules/blueprint-composer/app/components/util/model/entity.model.spec.js 
b/ui-modules/blueprint-composer/app/components/util/model/entity.model.spec.js
index 2b18a088..71798d12 100644
--- 
a/ui-modules/blueprint-composer/app/components/util/model/entity.model.spec.js
+++ 
b/ui-modules/blueprint-composer/app/components/util/model/entity.model.spec.js
@@ -16,9 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import {Entity, EntityFamily, PREDICATE_MEMBERSPEC} from "./entity.model";
+import {Entity, EntityFamily} from "./entity.model";
 import {Issue} from './issue.model';
 
+const DOT_MEMBERSPEC_REGEX = /^(\w+\.)*member[sS]pec$/;
+export const PREDICATE_DOT_MEMBERSPEC = (config, 
entity)=>(config.name.match(DOT_MEMBERSPEC_REGEX));
+
 const FIRST_MEMBERSPEC_REGEX = /^(\w+\.)*first[mM]ember[sS]pec$/;
 export const PREDICATE_FIRST_MEMBERSPEC = (config, 
entity)=>(config.name.match(FIRST_MEMBERSPEC_REGEX));
 
@@ -152,15 +155,17 @@ describe('Brooklyn Model', ()=> {
             expect(memberSpecs.length).toBe(2);
             expect(memberSpecs[0].family).toBe(EntityFamily.SPEC);
             expect(memberSpecs[1].family).toBe(EntityFamily.SPEC);
-            expect(entity.children[1].getClusterMemberspecEntity((config, 
entity)=>(entity._id === memberSpecs[0]._id))).toBe(memberSpecs[0]);
-            expect(entity.children[1].getClusterMemberspecEntity((config, 
entity)=>(entity._id === memberSpecs[1]._id))).toBe(memberSpecs[1]);
-            
expect(entity.children[1].getClusterMemberspecEntity(PREDICATE_MEMBERSPEC)).toBe(memberSpecs[0]);
-            
expect(entity.children[1].getClusterMemberspecEntity(PREDICATE_FIRST_MEMBERSPEC)).toBe(memberSpecs[1]);
             let configKeys = 
Object.keys(entity.children[1].getClusterMemberspecEntities());
             expect(configKeys).toBeDefined();
             expect(configKeys.length).toBe(2);
-            expect(configKeys[0]).toBe('cluster.memberspec');
-            expect(configKeys[1]).toBe('cluster.firstMemberspec');
+            const msi = configKeys.findIndex(ck => ck=='cluster.memberspec');
+            const fmsi = configKeys.findIndex(ck => 
ck=='cluster.firstMemberspec');
+            expect(msi).not.toBe(-1);
+            expect(fmsi).not.toBe(-1);
+            expect(entity.children[1].getClusterMemberspecEntity((config, 
entity)=>(entity._id === memberSpecs[0]._id))).toBe(memberSpecs[0]);
+            expect(entity.children[1].getClusterMemberspecEntity((config, 
entity)=>(entity._id === memberSpecs[1]._id))).toBe(memberSpecs[1]);
+            
expect(entity.children[1].getClusterMemberspecEntity(PREDICATE_DOT_MEMBERSPEC)).toBe(memberSpecs[msi]);
+            
expect(entity.children[1].getClusterMemberspecEntity(PREDICATE_FIRST_MEMBERSPEC)).toBe(memberSpecs[fmsi]);
         });
 
         // Location
@@ -383,4 +388,4 @@ const BLUEPRINT_OBJECT = {
             }
         }
     ]
-};
\ No newline at end of file
+};

Reply via email to