From 284b51f82d384aa0d385a125cdb32018a9f6a7c1 Mon Sep 17 00:00:00 2001
From: fsdavid <daviti1@mail.com>
Date: Fri, 16 Jul 2021 01:14:12 +0200
Subject: [PATCH] Fix unit test test eiot

---
 e2e/protractor.conf.js                        |  10 +-
 .../parcellationRegion/region.base.spec.ts    | 137 +++++++++---------
 2 files changed, 73 insertions(+), 74 deletions(-)

diff --git a/e2e/protractor.conf.js b/e2e/protractor.conf.js
index 500dbdf9f..2fbc49e5b 100644
--- a/e2e/protractor.conf.js
+++ b/e2e/protractor.conf.js
@@ -22,7 +22,7 @@ const PROTRACTOR_SPECS = process.env.PROTRACTOR_SPECS
 const localConfig = {
   ...(SELENIUM_ADDRESS
     ? { seleniumAddress: SELENIUM_ADDRESS }
-    : { directConnect: true } 
+    : { directConnect: true }
   ),
   capabilities: {
     // Use headless chrome
@@ -71,13 +71,13 @@ let bsLocal
 /**
  * config adapted from
  * https://github.com/browserstack/protractor-browserstack
- * 
+ *
  * MIT licensed
  */
 const bsConfig = {
   'browserstackUser': BROWSERSTACK_USERNAME,
   'browserstackKey': BROWSERSTACK_ACCESS_KEY,
-  
+
   'capabilities': {
     'build': 'protractor-browserstack',
     'name': BROWSERSTACK_TEST_NAME || 'iav_e2e',
@@ -121,7 +121,7 @@ exports.config = {
   jasmineNodeOpts: {
     defaultTimeoutInterval: 1000 * 60 * 10
   },
-  
+
   ...(
     BROWSERSTACK_ACCESS_KEY && BROWSERSTACK_USERNAME
     ? bsConfig
@@ -131,4 +131,4 @@ exports.config = {
   ...(
     (directConnect && { directConnect }) || {}
   )
-}
\ No newline at end of file
+}
diff --git a/src/atlasComponents/parcellationRegion/region.base.spec.ts b/src/atlasComponents/parcellationRegion/region.base.spec.ts
index da28ffb41..0fb3792e9 100644
--- a/src/atlasComponents/parcellationRegion/region.base.spec.ts
+++ b/src/atlasComponents/parcellationRegion/region.base.spec.ts
@@ -11,7 +11,8 @@ const  util = require('common/util')
 const mr0 = {
   labelIndex: 1,
   name: 'mr0',
-  fullId: {
+  availableIn: [{id: 'fzj/mock/rs/v0.0.0/aaa-bbb'}, {id: 'fzj/mock/rs/v0.0.0/bbb-bbb'}, {id: 'fzj/mock/rs/v0.0.0/ccc-bbb'}],
+  id: {
     kg: {
       kgSchema: 'fzj/mock/pr',
       kgId: 'aaa-bbb'
@@ -34,7 +35,7 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
       const mr1wrong = {
         labelIndex: 1,
         name: 'mr1',
-        fullId: {
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'fff-bbb'
@@ -45,7 +46,7 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
       const mr0wrong = {
         labelIndex: 1,
         name: 'mr0',
-        fullId: {
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'aaa-fff'
@@ -56,8 +57,8 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
 
       const mr1lh = {
         labelIndex: 1,
-        name: 'mr1 - left hemisphere',
-        fullId: {
+        name: 'mr1 left',
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'ccc-bbb'
@@ -67,8 +68,8 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
 
       const mr1rh = {
         labelIndex: 1,
-        name: 'mr1 - right hemisphere',
-        fullId: {
+        name: 'mr1 right',
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'ccc-bbb'
@@ -76,10 +77,16 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
         }
       }
 
+      const mr0nh = {
+        labelIndex: 11,
+        name: 'mr0',
+      }
+
       const mr0lh = {
         labelIndex: 1,
-        name: 'mr0 - left hemisphere',
-        fullId: {
+        name: 'mr0 left',
+        availableIn: [{id: 'fzj/mock/rs/v0.0.0/aaa-bbb'}, {id: 'fzj/mock/rs/v0.0.0/bbb-bbb'}, {id: 'fzj/mock/rs/v0.0.0/ccc-bbb'}],
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'aaa-bbb'
@@ -89,8 +96,8 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
 
       const mr0rh = {
         labelIndex: 1,
-        name: 'mr0 - right hemisphere',
-        fullId: {
+        name: 'mr0 right',
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'aaa-bbb'
@@ -101,7 +108,7 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
       const mr1 = {
         labelIndex: 1,
         name: 'mr1',
-        fullId: {
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'ccc-bbb'
@@ -113,16 +120,19 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
 
       const mp1h = {
         name: 'mp1h',
-        regions: [ mr1lh, mr0lh,  mr0rh, mr1rh ]
+        '@id': 'parcellation/id',
+        regions: [ mr0nh, mr1lh, mr0lh,  mr0rh, mr1rh ]
       }
 
       const mpWrong = {
         name: 'mp1h',
+        '@id': 'parcellation/id',
         regions: [ mr1wrong, mr0wrong ]
       }
 
       const mp0 = {
         name: 'mp0',
+        '@id': 'parcellation/id',
         regions: [ mr1, mr0 ]
       }
 
@@ -130,31 +140,31 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
 
       const mt0 = {
         name: 'mt0',
-        fullId: 'fzj/mock/rs/v0.0.0/aaa-bbb',
+        '@id': 'fzj/mock/rs/v0.0.0/aaa-bbb',
         parcellations: [ mp0 ]
       }
 
       const mt1 = {
         name: 'mt1',
-        fullId: 'fzj/mock/rs/v0.0.0/bbb-bbb',
+        '@id': 'fzj/mock/rs/v0.0.0/bbb-bbb',
         parcellations: [ mp0 ]
       }
 
       const mt2 = {
         name: 'mt2',
-        fullId: 'fzj/mock/rs/v0.0.0/ccc-bbb',
+        '@id': 'fzj/mock/rs/v0.0.0/ccc-bbb',
         parcellations: [ mp1h ]
       }
 
       const mt3 = {
         name: 'mt3',
-        fullId: 'fzj/mock/rs/v0.0.0/ddd-bbb',
+        '@id': 'fzj/mock/rs/v0.0.0/ddd-bbb',
         parcellations: [ mp1h ]
       }
 
       const mtWrong = {
         name: 'mtWrong',
-        fullId: 'fzj/mock/rs/v0.0.0/ddd-bbb',
+        '@id': 'fzj/mock/rs/v0.0.0/ddd-bbb',
         parcellations: [ mpWrong ]
       }
 
@@ -169,7 +179,8 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
         mr0lh,
         mt3,
         mr0,
-        mr0rh
+        mr0rh,
+        mr0nh
       }
 
     }
@@ -181,7 +192,7 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
       const mr1wrong = {
         labelIndex: 1,
         name: 'mr1',
-        fullId: {
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'fff-bbb'
@@ -192,7 +203,7 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
       const mr0wrong = {
         labelIndex: 1,
         name: 'mr0',
-        fullId: {
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'aaa-fff'
@@ -204,8 +215,8 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
       const mr1lh = {
         labelIndex: 1,
         name: 'mr1',
-        status: 'left hemisphere',
-        fullId: {
+        status: 'left',
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'ccc-bbb'
@@ -216,8 +227,8 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
       const mr1rh = {
         labelIndex: 1,
         name: 'mr1',
-        status: 'right hemisphere',
-        fullId: {
+        status: 'right',
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'ccc-bbb'
@@ -225,11 +236,16 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
         }
       }
 
+      const mr0nh = {
+        labelIndex: 11,
+        name: 'mr0',
+      }
+
       const mr0lh = {
         labelIndex: 1,
-        name: 'mr0',
-        status: 'left hemisphere',
-        fullId: {
+        name: 'mr0 left',
+        availableIn: [{id: 'fzj/mock/rs/v0.0.0/aaa-bbb'}, {id: 'fzj/mock/rs/v0.0.0/bbb-bbb'}, {id: 'fzj/mock/rs/v0.0.0/ccc-bbb'}],
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'aaa-bbb'
@@ -239,9 +255,8 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
 
       const mr0rh = {
         labelIndex: 1,
-        name: 'mr0',
-        status: 'right hemisphere',
-        fullId: {
+        name: 'mr0 right',
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'aaa-bbb'
@@ -252,7 +267,7 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
       const mr1 = {
         labelIndex: 1,
         name: 'mr1',
-        fullId: {
+        id: {
           kg: {
             kgSchema: 'fzj/mock/pr',
             kgId: 'ccc-bbb'
@@ -264,16 +279,19 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
 
       const mp1h = {
         name: 'mp1h',
-        regions: [ mr1lh, mr0lh,  mr0rh, mr1rh ]
+        '@id': 'parcellation/id',
+        regions: [ mr0nh, mr1lh, mr0lh,  mr0rh, mr1rh ]
       }
 
       const mpWrong = {
         name: 'mp1h',
+        '@id': 'parcellation/id',
         regions: [ mr1wrong, mr0wrong ]
       }
 
       const mp0 = {
         name: 'mp0',
+        '@id': 'parcellation/id',
         regions: [ mr1, mr0 ]
       }
 
@@ -281,31 +299,31 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
 
       const mt0 = {
         name: 'mt0',
-        fullId: 'fzj/mock/rs/v0.0.0/aaa-bbb',
+        '@id': 'fzj/mock/rs/v0.0.0/aaa-bbb',
         parcellations: [ mp0 ]
       }
 
       const mt1 = {
         name: 'mt1',
-        fullId: 'fzj/mock/rs/v0.0.0/bbb-bbb',
+        '@id': 'fzj/mock/rs/v0.0.0/bbb-bbb',
         parcellations: [ mp0 ]
       }
 
       const mt2 = {
         name: 'mt2',
-        fullId: 'fzj/mock/rs/v0.0.0/ccc-bbb',
+        '@id': 'fzj/mock/rs/v0.0.0/ccc-bbb',
         parcellations: [ mp1h ]
       }
 
       const mt3 = {
         name: 'mt3',
-        fullId: 'fzj/mock/rs/v0.0.0/ddd-bbb',
+        '@id': 'fzj/mock/rs/v0.0.0/ddd-bbb',
         parcellations: [ mp1h ]
       }
 
       const mtWrong = {
         name: 'mtWrong',
-        fullId: 'fzj/mock/rs/v0.0.0/ddd-bbb',
+        '@id': 'fzj/mock/rs/v0.0.0/ddd-bbb',
         parcellations: [ mpWrong ]
       }
 
@@ -318,6 +336,7 @@ const getRegionInOtherTemplateSelectorBundle = (version: EnumParcRegVersion) =>
         mt1,
         mp1h,
         mr0lh,
+        mr0nh,
         mt3,
         mr0,
         mr0rh
@@ -336,7 +355,7 @@ describe('> region.base.ts', () => {
     for (const enumKey of Object.keys(EnumParcRegVersion)) {
       describe(`> selector version for ${enumKey}`, () => {
 
-        const { mockFetchedTemplates, mr0, mt2, mt0, mp0, mt1, mp1h, mr0lh, mt3, mr0rh } = getRegionInOtherTemplateSelectorBundle(enumKey as EnumParcRegVersion)
+        const { mockFetchedTemplates, mr0, mt2, mt0, mp0, mt1, mp1h, mr0lh, mt3, mr0rh, mr0nh } = getRegionInOtherTemplateSelectorBundle(enumKey as EnumParcRegVersion)
 
         let selectedAtlas = {
           templateSpaces: mockFetchedTemplates
@@ -349,7 +368,7 @@ describe('> region.base.ts', () => {
           })
 
           it('> length checks out', () => {
-            expect(result.length).toEqual(5)
+            expect(result.length).toEqual(4)
           })
 
           it('> does not contain itself', () => {
@@ -378,66 +397,46 @@ describe('> region.base.ts', () => {
                 template: mt2,
                 parcellation: mp1h,
                 region: mr0lh,
-                hemisphere: 'left hemisphere'
+                hemisphere: 'left'
               })
             )
           })
           it('> hemisphere result has hemisphere metadata # 2', () => {
             expect(result).toContain(
               jasmine.objectContaining({
-                template: mt3,
-                parcellation: mp1h,
-                region: mr0lh,
-                hemisphere: 'left hemisphere'
-              })
-            )
-          })
-          it('> hemisphere result has hemisphere metadata # 3', () => {
-            expect(result).toContain(
-              jasmine.objectContaining({
-                template: mt3,
-                parcellation: mp1h,
-                region: mr0rh,
-                hemisphere: 'right hemisphere'
-              })
-            )
-          })
-          it('> hemisphere result has hemisphere metadata # 4', () => {
-            expect(result).toContain(
-              jasmine.objectContaining({
-                template: mt3,
+                template: mt2,
                 parcellation: mp1h,
                 region: mr0rh,
-                hemisphere: 'right hemisphere'
+                hemisphere: 'right'
               })
             )
           })
         })
 
-        describe('> hemisphere data selected (left hemisphere), simulates julich-brain in mni152', () => {
+        describe('> hemisphere data selected (left), simulates julich-brain in mni152', () => {
           let result
           beforeAll(() => {
-            result = regionInOtherTemplateSelector.projector(selectedAtlas, mockFetchedTemplates, { region: {...mt2, context: {template: mt0, parcellation: mp1h} }})
+            result = regionInOtherTemplateSelector.projector(selectedAtlas, mockFetchedTemplates, { region: {...mr0lh, context: {template: mt0, parcellation: mp1h} }})
           })
 
           it('> length checks out', () => {
             expect(result.length).toEqual(3)
           })
 
-          it('> does not select wrong hemisphere (right hemisphere)', () => {
+          it('> does not select wrong hemisphere (right)', () => {
             expect(result).not.toContain(
               jasmine.objectContaining({
-                template: mt3,
+                template: mt2,
                 parcellation: mp1h,
                 region: mr0rh,
               })
             )
           })
 
-          it('> select the corresponding hemisphere (left hemisphere), but without hemisphere metadata', () => {
+          it('> select the region with correct hemisphere', () => {
             expect(result).toContain(
               jasmine.objectContaining({
-                template: mt3,
+                template: mt2,
                 parcellation: mp1h,
                 region: mr0lh
               })
-- 
GitLab