@@ -229,4 +229,102 @@ public async Task NuGetConfigMerger_WhenChannelRequiresGlobalPackagesFolder_Adds
229229 Assert . NotNull ( globalPackagesFolderAdd ) ;
230230 Assert . Equal ( ".nugetpackages" , ( string ? ) globalPackagesFolderAdd . Attribute ( "value" ) ) ;
231231 }
232+
233+ [ Fact ]
234+ public async Task GetChannelsAsync_WhenStagingChannelEnabled_StagingAppearsAfterStableBeforeDaily ( )
235+ {
236+ // Arrange
237+ using var workspace = TemporaryWorkspace . Create ( outputHelper ) ;
238+ var tempDir = workspace . WorkspaceRoot ;
239+ var hivesDir = new DirectoryInfo ( Path . Combine ( tempDir . FullName , ".aspire" , "hives" ) ) ;
240+ var cacheDir = new DirectoryInfo ( Path . Combine ( tempDir . FullName , ".aspire" , "cache" ) ) ;
241+
242+ // Create some PR hives to ensure staging appears before them
243+ hivesDir . Create ( ) ;
244+ Directory . CreateDirectory ( Path . Combine ( hivesDir . FullName , "pr-10167" ) ) ;
245+ Directory . CreateDirectory ( Path . Combine ( hivesDir . FullName , "pr-11832" ) ) ;
246+
247+ var executionContext = new CliExecutionContext ( tempDir , hivesDir , cacheDir , new DirectoryInfo ( Path . Combine ( Path . GetTempPath ( ) , "aspire-test-runtimes" ) ) ) ;
248+
249+ var features = new TestFeatures ( ) ;
250+ features . SetFeature ( KnownFeatures . StagingChannelEnabled , true ) ;
251+
252+ var configuration = new ConfigurationBuilder ( )
253+ . AddInMemoryCollection ( new Dictionary < string , string ? >
254+ {
255+ [ "overrideStagingHash" ] = "12345678"
256+ } )
257+ . Build ( ) ;
258+
259+ var packagingService = new PackagingService ( executionContext , new FakeNuGetPackageCache ( ) , features , configuration ) ;
260+
261+ // Act
262+ var channels = await packagingService . GetChannelsAsync ( ) ;
263+
264+ // Assert
265+ var channelNames = channels . Select ( c => c . Name ) . ToList ( ) ;
266+
267+ // Verify all expected channels are present
268+ Assert . Contains ( "default" , channelNames ) ;
269+ Assert . Contains ( "stable" , channelNames ) ;
270+ Assert . Contains ( "staging" , channelNames ) ;
271+ Assert . Contains ( "daily" , channelNames ) ;
272+ Assert . Contains ( "pr-10167" , channelNames ) ;
273+ Assert . Contains ( "pr-11832" , channelNames ) ;
274+
275+ // Verify the order: default, stable, staging, daily, pr-*
276+ var defaultIndex = channelNames . IndexOf ( "default" ) ;
277+ var stableIndex = channelNames . IndexOf ( "stable" ) ;
278+ var stagingIndex = channelNames . IndexOf ( "staging" ) ;
279+ var dailyIndex = channelNames . IndexOf ( "daily" ) ;
280+ var pr10167Index = channelNames . IndexOf ( "pr-10167" ) ;
281+ var pr11832Index = channelNames . IndexOf ( "pr-11832" ) ;
282+
283+ Assert . True ( defaultIndex < stableIndex , $ "default should come before stable (default: { defaultIndex } , stable: { stableIndex } )") ;
284+ Assert . True ( stableIndex < stagingIndex , $ "stable should come before staging (stable: { stableIndex } , staging: { stagingIndex } )") ;
285+ Assert . True ( stagingIndex < dailyIndex , $ "staging should come before daily (staging: { stagingIndex } , daily: { dailyIndex } )") ;
286+ Assert . True ( dailyIndex < pr10167Index , $ "daily should come before pr-10167 (daily: { dailyIndex } , pr-10167: { pr10167Index } )") ;
287+ Assert . True ( dailyIndex < pr11832Index , $ "daily should come before pr-11832 (daily: { dailyIndex } , pr-11832: { pr11832Index } )") ;
288+ }
289+
290+ [ Fact ]
291+ public async Task GetChannelsAsync_WhenStagingChannelDisabled_OrderIsDefaultStableDailyPr ( )
292+ {
293+ // Arrange
294+ using var workspace = TemporaryWorkspace . Create ( outputHelper ) ;
295+ var tempDir = workspace . WorkspaceRoot ;
296+ var hivesDir = new DirectoryInfo ( Path . Combine ( tempDir . FullName , ".aspire" , "hives" ) ) ;
297+ var cacheDir = new DirectoryInfo ( Path . Combine ( tempDir . FullName , ".aspire" , "cache" ) ) ;
298+
299+ // Create some PR hives
300+ hivesDir . Create ( ) ;
301+ Directory . CreateDirectory ( Path . Combine ( hivesDir . FullName , "pr-12345" ) ) ;
302+
303+ var executionContext = new CliExecutionContext ( tempDir , hivesDir , cacheDir , new DirectoryInfo ( Path . Combine ( Path . GetTempPath ( ) , "aspire-test-runtimes" ) ) ) ;
304+
305+ var features = new TestFeatures ( ) ;
306+ // Staging disabled by default
307+ var configuration = new ConfigurationBuilder ( ) . Build ( ) ;
308+
309+ var packagingService = new PackagingService ( executionContext , new FakeNuGetPackageCache ( ) , features , configuration ) ;
310+
311+ // Act
312+ var channels = await packagingService . GetChannelsAsync ( ) ;
313+
314+ // Assert
315+ var channelNames = channels . Select ( c => c . Name ) . ToList ( ) ;
316+
317+ // Verify staging is not present
318+ Assert . DoesNotContain ( "staging" , channelNames ) ;
319+
320+ // Verify the order: default, stable, daily, pr-*
321+ var defaultIndex = channelNames . IndexOf ( "default" ) ;
322+ var stableIndex = channelNames . IndexOf ( "stable" ) ;
323+ var dailyIndex = channelNames . IndexOf ( "daily" ) ;
324+ var pr12345Index = channelNames . IndexOf ( "pr-12345" ) ;
325+
326+ Assert . True ( defaultIndex < stableIndex , "default should come before stable" ) ;
327+ Assert . True ( stableIndex < dailyIndex , "stable should come before daily" ) ;
328+ Assert . True ( dailyIndex < pr12345Index , "daily should come before pr-12345" ) ;
329+ }
232330}
0 commit comments