File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed
Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,11 @@ const cloudManagerHOC = function (WrappedComponent) {
101101 handleExtensionAdded ( categoryInfo ) {
102102 // Note that props.vm.extensionManager.isExtensionLoaded('videoSensing') is still false
103103 // at the point of this callback, so it is difficult to reuse the canModifyCloudData logic.
104- if ( categoryInfo . id === 'videoSensing' && this . isConnected ( ) ) {
104+ if (
105+ ( categoryInfo . id === 'videoSensing' ||
106+ categoryInfo . id === 'faceSensing' ) &&
107+ this . isConnected ( )
108+ ) {
105109 this . disconnectFromCloud ( ) ;
106110 }
107111 }
@@ -157,9 +161,18 @@ const cloudManagerHOC = function (WrappedComponent) {
157161 isShowingWithId : getIsShowingWithId ( loadingState ) ,
158162 projectId : state . scratchGui . projectState . projectId ,
159163 // if you're editing someone else's project, you can't modify cloud data
160- canModifyCloudData : ( ! state . scratchGui . mode . hasEverEnteredEditor || ownProps . canSave ) &&
164+ canModifyCloudData :
165+ ( ! state . scratchGui . mode . hasEverEnteredEditor ||
166+ ownProps . canSave ) &&
161167 // possible security concern if the program attempts to encode webcam data over cloud variables
162- ! ownProps . vm . extensionManager . isExtensionLoaded ( 'videoSensing' )
168+ ! (
169+ ownProps . vm . extensionManager . isExtensionLoaded (
170+ 'videoSensing'
171+ ) ||
172+ ownProps . vm . extensionManager . isExtensionLoaded (
173+ 'faceSensing'
174+ )
175+ )
163176 } ;
164177 } ;
165178
Original file line number Diff line number Diff line change @@ -162,6 +162,25 @@ describe('CloudManagerHOC', () => {
162162 expect ( CloudProvider ) . not . toHaveBeenCalled ( ) ;
163163 } ) ;
164164
165+ test ( 'when faceSensing extension is active, the cloud provider is not set on the vm' , ( ) => {
166+ const Component = ( ) => < div /> ;
167+ const WrappedComponent = cloudManagerHOC ( Component ) ;
168+ vm . extensionManager . isExtensionLoaded = jest . fn ( extension => extension === 'faceSensing' ) ;
169+
170+ mount (
171+ < WrappedComponent
172+ hasCloudPermission
173+ cloudHost = "nonEmpty"
174+ store = { store }
175+ username = "user"
176+ vm = { vm }
177+ />
178+ ) ;
179+
180+ expect ( vm . setCloudProvider . mock . calls . length ) . toBe ( 0 ) ;
181+ expect ( CloudProvider ) . not . toHaveBeenCalled ( ) ;
182+ } ) ;
183+
165184 test ( 'if the isShowingWithId prop becomes true, it sets the cloud provider on the vm' , ( ) => {
166185 const Component = ( ) => < div /> ;
167186 const WrappedComponent = cloudManagerHOC ( Component ) ;
You can’t perform that action at this time.
0 commit comments