@@ -359,6 +359,118 @@ Learn more: https://shopify.dev/docs/apps/build/authentication-authorization/app
359359 // When/Then
360360 await expect ( app . preDeployValidation ( ) ) . resolves . not . toThrow ( )
361361 } )
362+
363+ test ( 'does not throw an error when only compliance webhooks are used with legacy install flow' , async ( ) => {
364+ // Given
365+ const configuration : CurrentAppConfiguration = {
366+ ...DEFAULT_CONFIG ,
367+ access_scopes : {
368+ scopes : 'read_orders' ,
369+ use_legacy_install_flow : true ,
370+ } ,
371+ webhooks : {
372+ api_version : '2024-07' ,
373+ subscriptions : [
374+ {
375+ compliance_topics : [ 'customers/data_request' , 'customers/redact' , 'shop/redact' ] ,
376+ uri : '/webhooks' ,
377+ } ,
378+ ] ,
379+ } ,
380+ }
381+ const app = testApp ( { configuration} )
382+
383+ // When/Then
384+ await expect ( app . preDeployValidation ( ) ) . resolves . not . toThrow ( )
385+ } )
386+
387+ test ( 'throws an error when both app-specific and compliance webhooks are used with legacy install flow' , async ( ) => {
388+ // Given
389+ const configuration : CurrentAppConfiguration = {
390+ ...DEFAULT_CONFIG ,
391+ access_scopes : {
392+ scopes : 'read_orders' ,
393+ use_legacy_install_flow : true ,
394+ } ,
395+ webhooks : {
396+ api_version : '2024-07' ,
397+ subscriptions : [
398+ {
399+ topics : [ 'orders/create' ] ,
400+ uri : '/webhooks/orders' ,
401+ } ,
402+ {
403+ compliance_topics : [ 'customers/redact' ] ,
404+ uri : '/webhooks/compliance' ,
405+ } ,
406+ ] ,
407+ } ,
408+ }
409+ const app = testApp ( { configuration} )
410+
411+ // When/Then
412+ await expect ( app . preDeployValidation ( ) ) . rejects . toThrow (
413+ new AbortError (
414+ 'App-specific webhook subscriptions are not supported when use_legacy_install_flow is enabled.' ,
415+ `To use app-specific webhooks, you need to:
416+ 1. Remove 'use_legacy_install_flow = true' from your configuration
417+ 2. Run 'shopify app deploy' to sync your scopes with the Partner Dashboard
418+
419+ Alternatively, continue using shop-specific webhooks with the legacy install flow.
420+
421+ Learn more: https://shopify.dev/docs/apps/build/authentication-authorization/app-installation` ,
422+ ) ,
423+ )
424+ } )
425+
426+ test ( 'does not throw an error for subscription with empty topics array and legacy install flow' , async ( ) => {
427+ // Given
428+ const configuration : CurrentAppConfiguration = {
429+ ...DEFAULT_CONFIG ,
430+ access_scopes : {
431+ scopes : 'read_orders' ,
432+ use_legacy_install_flow : true ,
433+ } ,
434+ webhooks : {
435+ api_version : '2024-07' ,
436+ subscriptions : [
437+ {
438+ topics : [ ] ,
439+ uri : '/webhooks' ,
440+ } ,
441+ ] ,
442+ } ,
443+ }
444+ const app = testApp ( { configuration} )
445+
446+ // When/Then
447+ await expect ( app . preDeployValidation ( ) ) . resolves . not . toThrow ( )
448+ } )
449+
450+ test ( 'does not throw an error for subscription with only compliance_topics and no topics field' , async ( ) => {
451+ // Given
452+ const configuration : CurrentAppConfiguration = {
453+ ...DEFAULT_CONFIG ,
454+ access_scopes : {
455+ scopes : 'read_orders' ,
456+ use_legacy_install_flow : true ,
457+ } ,
458+ webhooks : {
459+ api_version : '2024-07' ,
460+ subscriptions : [
461+ {
462+ // Only compliance_topics, no topics field at all
463+ compliance_topics : [ 'customers/data_request' ] ,
464+ uri : '/webhooks/gdpr' ,
465+ } ,
466+ ] ,
467+ } ,
468+ }
469+ const app = testApp ( { configuration} )
470+
471+ // When/Then
472+ await expect ( app . preDeployValidation ( ) ) . resolves . not . toThrow ( )
473+ } )
362474} )
363475
364476describe ( 'validateFunctionExtensionsWithUiHandle' , ( ) => {
0 commit comments