Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tests/Integration/Components/FluentPlaywrightBaseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ protected FluentPlaywrightBaseTest(ITestOutputHelper output, StartServerFixture
/// </summary>
protected virtual StartServerFixture Server { get; set; }

public async Task<IPage> WaitOpenPageAsync(string url, bool? openDevTools = null)
public async Task<IPage> WaitOpenPageAsync(string url, bool? openDevTools = null, bool? openHeadlessBrowser = null)
{
_playwright = await Playwright.Playwright.CreateAsync();
_browser = await _playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions()
{
Devtools = openDevTools
Devtools = openDevTools,
Headless = openHeadlessBrowser
});

var page = await _browser.NewPageAsync();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@page "/list/autocomplete/onchange-after"

<div>
Current count: <span data-testid="current-value">@countAfter</span>
</div>

<FluentAutocomplete TValue="string"
TOption="string"
Label="Test"
Items="Options"
@bind-SelectedItems="SelectedItems"
@bind-SelectedItems:after="AfterChanged" />

@code
{
string test = string.Empty;
int countAfter = 0;
IEnumerable<string> SelectedItems { get; set; } = [];

void AfterChanged()
{
countAfter++;
}

List<string> Options = new List<string>
{
"Option 1",
"Option 2",
"Option 3",
"Option 4",
"Option 5"
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// ------------------------------------------------------------------------
// This file is licensed to you under the MIT License.
// ------------------------------------------------------------------------

using Microsoft.FluentUI.AspNetCore.Components.IntegrationTests.WebServer;
using Microsoft.Playwright;
using Xunit;
using Xunit.Abstractions;

namespace Microsoft.FluentUI.AspNetCore.Components.IntegrationTests.Components.List;

[Collection(StartServerCollection.Name)]
public class FluentAutocompleteTests : FluentPlaywrightBaseTest
{
public FluentAutocompleteTests(ITestOutputHelper output, StartServerFixture server)
: base(output, server)
{
}

[Fact(Skip = "Playwright is optional for the moment. This test will fail.")]
public async Task FluentAutocomplete_OnChangeAfter()
{
// Arrange
var page = await WaitOpenPageAsync($"/list/autocomplete/onchange-after", openDevTools: false);

// Act
await page.ClickAsync("fluent-text-input");
await page.ClickAsync("fluent-option");
await Task.Delay(100); // Wait for the onChange event to propagate

// Assert
await page.ScreenshotAsync(new()
{
Path = $"{Server.ScreenshotsFolder}FluentAutocomplete_OnChangeAfter.png"
});

await Assertions.Expect(page.GetByTestId("current-value"))
.ToContainTextAsync("1");
}
}

Loading