@@ -6,16 +6,14 @@ import {
66 testThemeExtensions ,
77 testUIExtension ,
88} from '../../models/app/app.test-data.js'
9- import { AppInterface , AppManifest , WebType } from '../../models/app/app.js'
9+ import { AppInterface , AppManifest } from '../../models/app/app.js'
1010import * as bundle from '../bundle.js'
1111import * as functionBuild from '../function/build.js'
12- import * as webService from '../web.js'
1312import { describe , expect , test , vi } from 'vitest'
1413import * as file from '@shopify/cli-kit/node/fs'
1514import { joinPath } from '@shopify/cli-kit/node/path'
1615
1716vi . mock ( '../function/build.js' )
18- vi . mock ( '../web.js' )
1917
2018describe ( 'bundleAndBuildExtensions' , ( ) => {
2119 let app : AppInterface
@@ -262,153 +260,6 @@ describe('bundleAndBuildExtensions', () => {
262260 } )
263261 } )
264262
265- test ( 'runs web build command concurrently with extensions when build command is defined' , async ( ) => {
266- await file . inTemporaryDirectory ( async ( tmpDir : string ) => {
267- // Given
268- const bundlePath = joinPath ( tmpDir , 'bundle.zip' )
269- const mockBuildWeb = vi . mocked ( webService . default )
270-
271- const functionExtension = await testFunctionExtension ( )
272- const extensionBuildMock = vi . fn ( ) . mockImplementation ( async ( options , bundleDirectory ) => {
273- file . writeFileSync ( joinPath ( bundleDirectory , 'index.wasm' ) , '' )
274- } )
275- functionExtension . buildForBundle = extensionBuildMock
276-
277- const app = testApp ( {
278- allExtensions : [ functionExtension ] ,
279- directory : tmpDir ,
280- webs : [
281- {
282- directory : '/tmp/web' ,
283- configuration : {
284- roles : [ WebType . Backend ] ,
285- commands : { dev : 'npm run dev' , build : 'npm run build' } ,
286- } ,
287- } ,
288- ] ,
289- } )
290-
291- const identifiers = {
292- app : 'app-id' ,
293- extensions : { [ functionExtension . localIdentifier ] : functionExtension . localIdentifier } ,
294- extensionIds : { } ,
295- extensionsNonUuidManaged : { } ,
296- }
297- appManifest = await app . manifest ( identifiers )
298-
299- // When
300- await bundleAndBuildExtensions ( {
301- app,
302- appManifest,
303- identifiers,
304- bundlePath,
305- skipBuild : false ,
306- isDevDashboardApp : false ,
307- } )
308-
309- // Then
310- expect ( mockBuildWeb ) . toHaveBeenCalledWith ( 'build' , expect . objectContaining ( { web : app . webs [ 0 ] } ) )
311- } )
312- } )
313-
314- test ( 'skips web build for webs without a build command defined' , async ( ) => {
315- await file . inTemporaryDirectory ( async ( tmpDir : string ) => {
316- // Given
317- const bundlePath = joinPath ( tmpDir , 'bundle.zip' )
318- const mockBuildWeb = vi . mocked ( webService . default )
319-
320- const functionExtension = await testFunctionExtension ( )
321- const extensionBuildMock = vi . fn ( ) . mockImplementation ( async ( options , bundleDirectory ) => {
322- file . writeFileSync ( joinPath ( bundleDirectory , 'index.wasm' ) , '' )
323- } )
324- functionExtension . buildForBundle = extensionBuildMock
325-
326- const app = testApp ( {
327- allExtensions : [ functionExtension ] ,
328- directory : tmpDir ,
329- webs : [
330- {
331- directory : '/tmp/web' ,
332- configuration : {
333- roles : [ WebType . Backend ] ,
334- commands : { dev : 'npm run dev' } ,
335- } ,
336- } ,
337- ] ,
338- } )
339-
340- const identifiers = {
341- app : 'app-id' ,
342- extensions : { [ functionExtension . localIdentifier ] : functionExtension . localIdentifier } ,
343- extensionIds : { } ,
344- extensionsNonUuidManaged : { } ,
345- }
346- appManifest = await app . manifest ( identifiers )
347-
348- // When
349- await bundleAndBuildExtensions ( {
350- app,
351- appManifest,
352- identifiers,
353- bundlePath,
354- skipBuild : false ,
355- isDevDashboardApp : false ,
356- } )
357-
358- // Then
359- expect ( mockBuildWeb ) . not . toHaveBeenCalled ( )
360- } )
361- } )
362-
363- test ( 'skips web build command when skipBuild is true' , async ( ) => {
364- await file . inTemporaryDirectory ( async ( tmpDir : string ) => {
365- // Given
366- const bundlePath = joinPath ( tmpDir , 'bundle.zip' )
367- const mockBuildWeb = vi . mocked ( webService . default )
368-
369- const functionExtension = await testFunctionExtension ( )
370- const extensionCopyMock = vi . fn ( ) . mockImplementation ( async ( options , bundleDirectory ) => {
371- file . writeFileSync ( joinPath ( bundleDirectory , 'index.wasm' ) , '' )
372- } )
373- functionExtension . copyIntoBundle = extensionCopyMock
374-
375- const app = testApp ( {
376- allExtensions : [ functionExtension ] ,
377- directory : tmpDir ,
378- webs : [
379- {
380- directory : '/tmp/web' ,
381- configuration : {
382- roles : [ WebType . Backend ] ,
383- commands : { dev : 'npm run dev' , build : 'npm run build' } ,
384- } ,
385- } ,
386- ] ,
387- } )
388-
389- const identifiers = {
390- app : 'app-id' ,
391- extensions : { [ functionExtension . localIdentifier ] : functionExtension . localIdentifier } ,
392- extensionIds : { } ,
393- extensionsNonUuidManaged : { } ,
394- }
395- appManifest = await app . manifest ( identifiers )
396-
397- // When
398- await bundleAndBuildExtensions ( {
399- app,
400- appManifest,
401- identifiers,
402- bundlePath,
403- skipBuild : true ,
404- isDevDashboardApp : false ,
405- } )
406-
407- // Then
408- expect ( mockBuildWeb ) . not . toHaveBeenCalled ( )
409- } )
410- } )
411-
412263 test ( 'handles multiple extension types together' , async ( ) => {
413264 await file . inTemporaryDirectory ( async ( tmpDir : string ) => {
414265 // Given
0 commit comments