Skip to content

Commit ee90cb8

Browse files
Add test
1 parent 717bb55 commit ee90cb8

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/Components/test/E2ETest/Tests/QuickGridTest.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void CanOpenColumnOptions()
135135
}
136136

137137
[Fact]
138-
public void CanCloseColumnOptions()
138+
public void CanCloseColumnOptionsByBlurring()
139139
{
140140
var grid = app.FindElement(By.CssSelector("#grid > table"));
141141
var firstNameColumnOptionsButton = grid.FindElement(By.CssSelector("thead > tr > th:nth-child(2) > div > button[title=\"Column options\"]"));
@@ -148,4 +148,19 @@ public void CanCloseColumnOptions()
148148
var firstNameSearchSelector = "#grid > table > thead > tr > th:nth-child(2) input[type=search]";
149149
Browser.DoesNotExist(By.CssSelector(firstNameSearchSelector));
150150
}
151+
152+
[Fact]
153+
public void CanCloseColumnOptionsByCloseColumnOptionsAsync()
154+
{
155+
var grid = app.FindElement(By.CssSelector("#grid > table"));
156+
var firstNameColumnOptionsButton = grid.FindElement(By.CssSelector("thead > tr > th:nth-child(2) > div > button[title=\"Column options\"]"));
157+
158+
firstNameColumnOptionsButton.Click();
159+
160+
// Click the button inside the column options to close, this calls CloseColumnOptionsAsync
161+
grid.FindElement(By.CssSelector("#close-column-options")).Click();
162+
163+
var firstNameSearchSelector = "#grid > table > thead > tr > th:nth-child(2) input[type=search]";
164+
Browser.DoesNotExist(By.CssSelector(firstNameSearchSelector));
165+
}
151166
}

src/Components/test/testassets/BasicTestApp/QuickGridTest/SampleQuickGridComponent.razor

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
<h3>Sample QuickGrid Component</h3>
44

55
<div id="grid">
6-
<QuickGrid Items="@FilteredPeople" Pagination="@pagination" custom-attrib="somevalue" class="custom-class-attrib">
6+
<QuickGrid @ref="@quickGrid" Items="@FilteredPeople" Pagination="@pagination" custom-attrib="somevalue" class="custom-class-attrib">
77
<PropertyColumn Property="@(p => p.PersonId)" Sortable="true" />
88
<PropertyColumn Property="@(p => p.firstName)" Sortable="true">
99
<ColumnOptions>
1010
<div class="search-box">
1111
<input type="search" autofocus @bind="firstNameFilter" @bind:event="oninput" placeholder="First name..." />
1212
</div>
13+
<button id="close-column-options" @onclick="@(() => quickGrid.CloseColumnOptionsAsync())">Close Column Options</button>
1314
</ColumnOptions>
1415
</PropertyColumn>
1516
<PropertyColumn Property="@(p => p.lastName)" Sortable="true" />
@@ -23,6 +24,7 @@
2324
record Person(int PersonId, string firstName, string lastName, DateOnly BirthDate);
2425
PaginationState pagination = new PaginationState { ItemsPerPage = 10 };
2526
string firstNameFilter;
27+
QuickGrid<Person> quickGrid;
2628

2729
int ComputeAge(DateOnly birthDate)
2830
=> DateTime.Now.Year - birthDate.Year - (birthDate.DayOfYear < DateTime.Now.DayOfYear ? 0 : 1);

0 commit comments

Comments
 (0)