@@ -112,7 +112,7 @@ describe('app_config_app_access', () => {
112112 expect ( result ) . toEqual ( [ 'Access scopes auto-granted: write_orders, read_inventory' ] )
113113 } )
114114
115- test ( 'should return default message when no scopes are provided' , async ( ) => {
115+ test ( 'should return managed install flow empty scopes message when no access_scopes are provided' , async ( ) => {
116116 // Given
117117 const config = {
118118 auth : {
@@ -126,5 +126,114 @@ describe('app_config_app_access', () => {
126126 // Then
127127 expect ( result ) . toEqual ( [ 'App has been installed' ] )
128128 } )
129+
130+ test ( 'should return legacy install flow message when use_legacy_install_flow is true' , async ( ) => {
131+ // Given
132+ const config = {
133+ access_scopes : {
134+ scopes : 'read_products,write_products' ,
135+ use_legacy_install_flow : true ,
136+ } ,
137+ auth : {
138+ redirect_urls : [ 'https://example.com/auth/callback' ] ,
139+ } ,
140+ }
141+
142+ // When
143+ const result = await spec . getDevSessionUpdateMessages ! ( config )
144+
145+ // Then
146+ expect ( result ) . toEqual ( [ 'Using legacy install flow - access scopes are not auto-granted' ] )
147+ } )
148+
149+ test ( 'should return legacy install flow message even with required_scopes when use_legacy_install_flow is true' , async ( ) => {
150+ // Given
151+ const config = {
152+ access_scopes : {
153+ required_scopes : [ 'write_orders' , 'read_inventory' ] ,
154+ use_legacy_install_flow : true ,
155+ } ,
156+ auth : {
157+ redirect_urls : [ 'https://example.com/auth/callback' ] ,
158+ } ,
159+ }
160+
161+ // When
162+ const result = await spec . getDevSessionUpdateMessages ! ( config )
163+
164+ // Then
165+ expect ( result ) . toEqual ( [ 'Using legacy install flow - access scopes are not auto-granted' ] )
166+ } )
167+
168+ test ( 'should return normal scopes message when use_legacy_install_flow is false' , async ( ) => {
169+ // Given
170+ const config = {
171+ access_scopes : {
172+ scopes : 'read_products,write_products' ,
173+ use_legacy_install_flow : false ,
174+ } ,
175+ auth : {
176+ redirect_urls : [ 'https://example.com/auth/callback' ] ,
177+ } ,
178+ }
179+
180+ // When
181+ const result = await spec . getDevSessionUpdateMessages ! ( config )
182+
183+ // Then
184+ expect ( result ) . toEqual ( [ 'Access scopes auto-granted: read_products, write_products' ] )
185+ } )
186+
187+ test ( 'should return legacy install flow message when both scopes and required_scopes are nil' , async ( ) => {
188+ // Given
189+ const config = {
190+ access_scopes : { } ,
191+ auth : {
192+ redirect_urls : [ 'https://example.com/auth/callback' ] ,
193+ } ,
194+ }
195+
196+ // When
197+ const result = await spec . getDevSessionUpdateMessages ! ( config )
198+
199+ // Then
200+ expect ( result ) . toEqual ( [ 'Using legacy install flow - access scopes are not auto-granted' ] )
201+ } )
202+
203+ test ( 'should handle empty string scopes' , async ( ) => {
204+ // Given
205+ const config = {
206+ access_scopes : {
207+ scopes : '' ,
208+ } ,
209+ auth : {
210+ redirect_urls : [ 'https://example.com/auth/callback' ] ,
211+ } ,
212+ }
213+
214+ // When
215+ const result = await spec . getDevSessionUpdateMessages ! ( config )
216+
217+ // Then
218+ expect ( result ) . toEqual ( [ 'App has been installed' ] )
219+ } )
220+
221+ test ( 'should handle empty array required_scopes' , async ( ) => {
222+ // Given
223+ const config = {
224+ access_scopes : {
225+ required_scopes : [ ] ,
226+ } ,
227+ auth : {
228+ redirect_urls : [ 'https://example.com/auth/callback' ] ,
229+ } ,
230+ }
231+
232+ // When
233+ const result = await spec . getDevSessionUpdateMessages ! ( config )
234+
235+ // Then
236+ expect ( result ) . toEqual ( [ 'App has been installed' ] )
237+ } )
129238 } )
130239} )
0 commit comments