@@ -1683,6 +1683,85 @@ use_legacy_install_flow = true
16831683[auth]
16841684redirect_urls = [ "https://example.com/callback1" ]
16851685
1686+ [webhooks]
1687+ api_version = "2023-07"
1688+
1689+ [[webhooks.subscriptions]]
1690+ topics = [ "products/create" ]
1691+ uri = "https://my-app.com/webhooks"
1692+
1693+ [pos]
1694+ embedded = false
1695+ `
1696+ expect ( content ) . toEqual ( expectedContent )
1697+ } )
1698+ } )
1699+
1700+ test ( 'existing config is respected when isNewApp is true, config is current and client_id is not the same as remote app and config name is provided' , async ( ) => {
1701+ await inTemporaryDirectory ( async ( tmp ) => {
1702+ // Given
1703+ const developerPlatformClient = buildDeveloperPlatformClient ( )
1704+ const options : LinkOptions = {
1705+ directory : tmp ,
1706+ developerPlatformClient,
1707+ isNewApp : true ,
1708+ configName : 'staging' ,
1709+ }
1710+ const localApp = {
1711+ configuration : {
1712+ path : joinPath ( tmp , 'shopify.app.staging.toml' ) ,
1713+ name : 'my app' ,
1714+ client_id : 'invalid_client_id_from_template' ,
1715+ webhooks : {
1716+ api_version : '2023-04' ,
1717+ subscriptions : [ { topics : [ 'products/create' ] , uri : 'https://my-app.com/webhooks' } ] ,
1718+ } ,
1719+ application_url : 'https://myapp.com' ,
1720+ build : {
1721+ automatically_update_urls_on_dev : true ,
1722+ dev_store_url : 'my-store.myshopify.com' ,
1723+ include_config_on_deploy : true ,
1724+ } ,
1725+ access_scopes : {
1726+ scopes : 'write_products' ,
1727+ } ,
1728+ } as CurrentAppConfiguration ,
1729+ }
1730+
1731+ vi . mocked ( loadApp ) . mockResolvedValue ( await mockApp ( tmp , localApp , [ ] , 'current' ) )
1732+ vi . mocked ( fetchOrCreateOrganizationApp ) . mockResolvedValue ( mockRemoteApp ( { developerPlatformClient} ) )
1733+ const remoteConfiguration = {
1734+ ...DEFAULT_REMOTE_CONFIGURATION ,
1735+ handle : 'handle' ,
1736+ }
1737+ vi . mocked ( fetchAppRemoteConfiguration ) . mockResolvedValue ( remoteConfiguration )
1738+
1739+ // When
1740+ await link ( options )
1741+
1742+ // Then
1743+ const content = await readFile ( joinPath ( tmp , 'shopify.app.staging.toml' ) )
1744+ const expectedContent = `# Learn more about configuring your app at https://shopify.dev/docs/apps/tools/cli/configuration
1745+
1746+ client_id = "12345"
1747+ name = "app1"
1748+ handle = "handle"
1749+ application_url = "https://example.com"
1750+ embedded = true
1751+
1752+ [build]
1753+ automatically_update_urls_on_dev = true
1754+ dev_store_url = "my-store.myshopify.com"
1755+ include_config_on_deploy = true
1756+
1757+ [access_scopes]
1758+ # Learn more at https://shopify.dev/docs/apps/tools/cli/configuration#access_scopes
1759+ scopes = "write_products"
1760+ use_legacy_install_flow = true
1761+
1762+ [auth]
1763+ redirect_urls = [ "https://example.com/callback1" ]
1764+
16861765[webhooks]
16871766api_version = "2023-07"
16881767
0 commit comments