@@ -4,12 +4,9 @@ import {
44 unsetAppConfigValue ,
55 setManyAppConfigValues ,
66} from './patch-app-configuration-file.js'
7- import { getAppVersionedSchema } from '../../models/app/app.js'
8- import { loadLocalExtensionsSpecifications } from '../../models/extensions/load-specifications.js'
9- import { environmentVariableNames } from '../../constants.js'
107import { readFile , writeFileSync , inTemporaryDirectory } from '@shopify/cli-kit/node/fs'
118import { joinPath } from '@shopify/cli-kit/node/path'
12- import { afterEach , beforeEach , describe , expect , test , vi } from 'vitest'
9+ import { describe , expect , test } from 'vitest'
1310
1411const defaultToml = `# Learn more about configuring your app at https://shopify.dev/docs/apps/tools/cli/configuration
1512client_id = "12345"
@@ -31,8 +28,6 @@ redirect_urls = [
3128api_version = "2023-04"
3229`
3330
34- const schema = getAppVersionedSchema ( await loadLocalExtensionsSpecifications ( ) , false )
35-
3631function writeDefaulToml ( tmpDir : string ) {
3732 const configPath = joinPath ( tmpDir , 'shopify.app.toml' )
3833 writeFileSync ( configPath , defaultToml )
@@ -120,20 +115,12 @@ describe('patchAppHiddenConfigFile', () => {
120115 } )
121116} )
122117
123- describe . each ( [ false , true ] ) ( 'setAppConfigValue (disableWasmTomlPatch: %s)' , ( disableWasmTomlPatch ) => {
124- beforeEach ( ( ) => {
125- vi . stubEnv ( environmentVariableNames . disableWasmTomlPatch , disableWasmTomlPatch . toString ( ) )
126- } )
127-
128- afterEach ( ( ) => {
129- vi . unstubAllEnvs ( )
130- } )
131-
118+ describe ( 'setAppConfigValue' , ( ) => {
132119 test ( 'sets a top-level value in the configuration' , async ( ) => {
133120 await inTemporaryDirectory ( async ( tmpDir ) => {
134121 const configPath = writeDefaulToml ( tmpDir )
135122
136- await setAppConfigValue ( configPath , 'name' , 'Updated App Name' , schema )
123+ await setAppConfigValue ( configPath , 'name' , 'Updated App Name' )
137124
138125 const updatedTomlFile = await readFile ( configPath )
139126 expect ( updatedTomlFile ) . toContain ( 'name = "Updated App Name"' )
@@ -144,7 +131,7 @@ describe.each([false, true])('setAppConfigValue (disableWasmTomlPatch: %s)', (di
144131 await inTemporaryDirectory ( async ( tmpDir ) => {
145132 const configPath = writeDefaulToml ( tmpDir )
146133
147- await setAppConfigValue ( configPath , 'build.dev_store_url' , 'example.myshopify.com' , schema )
134+ await setAppConfigValue ( configPath , 'build.dev_store_url' , 'example.myshopify.com' )
148135
149136 const updatedTomlFile = await readFile ( configPath )
150137 expect ( updatedTomlFile ) . toContain ( '[build]' )
@@ -156,7 +143,7 @@ describe.each([false, true])('setAppConfigValue (disableWasmTomlPatch: %s)', (di
156143 await inTemporaryDirectory ( async ( tmpDir ) => {
157144 const configPath = writeDefaulToml ( tmpDir )
158145
159- await setAppConfigValue ( configPath , 'build.auth.settings' , true , schema )
146+ await setAppConfigValue ( configPath , 'build.auth.settings' , true )
160147
161148 const updatedTomlFile = await readFile ( configPath )
162149 expect ( updatedTomlFile ) . toContain ( '[build.auth]' )
@@ -165,20 +152,12 @@ describe.each([false, true])('setAppConfigValue (disableWasmTomlPatch: %s)', (di
165152 } )
166153} )
167154
168- describe . each ( [ false , true ] ) ( 'unsetAppConfigValue (disableWasmTomlPatch: %s)' , ( disableWasmTomlPatch ) => {
169- beforeEach ( ( ) => {
170- vi . stubEnv ( environmentVariableNames . disableWasmTomlPatch , disableWasmTomlPatch . toString ( ) )
171- } )
172-
173- afterEach ( ( ) => {
174- vi . unstubAllEnvs ( )
175- } )
176-
155+ describe ( 'unsetAppConfigValue' , ( ) => {
177156 test ( 'unsets a top-level value in the configuration' , async ( ) => {
178157 await inTemporaryDirectory ( async ( tmpDir ) => {
179158 const configPath = writeDefaulToml ( tmpDir )
180159
181- await unsetAppConfigValue ( configPath , 'name' , schema )
160+ await unsetAppConfigValue ( configPath , 'name' )
182161
183162 const updatedTomlFile = await readFile ( configPath )
184163 expect ( updatedTomlFile ) . not . toContain ( 'name = "app1"' )
@@ -190,10 +169,10 @@ describe.each([false, true])('unsetAppConfigValue (disableWasmTomlPatch: %s)', (
190169 const configPath = writeDefaulToml ( tmpDir )
191170
192171 // Add a value first
193- await setAppConfigValue ( configPath , 'build.dev_store_url' , 'example.myshopify.com' , schema )
172+ await setAppConfigValue ( configPath , 'build.dev_store_url' , 'example.myshopify.com' )
194173
195174 // Now unset it
196- await unsetAppConfigValue ( configPath , 'build.dev_store_url' , schema )
175+ await unsetAppConfigValue ( configPath , 'build.dev_store_url' )
197176
198177 const updatedTomlFile = await readFile ( configPath )
199178 expect ( updatedTomlFile ) . toContain ( '[build]' )
@@ -202,27 +181,15 @@ describe.each([false, true])('unsetAppConfigValue (disableWasmTomlPatch: %s)', (
202181 } )
203182} )
204183
205- describe . each ( [ false , true ] ) ( 'setManyAppConfigValues (disableWasmTomlPatch: %s)' , ( disableWasmTomlPatch ) => {
206- beforeEach ( ( ) => {
207- vi . stubEnv ( environmentVariableNames . disableWasmTomlPatch , disableWasmTomlPatch . toString ( ) )
208- } )
209-
210- afterEach ( ( ) => {
211- vi . unstubAllEnvs ( )
212- } )
213-
184+ describe ( 'setManyAppConfigValues' , ( ) => {
214185 test ( 'sets multiple top-level values in the configuration' , async ( ) => {
215186 await inTemporaryDirectory ( async ( tmpDir ) => {
216187 const configPath = writeDefaulToml ( tmpDir )
217188
218- await setManyAppConfigValues (
219- configPath ,
220- [
221- { keyPath : 'name' , value : 'Updated App Name' } ,
222- { keyPath : 'client_id' , value : '67890' } ,
223- ] ,
224- schema ,
225- )
189+ await setManyAppConfigValues ( configPath , [
190+ { keyPath : 'name' , value : 'Updated App Name' } ,
191+ { keyPath : 'client_id' , value : '67890' } ,
192+ ] )
226193
227194 const updatedTomlFile = await readFile ( configPath )
228195 expect ( updatedTomlFile ) . toContain ( 'name = "Updated App Name"' )
@@ -234,14 +201,10 @@ describe.each([false, true])('setManyAppConfigValues (disableWasmTomlPatch: %s)'
234201 await inTemporaryDirectory ( async ( tmpDir ) => {
235202 const configPath = writeDefaulToml ( tmpDir )
236203
237- await setManyAppConfigValues (
238- configPath ,
239- [
240- { keyPath : 'name' , value : 'Updated App Name' } ,
241- { keyPath : 'build.dev_store_url' , value : 'example.myshopify.com' } ,
242- ] ,
243- schema ,
244- )
204+ await setManyAppConfigValues ( configPath , [
205+ { keyPath : 'name' , value : 'Updated App Name' } ,
206+ { keyPath : 'build.dev_store_url' , value : 'example.myshopify.com' } ,
207+ ] )
245208
246209 const updatedTomlFile = await readFile ( configPath )
247210 expect ( updatedTomlFile ) . toContain ( 'name = "Updated App Name"' )
@@ -254,11 +217,9 @@ describe.each([false, true])('setManyAppConfigValues (disableWasmTomlPatch: %s)'
254217 await inTemporaryDirectory ( async ( tmpDir ) => {
255218 const configPath = writeDefaulToml ( tmpDir )
256219
257- await setManyAppConfigValues (
258- configPath ,
259- [ { keyPath : 'auth.redirect_urls' , value : [ 'https://example.com/redirect3' , 'https://example.com/redirect4' ] } ] ,
260- schema ,
261- )
220+ await setManyAppConfigValues ( configPath , [
221+ { keyPath : 'auth.redirect_urls' , value : [ 'https://example.com/redirect3' , 'https://example.com/redirect4' ] } ,
222+ ] )
262223
263224 const updatedTomlFile = await readFile ( configPath )
264225 expect ( updatedTomlFile ) . toContain ( '[auth]' )
@@ -274,14 +235,10 @@ describe.each([false, true])('setManyAppConfigValues (disableWasmTomlPatch: %s)'
274235 await inTemporaryDirectory ( async ( tmpDir ) => {
275236 const configPath = writeDefaulToml ( tmpDir )
276237
277- await setManyAppConfigValues (
278- configPath ,
279- [
280- { keyPath : 'build.dev_store_url' , value : 'example.myshopify.com' } ,
281- { keyPath : 'build.automatically_update_urls_on_dev' , value : true } ,
282- ] ,
283- schema ,
284- )
238+ await setManyAppConfigValues ( configPath , [
239+ { keyPath : 'build.dev_store_url' , value : 'example.myshopify.com' } ,
240+ { keyPath : 'build.automatically_update_urls_on_dev' , value : true } ,
241+ ] )
285242
286243 const updatedTomlFile = await readFile ( configPath )
287244 expect ( updatedTomlFile ) . toContain ( '[build]' )
@@ -294,16 +251,12 @@ describe.each([false, true])('setManyAppConfigValues (disableWasmTomlPatch: %s)'
294251 await inTemporaryDirectory ( async ( tmpDir ) => {
295252 const configPath = writeDefaulToml ( tmpDir )
296253
297- await setManyAppConfigValues (
298- configPath ,
299- [
300- { keyPath : 'name' , value : 'Updated App Name' } ,
301- { keyPath : 'application_url' , value : 'https://example.com' } ,
302- { keyPath : 'access_scopes.use_legacy_install_flow' , value : false } ,
303- { keyPath : 'auth.redirect_urls' , value : [ 'https://example.com/redirect3' , 'https://example.com/redirect4' ] } ,
304- ] ,
305- schema ,
306- )
254+ await setManyAppConfigValues ( configPath , [
255+ { keyPath : 'name' , value : 'Updated App Name' } ,
256+ { keyPath : 'application_url' , value : 'https://example.com' } ,
257+ { keyPath : 'access_scopes.use_legacy_install_flow' , value : false } ,
258+ { keyPath : 'auth.redirect_urls' , value : [ 'https://example.com/redirect3' , 'https://example.com/redirect4' ] } ,
259+ ] )
307260
308261 const updatedTomlFile = await readFile ( configPath )
309262 expect ( updatedTomlFile ) . toContain ( 'name = "Updated App Name"' )
0 commit comments