@@ -76,5 +76,59 @@ describe('discovery/patterns/storefront-next', () => {
7676
7777 expect ( result ) . to . be . false ;
7878 } ) ;
79+
80+ it ( 'detects by root package name starting with storefront-next' , async ( ) => {
81+ const pkg = { name : 'storefront-next-app' } ;
82+ await fs . writeFile ( path . join ( tempDir , 'package.json' ) , JSON . stringify ( pkg ) ) ;
83+
84+ const result = await storefrontNextPattern . detect ( tempDir ) ;
85+
86+ expect ( result ) . to . be . true ;
87+ } ) ;
88+
89+ it ( 'detects monorepo when a workspace package has storefront-next dependency' , async ( ) => {
90+ const rootPkg = { name : 'my-monorepo' , workspaces : [ 'packages/*' ] } ;
91+ await fs . writeFile ( path . join ( tempDir , 'package.json' ) , JSON . stringify ( rootPkg ) ) ;
92+ const packagesDir = path . join ( tempDir , 'packages' ) ;
93+ await fs . mkdir ( packagesDir , { recursive : true } ) ;
94+ const pkgDir = path . join ( packagesDir , 'storefront-app' ) ;
95+ await fs . mkdir ( pkgDir , { recursive : true } ) ;
96+ const pkgPkg = { name : 'storefront-app' , dependencies : { '@salesforce/storefront-next-runtime' : '^1.0.0' } } ;
97+ await fs . writeFile ( path . join ( pkgDir , 'package.json' ) , JSON . stringify ( pkgPkg ) ) ;
98+
99+ const result = await storefrontNextPattern . detect ( tempDir ) ;
100+
101+ expect ( result ) . to . be . true ;
102+ } ) ;
103+
104+ it ( 'detects monorepo when a workspace package name starts with storefront-next' , async ( ) => {
105+ const rootPkg = { name : 'some-repo' , workspaces : [ 'packages/*' ] } ;
106+ await fs . writeFile ( path . join ( tempDir , 'package.json' ) , JSON . stringify ( rootPkg ) ) ;
107+ const packagesDir = path . join ( tempDir , 'packages' ) ;
108+ await fs . mkdir ( packagesDir , { recursive : true } ) ;
109+ const pkgDir = path . join ( packagesDir , 'storefront-next-runtime' ) ;
110+ await fs . mkdir ( pkgDir , { recursive : true } ) ;
111+ const pkgPkg = { name : 'storefront-next-runtime' } ;
112+ await fs . writeFile ( path . join ( pkgDir , 'package.json' ) , JSON . stringify ( pkgPkg ) ) ;
113+
114+ const result = await storefrontNextPattern . detect ( tempDir ) ;
115+
116+ expect ( result ) . to . be . true ;
117+ } ) ;
118+
119+ it ( 'returns false for monorepo when no workspace package indicates storefront-next' , async ( ) => {
120+ const rootPkg = { name : 'my-monorepo' , workspaces : [ 'packages/*' ] } ;
121+ await fs . writeFile ( path . join ( tempDir , 'package.json' ) , JSON . stringify ( rootPkg ) ) ;
122+ const packagesDir = path . join ( tempDir , 'packages' ) ;
123+ await fs . mkdir ( packagesDir , { recursive : true } ) ;
124+ const pkgDir = path . join ( packagesDir , 'other-app' ) ;
125+ await fs . mkdir ( pkgDir , { recursive : true } ) ;
126+ const pkgPkg = { name : 'other-app' , dependencies : { react : '^18.0.0' } } ;
127+ await fs . writeFile ( path . join ( pkgDir , 'package.json' ) , JSON . stringify ( pkgPkg ) ) ;
128+
129+ const result = await storefrontNextPattern . detect ( tempDir ) ;
130+
131+ expect ( result ) . to . be . false ;
132+ } ) ;
79133 } ) ;
80134} ) ;
0 commit comments