-
Notifications
You must be signed in to change notification settings - Fork 18
[Playground] Component - button to display a given input #171 #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
justinyoo
merged 14 commits into
aliencube:main
from
o-ii:feature/171-button-to-display
Aug 31, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
fa76d0f
Add DebugButton component to display input parameter (#171)
o-ii 0f8187e
Merge branch 'aliencube:main' into feature/171-button-to-display
o-ii 1b99f1a
Add DebugButton component to display input parameter (#171)
o-ii 8a0a5cb
Merge branch 'aliencube:main' into feature/171-button-to-display
o-ii c9b3195
Merge branch 'aliencube:main' into feature/171-button-to-display
o-ii f01e5b6
Merge branch 'aliencube:main' into feature/171-button-to-display
o-ii 9ec8b57
Merge branch 'aliencube:main' into feature/171-button-to-display
o-ii 5c0f543
Add DebugButton component to display input parameter (#171)
o-ii 38ad360
Merge branch 'aliencube:main' into feature/171-button-to-display
o-ii e0a33a9
Add DebugButton component to display input parameter (#171)
o-ii 28cf1fc
Add DebugButton component to display input parameter (#171)
o-ii 34cd4db
Add DebugButton component to display input parameter (#171)
o-ii dcfc303
Add DebugButton component to display input parameter (#171)
o-ii 7db8473
Add DebugButton component to display input parameter (#171)
o-ii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/AzureOpenAIProxy.PlaygroundApp/Components/Pages/Tests.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@page "/tests" | ||
@rendermode InteractiveServer | ||
|
||
<DebugTargetComponent OnValueChanged="SetInput" /> | ||
<DebugButtonComponent Input="@currentValue" /> | ||
|
||
@code { | ||
private object? currentValue; | ||
|
||
private void SetInput(int newValue) | ||
{ | ||
currentValue = newValue; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/AzureOpenAIProxy.PlaygroundApp/Components/UI/DebugButtonComponent.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@inject IToastService ToastService | ||
|
||
<!-- This component displays the given input when the button is clicked. --> | ||
<FluentButton @onclick="ShowToast" Appearance="Appearance.Accent">Debug</FluentButton> | ||
|
||
@code { | ||
[Parameter] | ||
public object? Input { get; set; } | ||
|
||
private async Task ShowToast() | ||
{ | ||
if (Input is null) | ||
{ | ||
ToastService.ShowToast(ToastIntent.Warning, "Input is null."); | ||
await Task.CompletedTask; | ||
return; | ||
} | ||
|
||
ToastService.ShowToast(ToastIntent.Success, $"{Input} (Type: {Input.GetType()})"); | ||
await Task.CompletedTask; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/AzureOpenAIProxy.PlaygroundApp/Components/UI/DebugTargetComponent.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<FluentRadioGroup Label="UI Test #171" TValue="int" ValueChanged="SetValue" Orientation="Orientation.Vertical"> | ||
<FluentRadio Value="123">123</FluentRadio> | ||
<FluentRadio Value="456">456</FluentRadio> | ||
<FluentRadio Value="789">789</FluentRadio> | ||
</FluentRadioGroup> | ||
|
||
@code { | ||
[Parameter] | ||
public EventCallback<int> OnValueChanged { get; set; } | ||
|
||
private async Task SetValue(int value) | ||
{ | ||
await OnValueChanged.InvokeAsync(value); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/TestsPageTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Microsoft.Playwright; | ||
using Microsoft.Playwright.NUnit; | ||
|
||
namespace AzureOpenAIProxy.PlaygroundApp.Tests.Pages; | ||
|
||
[Parallelizable(ParallelScope.Self)] | ||
[TestFixture] | ||
[Property("Category", "Integration")] | ||
public class TestsPageTests : PageTest | ||
{ | ||
public override BrowserNewContextOptions ContextOptions() => new() | ||
{ | ||
IgnoreHTTPSErrors = true, | ||
}; | ||
|
||
[SetUp] | ||
public async Task Setup() | ||
{ | ||
// Arrange | ||
await Page.GotoAsync("https://localhost:5001/tests"); | ||
await Page.WaitForLoadStateAsync(LoadState.NetworkIdle); | ||
} | ||
|
||
[Test] | ||
public async Task Given_No_Input_When_DebugButton_Clicked_Then_Toast_Should_Show_NullMessage() | ||
{ | ||
// Act | ||
await Page.GetByRole(AriaRole.Button, new() { Name = "Debug" }).ClickAsync(); | ||
|
||
// Assert | ||
await Expect(Page.Locator(".fluent-toast-title")).ToHaveTextAsync("Input is null."); | ||
} | ||
|
||
[Test] | ||
[TestCase(123, typeof(int))] | ||
[TestCase(456, typeof(int))] | ||
[TestCase(789, typeof(int))] | ||
public async Task Given_Input_When_DebugButton_Clicked_Then_Toast_Should_Show_Input(int inputValue, Type inputType) | ||
{ | ||
// Act | ||
await Page.GetByRole(AriaRole.Radio, new() { Name = $"{inputValue}" }).ClickAsync(); | ||
await Page.GetByRole(AriaRole.Button, new() { Name = "Debug" }).ClickAsync(); | ||
|
||
// Assert | ||
await Expect(Page.Locator(".fluent-toast-title")).ToHaveTextAsync($"{inputValue} (Type: {inputType})"); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.