diff --git a/tests/Integration/Components/FluentPlaywrightBaseTest.cs b/tests/Integration/Components/FluentPlaywrightBaseTest.cs index dcc6778a67..6b6224cff4 100644 --- a/tests/Integration/Components/FluentPlaywrightBaseTest.cs +++ b/tests/Integration/Components/FluentPlaywrightBaseTest.cs @@ -37,12 +37,13 @@ protected FluentPlaywrightBaseTest(ITestOutputHelper output, StartServerFixture /// protected virtual StartServerFixture Server { get; set; } - public async Task WaitOpenPageAsync(string url, bool? openDevTools = null) + public async Task 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(); diff --git a/tests/Integration/Components/List/Autocomplete/Examples/OnChangeAfterPage.razor b/tests/Integration/Components/List/Autocomplete/Examples/OnChangeAfterPage.razor new file mode 100644 index 0000000000..a388e1b131 --- /dev/null +++ b/tests/Integration/Components/List/Autocomplete/Examples/OnChangeAfterPage.razor @@ -0,0 +1,33 @@ +@page "/list/autocomplete/onchange-after" + +
+ Current count: @countAfter +
+ + + +@code +{ + string test = string.Empty; + int countAfter = 0; + IEnumerable SelectedItems { get; set; } = []; + + void AfterChanged() + { + countAfter++; + } + + List Options = new List + { + "Option 1", + "Option 2", + "Option 3", + "Option 4", + "Option 5" + }; +} diff --git a/tests/Integration/Components/List/Autocomplete/FluentAutocompleteTests.cs b/tests/Integration/Components/List/Autocomplete/FluentAutocompleteTests.cs new file mode 100644 index 0000000000..55fc0f54c7 --- /dev/null +++ b/tests/Integration/Components/List/Autocomplete/FluentAutocompleteTests.cs @@ -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"); + } +} +