-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8116 from davidwengier/WrapWithTagTests
Fixes #8077
- Loading branch information
Showing
1 changed file
with
118 additions
and
0 deletions.
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
src/Razor/test/Microsoft.VisualStudio.Razor.IntegrationTests/WrapWithTagTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT license. See License.txt in the project root for license information. | ||
|
||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace Microsoft.VisualStudio.Razor.IntegrationTests; | ||
|
||
public class WrapWithTagTests : AbstractRazorEditorTest | ||
{ | ||
[IdeFact] | ||
public async Task WrapWithTag_RootLevelElement() | ||
{ | ||
// Open the file | ||
await TestServices.SolutionExplorer.OpenFileAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.CounterRazorFile, ControlledHangMitigatingCancellationToken); | ||
|
||
await TestServices.Editor.PlaceCaretAsync("h1", charsOffset: -1, ControlledHangMitigatingCancellationToken); | ||
|
||
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken); | ||
|
||
// Act | ||
// % == Alt, + == Shift, so this is Alt+Shift+W | ||
TestServices.Input.Send("%+w"); | ||
|
||
// Assert | ||
await TestServices.Editor.WaitForCurrentLineTextAsync("<div><h1>Counter</h1></div>", ControlledHangMitigatingCancellationToken); | ||
} | ||
|
||
[IdeFact] | ||
public async Task WrapWithTag_ChildElement() | ||
{ | ||
// Open the file | ||
await TestServices.SolutionExplorer.OpenFileAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.FetchDataRazorFile, ControlledHangMitigatingCancellationToken); | ||
|
||
await TestServices.Editor.PlaceCaretAsync("<em", charsOffset: 1, ControlledHangMitigatingCancellationToken); | ||
|
||
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken); | ||
|
||
// Act | ||
// % == Alt, + == Shift, so this is Alt+Shift+W | ||
TestServices.Input.Send("%+w"); | ||
|
||
// Assert | ||
await TestServices.Editor.WaitForCurrentLineTextAsync("<p><div><em>Loading...</em></div></p>", ControlledHangMitigatingCancellationToken); | ||
} | ||
|
||
[IdeFact] | ||
public async Task WrapWithTag_Multiline() | ||
{ | ||
// Open the file | ||
await TestServices.SolutionExplorer.OpenFileAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.IndexRazorFile, ControlledHangMitigatingCancellationToken); | ||
|
||
await TestServices.Editor.SetTextAsync(""" | ||
@{ | ||
var items = new[] { 1, 2, 3, 4 }; | ||
} | ||
<PageTitle>Temp</PageTitle> | ||
<div> | ||
<table> | ||
@foreach (var item in items) { | ||
<tr> | ||
<td>@item</td> | ||
</tr> | ||
} | ||
</table> | ||
</div> | ||
""", ControlledHangMitigatingCancellationToken); | ||
|
||
await TestServices.Editor.PlaceCaretAsync("table", charsOffset: -1, ControlledHangMitigatingCancellationToken); | ||
|
||
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken); | ||
|
||
// Act | ||
// % == Alt, + == Shift, so this is Alt+Shift+W | ||
TestServices.Input.Send("%+w"); | ||
|
||
// Assert | ||
await TestServices.Editor.WaitForTextChangeAsync(""" | ||
@{ | ||
var items = new[] { 1, 2, 3, 4 }; | ||
} | ||
<PageTitle>Temp</PageTitle> | ||
<div> | ||
<div> | ||
<table> | ||
@foreach (var item in items) { | ||
<tr> | ||
<td>@item</td> | ||
</tr> | ||
} | ||
</table> | ||
</div> | ||
</div> | ||
""", ControlledHangMitigatingCancellationToken); | ||
} | ||
|
||
[IdeFact] | ||
public async Task WrapWithTag_SelfClosingTag() | ||
{ | ||
// Open the file | ||
await TestServices.SolutionExplorer.OpenFileAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.IndexRazorFile, ControlledHangMitigatingCancellationToken); | ||
|
||
await TestServices.Editor.PlaceCaretAsync("SurveyPrompt", charsOffset: -1, ControlledHangMitigatingCancellationToken); | ||
|
||
await TestServices.Editor.WaitForComponentClassificationAsync(ControlledHangMitigatingCancellationToken); | ||
|
||
// Act | ||
// % == Alt, + == Shift, so this is Alt+Shift+W | ||
TestServices.Input.Send("%+w"); | ||
|
||
// Assert | ||
await TestServices.Editor.WaitForCurrentLineTextAsync("<div><SurveyPrompt Title=\"How is Blazor working for you?\" /></div>", ControlledHangMitigatingCancellationToken); | ||
} | ||
} |