|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Linq;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.VisualStudio.Razor.IntegrationTests;
public class HtmlCodeActionsTests(ITestOutputHelper testOutputHelper) : AbstractRazorEditorTest(testOutputHelper)
{
[IdeFact]
public async Task HtmlCodeActionsTests_RemoveTag()
{
// Open the file
await TestServices.SolutionExplorer.OpenFileAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.CounterRazorFile, ControlledHangMitigatingCancellationToken);
await TestServices.Editor.PlaceCaretAsync("<h1>", 0, ControlledHangMitigatingCancellationToken);
// Act
var codeActions = await TestServices.Editor.InvokeCodeActionListAsync(ControlledHangMitigatingCancellationToken);
// Assert
var codeAction = Assert.Single(codeActions.SelectMany(s => s.Actions), a => a.DisplayText.Equals("Remove <h1> tag and leave contents"));
await TestServices.Editor.InvokeCodeActionAsync(codeAction, ControlledHangMitigatingCancellationToken);
await TestServices.Editor.WaitForCurrentLineTextAsync("Counter", ControlledHangMitigatingCancellationToken);
}
[IdeFact]
public async Task HtmlCodeActionsTests_RemoveTag_WithCSharpContent()
{
// Open the file
await TestServices.SolutionExplorer.OpenFileAsync(RazorProjectConstants.BlazorProjectName, RazorProjectConstants.ErrorCshtmlFile, ControlledHangMitigatingCancellationToken);
await TestServices.Editor.PlaceCaretAsync("<body>", 0, ControlledHangMitigatingCancellationToken);
// Act
var codeActions = await TestServices.Editor.InvokeCodeActionListAsync(ControlledHangMitigatingCancellationToken);
// Assert
var codeAction = Assert.Single(codeActions.SelectMany(s => s.Actions), a => a.DisplayText.Equals("Remove <body> tag and leave contents"));
await TestServices.Editor.InvokeCodeActionAsync(codeAction, ControlledHangMitigatingCancellationToken);
await TestServices.Editor.VerifyTextDoesntContainAsync("~~~", ControlledHangMitigatingCancellationToken);
}
}
|