@@ -67,6 +67,63 @@ describe('addUidToTomlsIfNecessary', () => {
6767 } )
6868 } )
6969
70+ test ( 'adds uid inside the [[extensions]] block for a single-entry array TOML (matching the app init template shape)' , async ( ) => {
71+ await inTemporaryDirectory ( async ( tmpDir ) => {
72+ // Given — a TOML using the modern `[[extensions]]` array-of-tables shape with a
73+ // single extension. This is the shape produced by `shopify app init` templates.
74+ const tomlPath = joinPath ( tmpDir , 'shopify.extension.toml' )
75+ const tomlContent = `api_version = "2026-07"
76+
77+ [[extensions]]
78+ # Change the merchant-facing name of the extension in locales/en.default.json
79+ name = "t:name"
80+ handle = "app-home"
81+ type = "ui_extension"
82+
83+ [[extensions.targeting]]
84+ module = "./src/AppHome.jsx"
85+ target = "admin.app.home.render"
86+
87+ [access_scopes]
88+ scopes = "write_metaobject_definitions,write_metaobjects,write_products"
89+ `
90+ await writeFile ( tomlPath , tomlContent )
91+
92+ const extension = {
93+ configurationPath : tomlPath ,
94+ handle : 'app-home' ,
95+ isUUIDStrategyExtension : true ,
96+ uid : 'abc-123' ,
97+ configuration : { } ,
98+ } as ExtensionInstance
99+
100+ const client = testDeveloperPlatformClient ( { supportsAtomicDeployments : true } )
101+
102+ // When
103+ await addUidToTomlsIfNecessary ( [ extension ] , client )
104+
105+ // Then — uid must be inside the [[extensions]] block (right after handle), not at
106+ // the top level of the file.
107+ const updatedContent = await readFile ( tomlPath )
108+ expect ( updatedContent ) . toBe ( `api_version = "2026-07"
109+
110+ [[extensions]]
111+ # Change the merchant-facing name of the extension in locales/en.default.json
112+ name = "t:name"
113+ handle = "app-home"
114+ uid = "abc-123"
115+ type = "ui_extension"
116+
117+ [[extensions.targeting]]
118+ module = "./src/AppHome.jsx"
119+ target = "admin.app.home.render"
120+
121+ [access_scopes]
122+ scopes = "write_metaobject_definitions,write_metaobjects,write_products"
123+ ` )
124+ } )
125+ } )
126+
70127 test ( 'adds uid to multi-extension TOML' , async ( ) => {
71128 await inTemporaryDirectory ( async ( tmpDir ) => {
72129 // Given
0 commit comments