@@ -170,7 +170,7 @@ describe('SanityApp', () => {
170
170
171
171
it ( 'redirects to core if not inside iframe and not local url' , async ( ) => {
172
172
const originalLocation = window . location
173
- const consoleLogSpy = vi . spyOn ( console , 'log ' ) . mockImplementation ( ( ) => { } )
173
+ const consoleWarnSpy = vi . spyOn ( console , 'warn ' ) . mockImplementation ( ( ) => { } )
174
174
175
175
const mockLocation = {
176
176
replace : vi . fn ( ) ,
@@ -204,7 +204,7 @@ describe('SanityApp', () => {
204
204
value : originalLocation ,
205
205
writable : true ,
206
206
} )
207
- consoleLogSpy . mockRestore ( )
207
+ consoleWarnSpy . mockRestore ( )
208
208
} )
209
209
210
210
it ( 'does not redirect to core if not inside iframe and local url' , async ( ) => {
@@ -243,4 +243,44 @@ describe('SanityApp', () => {
243
243
writable : true ,
244
244
} )
245
245
} )
246
+
247
+ it ( 'does not redirect to core if studioMode is enabled' , async ( ) => {
248
+ const originalLocation = window . location
249
+ const consoleWarnSpy = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } )
250
+
251
+ const mockLocation = {
252
+ replace : vi . fn ( ) ,
253
+ href : 'http://sanity-test.app' ,
254
+ }
255
+
256
+ const mockSanityConfig : SanityConfig = {
257
+ projectId : 'test-project' ,
258
+ dataset : 'test-dataset' ,
259
+ studioMode : { enabled : true } ,
260
+ }
261
+
262
+ Object . defineProperty ( window , 'location' , {
263
+ value : mockLocation ,
264
+ writable : true ,
265
+ } )
266
+
267
+ render (
268
+ < SanityApp config = { [ mockSanityConfig ] } fallback = { < div > Fallback</ div > } >
269
+ < div > Test Child</ div >
270
+ </ SanityApp > ,
271
+ )
272
+
273
+ // Wait for 1 second
274
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1010 ) )
275
+
276
+ // Add assertions based on your iframe-specific behavior
277
+ expect ( mockLocation . replace ) . not . toHaveBeenCalled ( )
278
+
279
+ // Clean up the mock
280
+ Object . defineProperty ( window , 'location' , {
281
+ value : originalLocation ,
282
+ writable : true ,
283
+ } )
284
+ consoleWarnSpy . mockRestore ( )
285
+ } )
246
286
} )
0 commit comments