11// Copyright (c) .NET Foundation. All rights reserved.
22// Licensed under the MIT license. See License.txt in the project root for license information.
33
4- using System ;
54using System . IO ;
65using System . Threading ;
76using System . Threading . Tasks ;
@@ -25,7 +24,7 @@ public async Task AddAndRemoveComponent()
2524
2625 async Task RunIterationAsync ( int index , CancellationToken cancellationToken )
2726 {
28- await TestServices . Editor . InsertTextAsync ( $ "<h1>Iteration { index } </h1>{ Environment . NewLine } ", cancellationToken ) ;
27+ await TestServices . Editor . InsertTextAsync ( $ "<h1>Iteration { index } </h1>{{ENTER} }", cancellationToken ) ;
2928
3029 await TestServices . Editor . PlaceCaretAsync ( "h1" , charsOffset : - 1 , cancellationToken ) ;
3130
@@ -56,4 +55,52 @@ async Task RunIterationAsync(int index, CancellationToken cancellationToken)
5655 await TestServices . Editor . InvokeDeleteLineAsync ( cancellationToken ) ;
5756 }
5857 }
58+
59+ [ ManualRunOnlyIdeFact ]
60+ public async Task RenameComponentAttribute ( )
61+ {
62+ await TestServices . SolutionExplorer . OpenFileAsync ( RazorProjectConstants . BlazorProjectName , RazorProjectConstants . IndexRazorFile , ControlledHangMitigatingCancellationToken ) ;
63+
64+ var attributeName = "Title" ;
65+
66+ await TestServices . Editor . PlaceCaretAsync ( $ "{ attributeName } =", charsOffset : - 1 , ControlledHangMitigatingCancellationToken ) ;
67+
68+ await TestServices . Editor . WaitForComponentClassificationAsync ( ControlledHangMitigatingCancellationToken ) ;
69+ // Make sure the test file is still what we expect, with one attribute
70+ await TestServices . Editor . WaitForSemanticClassificationAsync ( "RazorComponentAttribute" , ControlledHangMitigatingCancellationToken , count : 1 , exact : true ) ;
71+
72+ await RunStressTestAsync ( RunIterationAsync ) ;
73+
74+ async Task RunIterationAsync ( int index , CancellationToken cancellationToken )
75+ {
76+ attributeName = $ "RenamedTitle{ index } ";
77+
78+ await Task . Delay ( 500 ) ;
79+
80+ await TestServices . Editor . InvokeRenameAsync ( cancellationToken ) ;
81+ TestServices . Input . Send ( $ "{ attributeName } {{ENTER}}") ;
82+
83+ // The rename operation causes SurveyPrompt.razor to be opened
84+ await TestServices . Editor . WaitForActiveWindowByFileAsync ( "SurveyPrompt.razor" , cancellationToken ) ;
85+ await TestServices . Editor . VerifyTextContainsAsync ( $ "public string? { attributeName } {{ get; set; }}", cancellationToken ) ;
86+ await TestServices . Editor . VerifyTextContainsAsync ( $ "@{ attributeName } ", cancellationToken ) ;
87+
88+ await TestServices . Editor . ValidateNoDiscoColorsAsync ( cancellationToken ) ;
89+
90+ await TestServices . Editor . CloseCurrentlyFocusedWindowAsync ( HangMitigatingCancellationToken , save : true ) ;
91+
92+ await TestServices . Editor . WaitForActiveWindowByFileAsync ( "Index.razor" , cancellationToken ) ;
93+ await TestServices . Editor . VerifyTextContainsAsync ( $ "<SurveyPrompt { attributeName } =", cancellationToken ) ;
94+
95+ // Wait for our new attribute to color correctly
96+ await TestServices . Editor . WaitForSemanticClassificationAsync ( "RazorComponentAttribute" , cancellationToken , count : 1 , exact : true ) ;
97+
98+ await TestServices . Editor . ValidateNoDiscoColorsAsync ( cancellationToken ) ;
99+
100+ await Task . Delay ( 500 ) ;
101+
102+ // Reset the editor state for the next iteration
103+ await TestServices . Editor . PlaceCaretAsync ( $ "{ attributeName } =", charsOffset : - 1 , cancellationToken ) ;
104+ }
105+ }
59106}
0 commit comments