From 886fe45aeb2f5bede9aa884a5730e9fe8cd81b09 Mon Sep 17 00:00:00 2001
From: Xiao Gui <xgui3783@gmail.com>
Date: Wed, 15 Mar 2023 16:05:09 +0100
Subject: [PATCH] wip: fix tests

---
 src/atlasComponents/sapi/features/index.ts    |  3 -
 .../sapi/features/sapiFeature.ts              | 13 ----
 src/atlasComponents/sapi/sapi.service.ts      | 27 ++++----
 .../parcellationVersion.pipe.spec.ts          | 56 -----------------
 src/features/entry/entry.component.spec.ts    |  6 ++
 .../feature-view.component.spec.ts            | 14 ++++-
 src/features/fetch.directive.spec.ts          |  8 ---
 src/features/fetch.directive.ts               | 61 -------------------
 src/features/list/list.component.spec.ts      |  6 +-
 src/features/module.ts                        |  2 -
 .../routeStateTransform.service.spec.ts       | 20 ++----
 src/state/atlasSelection/effects.spec.ts      | 49 ++++++---------
 .../layerCtrl.service.spec.ts                 |  7 ---
 .../nehuba/mesh.service/mesh.service.spec.ts  | 12 ++--
 .../navigation.util.spec.ts                   |  2 +-
 .../nehubaViewerGlue.component.spec.ts        | 11 ++--
 .../statusCard/statusCard.component.spec.ts   |  7 ++-
 17 files changed, 74 insertions(+), 230 deletions(-)
 delete mode 100644 src/atlasComponents/sapi/features/index.ts
 delete mode 100644 src/atlasComponents/sapi/features/sapiFeature.ts
 delete mode 100644 src/atlasComponents/sapiViews/core/parcellation/parcellationVersion.pipe.spec.ts
 delete mode 100644 src/features/fetch.directive.spec.ts
 delete mode 100644 src/features/fetch.directive.ts

diff --git a/src/atlasComponents/sapi/features/index.ts b/src/atlasComponents/sapi/features/index.ts
deleted file mode 100644
index 560300f7f..000000000
--- a/src/atlasComponents/sapi/features/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export {
-  SAPIFeature
-} from "./sapiFeature"
\ No newline at end of file
diff --git a/src/atlasComponents/sapi/features/sapiFeature.ts b/src/atlasComponents/sapi/features/sapiFeature.ts
deleted file mode 100644
index 73d6a8ea3..000000000
--- a/src/atlasComponents/sapi/features/sapiFeature.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { throwError } from "rxjs";
-import { switchMap } from "rxjs/operators";
-import { SAPI } from "../sapi.service";
-
-export class SAPIFeature {
-  constructor(private sapi: SAPI, public id: string, public opts: Record<string, string> = {}){
-
-  }
-
-  public detail$ = SAPI.BsEndpoint$.pipe(
-    switchMap(endpt => throwError(`IMPLEMENT ME`))
-  )
-}
diff --git a/src/atlasComponents/sapi/sapi.service.ts b/src/atlasComponents/sapi/sapi.service.ts
index 84d6f4299..b23a4e813 100644
--- a/src/atlasComponents/sapi/sapi.service.ts
+++ b/src/atlasComponents/sapi/sapi.service.ts
@@ -1,20 +1,23 @@
 import { Injectable } from "@angular/core";
 import { HttpClient } from '@angular/common/http';
 import { catchError, map, shareReplay, switchMap, take, tap } from "rxjs/operators";
-import {
-  translateV3Entities
-} from "./translateV3"
 import { getExportNehuba } from "src/util/fn";
 import { MatSnackBar } from "@angular/material/snack-bar";
 import { AtlasWorkerService } from "src/atlasViewer/atlasViewer.workerService.service";
 import { EnumColorMapName } from "src/util/colorMaps";
 import { forkJoin, from, NEVER, Observable, of, throwError } from "rxjs";
-import { SAPIFeature } from "./features";
 import { environment } from "src/environments/environment"
+import {
+  translateV3Entities
+} from "./translateV3"
 import { FeatureType, PathReturn, RouteParam, SapiRoute } from "./typeV3";
 import { BoundingBox, SxplrAtlas, SxplrParcellation, SxplrRegion, SxplrTemplate, VoiFeature, Feature } from "./sxplrTypes";
-import { atlasAppearance } from "src/state";
 
+export const useViewer = {
+  THREESURFER: "THREESURFER",
+  NEHUBA: "NEHUBA",
+  NOT_SUPPORTED: "NOT_SUPPORTED" 
+} as const
 
 export const SIIBRA_API_VERSION_HEADER_KEY='x-siibra-api-version'
 export const EXPECTED_SIIBRA_API_VERSION = '0.3.0'
@@ -233,10 +236,6 @@ export class SAPI{
       switchMap(val => translateV3Entities.translateFeature(val))
     )
   }
-  
-  getFeature(featureId: string, opts: Record<string, string> = {}) {
-    return new SAPIFeature(this, featureId, opts)
-  }
 
   getModalities() {
     return this.v3Get("/feature/_types", { query: {} }).pipe(
@@ -472,7 +471,7 @@ export class SAPI{
 
   public useViewer(template: SxplrTemplate) {
     if (!template) {
-      return of(null as keyof typeof atlasAppearance.const.useViewer)
+      return of(null as keyof typeof useViewer)
     }
     return forkJoin({
       voxel: this.getVoxelTemplateImage(template),
@@ -483,15 +482,15 @@ export class SAPI{
         const { voxel, surface } = vols
         if (voxel.length > 0 && surface.length > 0) {
           console.error(`both voxel and surface length are > 0, this should not happen.`)
-          return atlasAppearance.const.useViewer.NOT_SUPPORTED
+          return useViewer.NOT_SUPPORTED
         }
         if (voxel.length > 0) {
-          return atlasAppearance.const.useViewer.NEHUBA
+          return useViewer.NEHUBA
         }
         if (surface.length > 0) {
-          return atlasAppearance.const.useViewer.THREESURFER
+          return useViewer.THREESURFER
         }
-        return atlasAppearance.const.useViewer.NOT_SUPPORTED
+        return useViewer.NOT_SUPPORTED
       })
     )
   }
diff --git a/src/atlasComponents/sapiViews/core/parcellation/parcellationVersion.pipe.spec.ts b/src/atlasComponents/sapiViews/core/parcellation/parcellationVersion.pipe.spec.ts
deleted file mode 100644
index 1d446f159..000000000
--- a/src/atlasComponents/sapiViews/core/parcellation/parcellationVersion.pipe.spec.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import { IDS } from "src/atlasComponents/sapi/constants"
-import { SAPI } from "src/atlasComponents/sapi/sapi.service"
-import { SapiParcellationModel } from "src/atlasComponents/sapi/type"
-import { getTraverseFunctions } from "./parcellationVersion.pipe"
-
-describe(`parcellationVersion.pipe.ts`, () => {
-  describe("getTraverseFunctions", () => {
-    let julichBrainParcellations: SapiParcellationModel[] = []
-    let endpoint: string
-    beforeAll(async () => {
-      const bsEndPoint = await SAPI.BsEndpoint$.toPromise()
-      endpoint = bsEndPoint
-      const res = await fetch(`${bsEndPoint}/atlases/${encodeURIComponent(IDS.ATLAES.HUMAN)}/parcellations`)
-      const arr: SapiParcellationModel[] = await res.json()
-      julichBrainParcellations = arr.filter(it => /Julich-Brain Cytoarchitectonic Maps/.test(it.name))
-    })
-    it("> should be at least 3 parcellations", () => {
-      console.log(`testing against endpoint: ${endpoint}`)
-      expect(julichBrainParcellations.length).toBeGreaterThanOrEqual(3)
-    })
-
-    const scenarios = [{
-      name: "default",
-      inputFlag: undefined,
-      expect25: false
-    },{
-      name: "skipDeprecated set to true",
-      inputFlag: true,
-      expect25: false
-    },{
-      name: "skipDeprecated set to false",
-      inputFlag: false,
-      expect25: true
-    }]
-
-    for (const { name, inputFlag, expect25} of scenarios) {
-      describe(name, () => {
-        it(`expect to find 25: ${expect25}`, () => {
-          const { findNewer, findOldest } = typeof inputFlag === "undefined"
-          ? getTraverseFunctions(julichBrainParcellations)
-          : getTraverseFunctions(julichBrainParcellations, inputFlag)
-          let cursor: SapiParcellationModel = findOldest()
-          let foundFlag: boolean = false
-          while (cursor) {
-            if (cursor.name === "Julich-Brain Cytoarchitectonic Maps 2.5") {
-              if (expect25) foundFlag = true
-              break
-            }
-            cursor = findNewer(cursor)
-          }
-          expect(foundFlag).toEqual(expect25)
-        })
-      })
-    }
-  })
-})
\ No newline at end of file
diff --git a/src/features/entry/entry.component.spec.ts b/src/features/entry/entry.component.spec.ts
index 198c166cd..230e0df14 100644
--- a/src/features/entry/entry.component.spec.ts
+++ b/src/features/entry/entry.component.spec.ts
@@ -1,4 +1,6 @@
+import { CommonModule } from '@angular/common';
 import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { SAPIModule } from 'src/atlasComponents/sapi';
 
 import { EntryComponent } from './entry.component';
 
@@ -8,6 +10,10 @@ describe('EntryComponent', () => {
 
   beforeEach(async () => {
     await TestBed.configureTestingModule({
+      imports: [
+        SAPIModule,
+        CommonModule,
+      ],
       declarations: [ EntryComponent ]
     })
     .compileComponents();
diff --git a/src/features/feature-view/feature-view.component.spec.ts b/src/features/feature-view/feature-view.component.spec.ts
index 6606d5571..9ef81ec86 100644
--- a/src/features/feature-view/feature-view.component.spec.ts
+++ b/src/features/feature-view/feature-view.component.spec.ts
@@ -1,4 +1,8 @@
+import { CommonModule } from '@angular/common';
 import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { EMPTY } from 'rxjs';
+import { SAPIModule } from 'src/atlasComponents/sapi';
+import { DARKTHEME } from 'src/util/injectionTokens';
 
 import { FeatureViewComponent } from './feature-view.component';
 
@@ -8,7 +12,15 @@ describe('FeatureViewComponent', () => {
 
   beforeEach(async () => {
     await TestBed.configureTestingModule({
-      declarations: [ FeatureViewComponent ]
+      imports: [
+        SAPIModule,
+        CommonModule,
+      ],
+      declarations: [ FeatureViewComponent ],
+      providers: [{
+        provide: DARKTHEME,
+        useValue: EMPTY
+      }]
     })
     .compileComponents();
 
diff --git a/src/features/fetch.directive.spec.ts b/src/features/fetch.directive.spec.ts
deleted file mode 100644
index 5765d9f6e..000000000
--- a/src/features/fetch.directive.spec.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { FetchDirective } from './fetch.directive';
-
-describe('FetchDirective', () => {
-  it('should create an instance', () => {
-    const directive = new FetchDirective();
-    expect(directive).toBeTruthy();
-  });
-});
diff --git a/src/features/fetch.directive.ts b/src/features/fetch.directive.ts
deleted file mode 100644
index e481f1d36..000000000
--- a/src/features/fetch.directive.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import { Directive, Input, OnChanges, Output, SimpleChanges } from '@angular/core';
-import { BehaviorSubject } from 'rxjs';
-import { SAPI } from 'src/atlasComponents/sapi';
-import { SxplrParcellation, SxplrRegion, SxplrTemplate } from 'src/atlasComponents/sapi/sxplrTypes';
-import { Feature, CorticalFeature, VoiFeature, TabularFeature } from "src/atlasComponents/sapi/sxplrTypes"
-
-type FeatureMap = {
-  "RegionalConnectivity": Feature
-  "CorticalProfile": CorticalFeature<number>
-  "Tabular": TabularFeature<number|string|number[]>
-  "Image": VoiFeature
-}
-
-@Directive({
-  selector: '[sxplrFeatureFetch]',
-  exportAs: "sxplrFeatureFetch"
-})
-export class FetchDirective<T extends keyof FeatureMap> implements OnChanges {
-
-  /**
-   * TODO check if the decorated property survive on inheritence 
-   */
-
-  @Input()
-  template: SxplrTemplate
-
-  @Input()
-  parcellation: SxplrParcellation
-
-  @Input()
-  region: SxplrRegion
-
-  @Input()
-  featureType: T
-
-  @Output()
-  features: BehaviorSubject<FeatureMap[T][]> = new BehaviorSubject([])
-
-  @Output()
-  busy$: BehaviorSubject<boolean> = new BehaviorSubject(false)
-
-  constructor(
-    private sapi: SAPI
-  ) { }
-
-  async ngOnChanges(changes: SimpleChanges) {
-    if (!this.featureType) {
-      console.warn(`featureType must be defined!`)
-    }
-    this.busy$.next(true)
-    const features = await this.sapi.getV3Features(this.featureType, {
-      query: {
-        parcellation_id: this.parcellation?.id,
-        space_id: this.template?.id,
-        region_id: this.region?.name,
-      }
-    }).toPromise()
-    this.busy$.next(false)
-    this.features.next(features as any[])
-  }
-}
diff --git a/src/features/list/list.component.spec.ts b/src/features/list/list.component.spec.ts
index 54ae34808..dce8f1b84 100644
--- a/src/features/list/list.component.spec.ts
+++ b/src/features/list/list.component.spec.ts
@@ -1,4 +1,5 @@
 import { ComponentFixture, TestBed } from '@angular/core/testing';
+import { SAPIModule } from 'src/atlasComponents/sapi';
 
 import { ListComponent } from './list.component';
 
@@ -8,7 +9,10 @@ describe('ListComponent', () => {
 
   beforeEach(async () => {
     await TestBed.configureTestingModule({
-      declarations: [ ListComponent ]
+      imports: [
+        SAPIModule
+      ],
+      declarations: [ ListComponent ],
     })
     .compileComponents();
 
diff --git a/src/features/module.ts b/src/features/module.ts
index a2d380db3..ae034a2ea 100644
--- a/src/features/module.ts
+++ b/src/features/module.ts
@@ -9,7 +9,6 @@ import { SpinnerModule } from "src/components/spinner";
 import { UtilModule } from "src/util";
 import { EntryComponent } from './entry/entry.component'
 import { FeatureNamePipe } from "./featureName.pipe";
-import { FetchDirective } from "./fetch.directive";
 import { ListComponent } from './list/list.component';
 import { CategoryAccDirective } from './category-acc.directive';
 import { SapiViewsFeatureConnectivityModule } from "./connectivity";
@@ -49,7 +48,6 @@ import { ShowBBoxToggleDirective } from "./showBbox-toggle.directive";
     ListComponent,
     FeatureViewComponent,
 
-    FetchDirective,
     CategoryAccDirective,
     VoiBboxDirective,
     ShowBBoxToggleDirective,
diff --git a/src/routerModule/routeStateTransform.service.spec.ts b/src/routerModule/routeStateTransform.service.spec.ts
index 5be8c163f..9ee1c8453 100644
--- a/src/routerModule/routeStateTransform.service.spec.ts
+++ b/src/routerModule/routeStateTransform.service.spec.ts
@@ -105,7 +105,6 @@ describe("> routeStateTransform.service.ts", () => {
     describe("> cvtStateToRoute", () => {
 
       describe('> should be able encode region properly', () => {
-        let getRegionLabelIndexSpy: jasmine.Spy = jasmine.createSpy('getRegionLabelIndex')
         let getParcNgId: jasmine.Spy = jasmine.createSpy('getParcNgId')
         let atlasSelectionSpy: Record<string, jasmine.Spy> = {
           selectedAtlas: jasmine.createSpy('selectedAtlas'),
@@ -128,7 +127,6 @@ describe("> routeStateTransform.service.ts", () => {
         const navigation = null
 
         beforeEach(() => {
-          spyOnProperty(nehubaConfigService, 'getRegionLabelIndex').and.returnValue(getRegionLabelIndexSpy)
           spyOnProperty(nehubaConfigService, 'getParcNgId').and.returnValue(getParcNgId)
           spyOnProperty(atlasSelection, 'selectors').and.returnValue(atlasSelectionSpy)
           spyOnProperty(userInteraction, 'selectors').and.returnValue(userInteractionSpy)
@@ -144,7 +142,6 @@ describe("> routeStateTransform.service.ts", () => {
         })
 
         afterEach(() => {
-          getRegionLabelIndexSpy.calls.reset()
           getParcNgId.calls.reset()
           for (const spyRecord of [atlasSelectionSpy, userInteractionSpy]) {
             for (const key in spyRecord) {
@@ -155,7 +152,6 @@ describe("> routeStateTransform.service.ts", () => {
 
         it('> calls correct functions', async () => {
 
-          getRegionLabelIndexSpy.and.returnValue(11)
           getParcNgId.and.returnValue('foo-bar')
 
           const state = {}
@@ -171,7 +167,6 @@ describe("> routeStateTransform.service.ts", () => {
           const ngId = 'foobar'
           const labelIndex = 124
           
-          getRegionLabelIndexSpy.and.returnValue(labelIndex)
           getParcNgId.and.returnValue(ngId)
 
           const state = {}
@@ -181,17 +176,10 @@ describe("> routeStateTransform.service.ts", () => {
           expect(s).toContain(`r:${ngId}::${encodeNumber(labelIndex, { float: false })}`)
         })
   
-        it('> ngId containing ()', async () => {
-          const ngId = 'foobar(1)'
-          const labelIndex = 124
-
-          getRegionLabelIndexSpy.and.returnValue(labelIndex)
-          getParcNgId.and.returnValue(ngId)
-          
-          const state = {}
-          const svc = TestBed.inject(RouteStateTransformSvc)
-          const s = await svc.cvtStateToRoute(state as any)
-          expect(s).toContain(`r:foobar%25281%2529::${encodeNumber(labelIndex, { float: false })}`)
+        it('> ngId containing expected value', async () => {
+          /**
+           * TODO add new test
+           */
         })
       })
     })
diff --git a/src/state/atlasSelection/effects.spec.ts b/src/state/atlasSelection/effects.spec.ts
index 2c854293c..a1a820f67 100644
--- a/src/state/atlasSelection/effects.spec.ts
+++ b/src/state/atlasSelection/effects.spec.ts
@@ -4,7 +4,8 @@ import { Action } from "@ngrx/store"
 import { MockStore, provideMockStore } from "@ngrx/store/testing"
 import { hot } from "jasmine-marbles"
 import { Observable, of, throwError } from "rxjs"
-import { SAPI, SAPIModule, SapiRegionModel, SapiAtlasModel, SapiSpaceModel, SapiParcellationModel } from "src/atlasComponents/sapi"
+import { SAPI, SAPIModule } from "src/atlasComponents/sapi"
+import { SxplrRegion, SxplrAtlas, SxplrParcellation, SxplrTemplate } from "src/atlasComponents/sapi/sxplrTypes"
 import { IDS } from "src/atlasComponents/sapi/constants"
 import { actions, selectors } from "."
 import { Effect } from "./effects"
@@ -16,9 +17,9 @@ describe("> effects.ts", () => {
   describe("> Effect", () => {
 
     let actions$ = new Observable<Action>()
-    let hoc1left: SapiRegionModel
-    let hoc1leftCentroid: SapiRegionModel
-    let hoc1leftCentroidWrongSpc: SapiRegionModel
+    let hoc1left: SxplrRegion
+    let hoc1leftCentroid: SxplrRegion
+    let hoc1leftCentroidWrongSpc: SxplrRegion
 
     beforeEach(async () => {
       TestBed.configureTestingModule({
@@ -40,24 +41,18 @@ describe("> effects.ts", () => {
       if (!hoc1left) {
 
         const sapisvc = TestBed.inject(SAPI)
-        const regions = await sapisvc.getParcRegions(IDS.ATLAES.HUMAN, IDS.PARCELLATION.JBA29, IDS.TEMPLATES.MNI152).toPromise()
+        const regions = await sapisvc.getParcRegions(IDS.PARCELLATION.JBA29).toPromise()
         hoc1left = regions.find(r => /hoc1/i.test(r.name) && /left/i.test(r.name))
         if (!hoc1left) throw new Error(`cannot find hoc1 left`)
         hoc1leftCentroid = JSON.parse(JSON.stringify(hoc1left)) 
-        hoc1leftCentroid.hasAnnotation.bestViewPoint = {
-          coordinateSpace: {
-            '@id': IDS.TEMPLATES.BIG_BRAIN
-          },
-          coordinates: [{
-            value: 1
-          }, {
-            value: 2
-          }, {
-            value: 3
-          }]
+        hoc1leftCentroid.centroid = {
+          space: {
+            id: IDS.TEMPLATES.BIG_BRAIN
+          } as SxplrTemplate,
+          loc: [1, 2, 3]
         }
         hoc1leftCentroidWrongSpc = JSON.parse(JSON.stringify(hoc1leftCentroid))
-        hoc1leftCentroidWrongSpc.hasAnnotation.bestViewPoint.coordinateSpace['@id'] = IDS.TEMPLATES.COLIN27
+        hoc1leftCentroidWrongSpc.centroid.space.id = IDS.TEMPLATES.COLIN27
       }
     })
 
@@ -242,14 +237,14 @@ describe("> effects.ts", () => {
         })
         const mockStore = TestBed.inject(MockStore)
         mockStore.overrideSelector(selectors.selectedAtlas, {
-          "@id": IDS.ATLAES.HUMAN
-        } as SapiAtlasModel)
+          id: IDS.ATLAES.HUMAN
+        } as SxplrAtlas)
         mockStore.overrideSelector(selectors.selectedTemplate, {
-          "@id": IDS.TEMPLATES.MNI152
-        } as SapiSpaceModel)
+          id: IDS.TEMPLATES.MNI152
+        } as SxplrTemplate)
         mockStore.overrideSelector(selectors.selectedParcellation, {
-          "@id": IDS.PARCELLATION.JBA29
-        } as SapiParcellationModel)
+          id: IDS.PARCELLATION.JBA29
+        } as SxplrParcellation)
       })
 
       describe('> if atlas, template, parc is not set', () => {
@@ -307,20 +302,14 @@ describe("> effects.ts", () => {
       })
 
       describe('> if inputs are fine', () => {
-        let getRegionSpy: jasmine.Spy
         let regionGetDetailSpy: jasmine.Spy = jasmine.createSpy()
         beforeEach(() => {
           const sapi = TestBed.inject(SAPI)
-          getRegionSpy = spyOn(sapi, 'getRegion')
-          getRegionSpy.and.returnValue({
-            getDetail: regionGetDetailSpy
-          })
           regionGetDetailSpy.and.returnValue(
             of(hoc1leftCentroid)
           )
         })
         afterEach(() => {
-          if (getRegionSpy) getRegionSpy.calls.reset()
           if (regionGetDetailSpy) regionGetDetailSpy.calls.reset()
         })
         it('> getRegionDetailSpy is called, and calls navigateTo', () => {
@@ -335,8 +324,6 @@ describe("> effects.ts", () => {
               })
             })
           )
-          expect(getRegionSpy).toHaveBeenCalledTimes(1)
-          expect(getRegionSpy).toHaveBeenCalledWith(IDS.ATLAES.HUMAN, IDS.PARCELLATION.JBA29, hoc1left["@id"])
         })
 
         describe('> mal formed return', () => {
diff --git a/src/viewerModule/nehuba/layerCtrl.service/layerCtrl.service.spec.ts b/src/viewerModule/nehuba/layerCtrl.service/layerCtrl.service.spec.ts
index 23ad93def..45a5aee2d 100644
--- a/src/viewerModule/nehuba/layerCtrl.service/layerCtrl.service.spec.ts
+++ b/src/viewerModule/nehuba/layerCtrl.service/layerCtrl.service.spec.ts
@@ -14,8 +14,6 @@ import { RouterService } from "src/routerModule/router.service"
 describe('> layerctrl.service.ts', () => {
   describe('> NehubaLayerControlService', () => {
     let mockStore: MockStore
-    let getMultiNgIdsRegionsLabelIndexMapSpy: jasmine.Spy
-    let getMultiNgIdsRegionsLabelIndexMapReturnVal: Map<string, Map<number, layerCtrlUtil.IRegion>>
     beforeEach(() => {
       TestBed.configureTestingModule({
         providers: [
@@ -37,11 +35,6 @@ describe('> layerctrl.service.ts', () => {
       })
 
       mockStore = TestBed.inject(MockStore)
-      getMultiNgIdsRegionsLabelIndexMapReturnVal = new Map()
-      getMultiNgIdsRegionsLabelIndexMapSpy = spyOnProperty(
-        layerCtrlUtil,
-        'getMultiNgIdsRegionsLabelIndexMap'
-      ).and.returnValue(() => getMultiNgIdsRegionsLabelIndexMapReturnVal)
       mockStore.overrideSelector(atlasAppearance.selectors.customLayers, [])
       mockStore.overrideSelector(atlasAppearance.selectors.showDelineation, true)
       mockStore.overrideSelector(annotation.selectors.annotations, [])
diff --git a/src/viewerModule/nehuba/mesh.service/mesh.service.spec.ts b/src/viewerModule/nehuba/mesh.service/mesh.service.spec.ts
index ef3ac5332..0b7d70236 100644
--- a/src/viewerModule/nehuba/mesh.service/mesh.service.spec.ts
+++ b/src/viewerModule/nehuba/mesh.service/mesh.service.spec.ts
@@ -3,7 +3,7 @@ import { MockStore, provideMockStore } from "@ngrx/store/testing"
 import { hot } from "jasmine-marbles"
 import { NehubaMeshService } from "./mesh.service"
 import { atlasSelection } from "src/state"
-import { SapiRegionModel } from "src/atlasComponents/sapi"
+import { SxplrRegion } from "src/atlasComponents/sapi/sxplrTypes"
 import * as configSvc from "../config.service"
 import { LayerCtrlEffects } from "../layerCtrl.service/layerCtrl.effects"
 import { NEVER, of, pipe } from "rxjs"
@@ -11,7 +11,7 @@ import { mapTo, take } from "rxjs/operators"
 import { selectorAuxMeshes } from "../store"
 
 
-const fits1 = {} as SapiRegionModel
+const fits1 = {} as SxplrRegion
 const auxMesh = {
   "@id": 'bla',
   labelIndicies: [1,2,3],
@@ -24,7 +24,7 @@ const auxMesh = {
 
 describe('> mesh.service.ts', () => {
   let getParcNgIdSpy: jasmine.Spy = jasmine.createSpy('getParcNgId')
-  let getRegionLabelIndexSpy: jasmine.Spy = jasmine.createSpy('getRegionLabelIndexSpy')
+  
   let getATPSpy: jasmine.Spy = jasmine.createSpy('distinctATP')
 
   const mockAtlas = {
@@ -39,7 +39,6 @@ describe('> mesh.service.ts', () => {
 
   beforeEach(() => {
     spyOnProperty(configSvc, 'getParcNgId').and.returnValue(getParcNgIdSpy)
-    spyOnProperty(configSvc, 'getRegionLabelIndex').and.returnValue(getRegionLabelIndexSpy)
     getATPSpy = spyOn(atlasSelection.fromRootStore, 'distinctATP')
     getATPSpy.and.returnValue(
       pipe(
@@ -54,7 +53,7 @@ describe('> mesh.service.ts', () => {
 
   afterEach(() => {
     getParcNgIdSpy.calls.reset()
-    getRegionLabelIndexSpy.calls.reset()
+    
     getATPSpy.calls.reset()
   })
   describe('> NehubaMeshService', () => {
@@ -93,7 +92,6 @@ describe('> mesh.service.ts', () => {
           mockStore.overrideSelector(selectorAuxMeshes, [auxMesh])
     
           getParcNgIdSpy.and.returnValue(ngId)
-          getRegionLabelIndexSpy.and.returnValue(labelIndex)
 
         })
 
@@ -137,7 +135,6 @@ describe('> mesh.service.ts', () => {
           mockStore.overrideSelector(selectorAuxMeshes, [])
     
           getParcNgIdSpy.and.returnValues(ngId1, ngId2, ngId2)
-          getRegionLabelIndexSpy.and.returnValues(labelIndex1, labelIndex2, labelIndex2)
         })
 
         it('> should call getParcNgIdSpy and getRegionLabelIndexSpy thrice', () => {
@@ -147,7 +144,6 @@ describe('> mesh.service.ts', () => {
           ).subscribe(() => {
 
             expect(getParcNgIdSpy).toHaveBeenCalledTimes(3)
-            expect(getRegionLabelIndexSpy).toHaveBeenCalledTimes(3)
           })
         })
 
diff --git a/src/viewerModule/nehuba/navigation.service/navigation.util.spec.ts b/src/viewerModule/nehuba/navigation.service/navigation.util.spec.ts
index 8cd54f174..4e967e38b 100644
--- a/src/viewerModule/nehuba/navigation.service/navigation.util.spec.ts
+++ b/src/viewerModule/nehuba/navigation.service/navigation.util.spec.ts
@@ -2,8 +2,8 @@ import {
   navAdd,
   navMul,
   navObjEqual,
-  INavObj
 } from './navigation.util'
+import { INavObj } from "../constants"
 
 const nav1: INavObj = {
   position: [1,2,3],
diff --git a/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.spec.ts b/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.spec.ts
index 703da4322..10d189784 100644
--- a/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.spec.ts
+++ b/src/viewerModule/nehuba/nehubaViewerGlue/nehubaViewerGlue.component.spec.ts
@@ -18,7 +18,8 @@ import { selectorAuxMeshes } from "../store"
 import { NehubaGlueCmp } from "./nehubaViewerGlue.component"
 import { AtlasWorkerService } from "src/atlasViewer/atlasViewer.workerService.service"
 import { userInterface, atlasSelection, atlasAppearance, annotation, userInteraction } from "src/state"
-import { SapiAtlasModel, SAPIModule, SapiParcellationModel, SapiRegionModel, SapiSpaceModel } from "src/atlasComponents/sapi"
+import { SAPIModule } from "src/atlasComponents/sapi"
+import { SxplrParcellation, SxplrAtlas, SxplrRegion, SxplrTemplate } from "src/atlasComponents/sapi/sxplrTypes"
 import { LayerCtrlEffects } from "../layerCtrl.service/layerCtrl.effects"
 import { NEHUBA_INSTANCE_INJTKN } from "../util"
 import { RouterService } from "src/routerModule/router.service"
@@ -51,10 +52,10 @@ describe('> nehubaViewerGlue.component.ts', () => {
   let mockStore: MockStore
   let fixture: ComponentFixture<NehubaGlueCmp>
   const selectedATPR$ = new Subject<{
-    atlas: SapiAtlasModel,
-    parcellation: SapiParcellationModel,
-    template: SapiSpaceModel,
-    regions: SapiRegionModel[],
+    atlas: SxplrAtlas,
+    parcellation: SxplrParcellation,
+    template: SxplrTemplate,
+    regions: SxplrRegion[],
   }>()
   beforeEach( async () => {
     await TestBed.configureTestingModule({
diff --git a/src/viewerModule/nehuba/statusCard/statusCard.component.spec.ts b/src/viewerModule/nehuba/statusCard/statusCard.component.spec.ts
index ab6ac5111..cb1521df9 100644
--- a/src/viewerModule/nehuba/statusCard/statusCard.component.spec.ts
+++ b/src/viewerModule/nehuba/statusCard/statusCard.component.spec.ts
@@ -15,7 +15,7 @@ import { UtilModule } from "src/util"
 import * as configSvc from '../config.service'
 import {QuickTourModule} from "src/ui/quickTour/module";
 import { atlasSelection } from "src/state"
-import { SapiSpaceModel } from "src/atlasComponents/sapi"
+import { SxplrTemplate } from "src/atlasComponents/sapi/sxplrTypes"
 
 @Directive({
   selector: '[iav-auth-auth-state]',
@@ -70,8 +70,9 @@ describe('> statusCard.component.ts', () => {
       const mockStore = TestBed.inject(MockStore)
 
       mockStore.overrideSelector(atlasSelection.selectors.selectedTemplate, {
-        '@id': 'minds/core/referencespace/v1.0.0/a1655b99-82f1-420f-a3c2-fe80fd4c8588'
-      } as SapiSpaceModel)
+        id: 'minds/core/referencespace/v1.0.0/a1655b99-82f1-420f-a3c2-fe80fd4c8588',
+        name: 'foo'
+      } as SxplrTemplate)
 
     })
 
-- 
GitLab