From 6ccbb5552dab49d8146e92e2933900eed2654d13 Mon Sep 17 00:00:00 2001 From: Jack Chen Date: Tue, 22 Sep 2020 10:29:57 -0700 Subject: [PATCH] fix(discoverability): set mode to REGION instead of NONE (#1260) * fix(discoverability): set mode to REGION instead of NONE * feat(discoverability): revert initial changes * feat(discoverability): call toggleAnnotationMode in handleFullscreenExit * feat(discoverability): use parameterized test * feat(discoverability): simplify logic Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- src/lib/viewers/BaseViewer.js | 3 +++ src/lib/viewers/__tests__/BaseViewer-test.js | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/lib/viewers/BaseViewer.js b/src/lib/viewers/BaseViewer.js index f5271817a..00b5e6bf7 100644 --- a/src/lib/viewers/BaseViewer.js +++ b/src/lib/viewers/BaseViewer.js @@ -587,6 +587,9 @@ class BaseViewer extends EventEmitter { if (this.annotator && this.areNewAnnotationsEnabled()) { this.annotator.emit(ANNOTATOR_EVENT.setVisibility, true); + if (this.options.enableAnnotationsDiscoverability) { + this.annotator.toggleAnnotationMode(AnnotationMode.REGION); + } this.enableAnnotationControls(); } } diff --git a/src/lib/viewers/__tests__/BaseViewer-test.js b/src/lib/viewers/__tests__/BaseViewer-test.js index 536ecd163..ab8faddda 100644 --- a/src/lib/viewers/__tests__/BaseViewer-test.js +++ b/src/lib/viewers/__tests__/BaseViewer-test.js @@ -583,6 +583,25 @@ describe('lib/viewers/BaseViewer', () => { expect(base.annotator.emit).to.be.calledWith(ANNOTATOR_EVENT.setVisibility, true); expect(base.enableAnnotationControls).to.be.called; }); + + it(`should show annotations and toggle annotations mode to REGION if enableAnnotationsDiscoverability is true`, () => { + sandbox.stub(base, 'areNewAnnotationsEnabled').returns(true); + sandbox.stub(base, 'enableAnnotationControls'); + base.annotator = { + emit: sandbox.mock(), + toggleAnnotationMode: sandbox.mock(), + }; + base.annotationControls = { + destroy: sandbox.mock(), + }; + base.options.enableAnnotationsDiscoverability = true; + + base.handleFullscreenExit(); + + expect(base.annotator.emit).to.be.calledWith(ANNOTATOR_EVENT.setVisibility, true); + expect(base.enableAnnotationControls).to.be.called; + expect(base.annotator.toggleAnnotationMode).to.be.calledWith(AnnotationMode.REGION); + }); }); describe('resize()', () => {