From bd3c6428bd6d61e6adcae8d08be78544cb66671d Mon Sep 17 00:00:00 2001 From: David Moreira Date: Thu, 5 Oct 2023 16:26:55 +0100 Subject: [PATCH] Autocomplete | Fix FreeTypingNotFoundTemplate not showing --- .../Blazorise.Components/Autocomplete.razor | 2 +- .../Autocomplete_5038Component.razor | 30 ++++++++++++++++ .../Autocomplete/Autocomplete_5038_Tests.cs | 35 +++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 Tests/BasicTestApp.Client/Autocomplete_5038Component.razor create mode 100644 Tests/Blazorise.E2E.Tests/Tests/Extensions/Autocomplete/Autocomplete_5038_Tests.cs diff --git a/Source/Extensions/Blazorise.Components/Autocomplete.razor b/Source/Extensions/Blazorise.Components/Autocomplete.razor index 09315159c7..23fd1363f5 100644 --- a/Source/Extensions/Blazorise.Components/Autocomplete.razor +++ b/Source/Extensions/Blazorise.Components/Autocomplete.razor @@ -4,7 +4,7 @@ @typeparam TItem @typeparam TValue - + @if ( IsMultiple && !SelectedTexts.IsNullOrEmpty() ) diff --git a/Tests/BasicTestApp.Client/Autocomplete_5038Component.razor b/Tests/BasicTestApp.Client/Autocomplete_5038Component.razor new file mode 100644 index 0000000000..f31e77d0d8 --- /dev/null +++ b/Tests/BasicTestApp.Client/Autocomplete_5038Component.razor @@ -0,0 +1,30 @@ + + + Add "@context" + + + +@code { + private List colors = new List + { + "Red", + "Orange", + "Yellow", + "Bright Green", + "Dark Green", + "Sky Blue", + "Blue", + "Purple", + "Hot Pink", + "Black", + "White", + "Gray" + }; +} \ No newline at end of file diff --git a/Tests/Blazorise.E2E.Tests/Tests/Extensions/Autocomplete/Autocomplete_5038_Tests.cs b/Tests/Blazorise.E2E.Tests/Tests/Extensions/Autocomplete/Autocomplete_5038_Tests.cs new file mode 100644 index 0000000000..99f8871075 --- /dev/null +++ b/Tests/Blazorise.E2E.Tests/Tests/Extensions/Autocomplete/Autocomplete_5038_Tests.cs @@ -0,0 +1,35 @@ +namespace Blazorise.E2E.Tests.Tests.Extensions.Autocomplete; + +[Parallelizable( ParallelScope.Self )] +[TestFixture] +public class Autocomplete_5038_Tests : BlazorisePageTest +{ + + [SetUp] + public async Task Init() + { + await SelectTestComponent(); + } + + /// + /// When a value is already set, setting a different value programmatically and then revisiting should have updated the Current Search Value and options shown. + /// + /// + [Test] + public async Task Test() + { + var sut = Page.Locator( ".b-is-autocomplete input[type=search]" ); + var dropdownMenu = Page.Locator( ".dropdown-menu.show" ); + + await sut.ClickAsync(); + await sut.FillAsync( "My Color" ); + await sut.PressAsync( "Enter" ); + await Expect( sut ).ToHaveValueAsync( "My Color" ); + + await dropdownMenu.WaitForAsync(); + var option = ( await dropdownMenu.Locator( ".dropdown-item" ).AllAsync() ).Single(); + + await Expect( option ).ToHaveTextAsync( @"Add ""My Color""" ); + } +} +