Skip to content

Commit c0aa264

Browse files
authored
Update debug button component (#297)
1 parent 421e073 commit c0aa264

File tree

5 files changed

+35
-15
lines changed

5 files changed

+35
-15
lines changed
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
@page "/tests"
22
@rendermode InteractiveServer
33

4-
<DebugTargetComponent OnValueChanged="SetInput" />
5-
<DebugButtonComponent Input="@currentValue" />
4+
<h1>Debug Button</h1>
5+
<DebugTargetComponent Id="debug-target" OnValueChanged="SetInput" />
6+
<DebugButtonComponent Id="debug-button" Input="@currentValue" />
67

78
@code {
89
private object? currentValue;
910

10-
private void SetInput(int newValue)
11+
private async Task SetInput(int newValue)
1112
{
1213
currentValue = newValue;
14+
await Task.CompletedTask;
1315
}
1416
}

src/AzureOpenAIProxy.PlaygroundApp/Components/UI/DebugButtonComponent.razor

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
@inject IToastService ToastService
22

33
<!-- This component displays the given input when the button is clicked. -->
4-
<FluentButton @onclick="ShowToast" Appearance="Appearance.Accent">Debug</FluentButton>
4+
<FluentButton Id="@Id" @onclick="ShowToast" Appearance="Appearance.Accent">Debug</FluentButton>
55

66
@code {
7+
[Parameter]
8+
public string? Id { get; set; }
9+
710
[Parameter]
811
public object? Input { get; set; }
912

src/AzureOpenAIProxy.PlaygroundApp/Components/UI/DebugTargetComponent.razor

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
<FluentRadioGroup Label="UI Test #171" TValue="int" ValueChanged="SetValue" Orientation="Orientation.Vertical">
1+
<FluentRadioGroup Id="@Id" Label="UI Test #171" TValue="int" ValueChanged="SetValue" Orientation="Orientation.Vertical">
22
<FluentRadio Value="123">123</FluentRadio>
33
<FluentRadio Value="456">456</FluentRadio>
44
<FluentRadio Value="789">789</FluentRadio>
55
</FluentRadioGroup>
66

77
@code {
8+
[Parameter]
9+
public string? Id { get; set; }
10+
811
[Parameter]
912
public EventCallback<int> OnValueChanged { get; set; }
1013

test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/HomePageTests.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ public class HomePageTests : PageTest
1313
IgnoreHTTPSErrors = true,
1414
};
1515

16-
[Test]
17-
public async Task Given_Root_Page_When_Navigated_Then_It_Should_No_Sidebar()
16+
[SetUp]
17+
public async Task Setup()
1818
{
19-
// Arrange
20-
await this.Page.GotoAsync("https://localhost:5001");
19+
await Page.GotoAsync("https://localhost:5001");
20+
await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
21+
}
2122

23+
[Test]
24+
public void Given_Root_Page_When_Navigated_Then_It_Should_No_Sidebar()
25+
{
2226
// Act
23-
var sidebar = this.Page.Locator("div.sidebar");
27+
var sidebar = Page.Locator("div.sidebar");
2428

2529
// Assert
2630
Expect(sidebar).Equals(null);

test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/TestsPageTests.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ public async Task Setup()
2222
}
2323

2424
[Test]
25-
public async Task Given_No_Input_When_DebugButton_Clicked_Then_Toast_Should_Show_NullMessage()
25+
public async Task Given_No_Input_On_DebugTarget_When_DebugButton_Clicked_Then_Toast_Should_Show_NullMessage()
2626
{
27+
// Arrange
28+
var button = Page.Locator("fluent-button#debug-button");
29+
2730
// Act
28-
await Page.GetByRole(AriaRole.Button, new() { Name = "Debug" }).ClickAsync();
31+
await button.ClickAsync();
2932

3033
// Assert
3134
await Expect(Page.Locator(".fluent-toast-title")).ToHaveTextAsync("Input is null.");
@@ -35,11 +38,16 @@ public async Task Given_No_Input_When_DebugButton_Clicked_Then_Toast_Should_Show
3538
[TestCase(123, typeof(int))]
3639
[TestCase(456, typeof(int))]
3740
[TestCase(789, typeof(int))]
38-
public async Task Given_Input_When_DebugButton_Clicked_Then_Toast_Should_Show_Input(int inputValue, Type inputType)
41+
public async Task Given_Input_On_DebugTarget_When_DebugButton_Clicked_Then_Toast_Should_Show_Input(int inputValue, Type inputType)
3942
{
43+
// Arrange
44+
var radio = Page.Locator("fluent-radio-group#debug-target")
45+
.Locator($"fluent-radio[current-value='{inputValue}']");
46+
var button = Page.Locator("fluent-button#debug-button");
47+
4048
// Act
41-
await Page.GetByRole(AriaRole.Radio, new() { Name = $"{inputValue}" }).ClickAsync();
42-
await Page.GetByRole(AriaRole.Button, new() { Name = "Debug" }).ClickAsync();
49+
await radio.ClickAsync();
50+
await button.ClickAsync();
4351

4452
// Assert
4553
await Expect(Page.Locator(".fluent-toast-title")).ToHaveTextAsync($"{inputValue} (Type: {inputType})");

0 commit comments

Comments
 (0)