From 6e5b6e119e1672c149294380bffbf4bcdbff5fd0 Mon Sep 17 00:00:00 2001 From: Xiao Gui <xgui3783@gmail.com> Date: Mon, 26 Oct 2020 17:12:11 +0100 Subject: [PATCH] chore: allow only 1 region to be selected --- e2e/src/selecting/region.prod.e2e-spec.js | 39 +++++++++++++++++++++++ src/atlasViewer/atlasViewer.component.ts | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 e2e/src/selecting/region.prod.e2e-spec.js diff --git a/e2e/src/selecting/region.prod.e2e-spec.js b/e2e/src/selecting/region.prod.e2e-spec.js new file mode 100644 index 000000000..14a10f94c --- /dev/null +++ b/e2e/src/selecting/region.prod.e2e-spec.js @@ -0,0 +1,39 @@ +const { AtlasPage } = require('../../src/util') +const { height, width } = require('../../opts') + +describe('> selecting regions', () => { + + const duplicatedRegion = { + atlas: 'Multilevel Human Atlas', + template: `ICBM 152 2009c Nonlinear Asymmetric`, + position: [-0.256, 26.028, -11.678] + } + describe(`> when selecting duplicated regions at ${duplicatedRegion.atlas} / ${duplicatedRegion.template} / ${JSON.stringify(duplicatedRegion.position)}`, () => { + it(`> when click, should only select a single region`, async () => { + const newPage = new AtlasPage() + await newPage.init() + await newPage.goto() + await newPage.selectAtlasTemplateParcellation(duplicatedRegion.atlas, duplicatedRegion.template) + await newPage.wait(500) + await newPage.waitForAsync() + await newPage.execScript(`interactiveViewer.viewerHandle.setNavigationLoc(${JSON.stringify(duplicatedRegion.position.map(v => v*1e6))}, true)`) + await newPage.wait(500) + await newPage.cursorMoveTo({ + position: [ width * 3 / 4, height / 4 ] + }) + await newPage.wait(500) + const txt = await newPage.getText(`[floatingMouseContextualContainerDirective]`) + expect(txt.indexOf(`left`)).toBeGreaterThanOrEqual(0) + expect(txt.indexOf(`right`)).toBeGreaterThanOrEqual(0) + + await newPage.cursorMoveToAndClick({ + position: [width * 3 / 4, height / 4] + }) + await newPage.wait(500) + await newPage.waitForAsync() + const visible = await newPage.areVisible(`region-menu`) + expect(visible.length).toEqual(1) + + }) + }) +}) diff --git a/src/atlasViewer/atlasViewer.component.ts b/src/atlasViewer/atlasViewer.component.ts index 1f656a997..2cb42747e 100644 --- a/src/atlasViewer/atlasViewer.component.ts +++ b/src/atlasViewer/atlasViewer.component.ts @@ -435,7 +435,7 @@ export class AtlasViewer implements OnDestroy, OnInit, AfterViewInit { if (!this.onhoverSegments) return this.store.dispatch( viewerStateSetSelectedRegions({ - selectRegions: this.onhoverSegments + selectRegions: this.onhoverSegments.slice(0, 1) }) ) } -- GitLab