forked from aliencube/azure-openai-sdk-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Playground] Component - Tab for system message and parameters (UI on…
…ly) aliencube#225 (aliencube#244)
- Loading branch information
Showing
6 changed files
with
97 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
20 changes: 20 additions & 0 deletions
20
src/AzureOpenAIProxy.PlaygroundApp/Components/UI/ConfigTabComponent.razor
This file contains 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,20 @@ | ||
<FluentTabs Id="config-tab" ActiveTabId="system-message" OnTabChange="ChangeTab"> | ||
<FluentTab Label="System message" Id="system-message-tab"> | ||
This is "System message" tab. | ||
</FluentTab> | ||
<FluentTab Label="Parameters" Id="parameters-tab"> | ||
This is "Parameters" tab. | ||
</FluentTab> | ||
</FluentTabs> | ||
|
||
<p id="active-tab">[TEST] Active tab changed to: @SelectedTab?.Id</p> | ||
|
||
@code { | ||
FluentTab? SelectedTab; | ||
|
||
private async Task ChangeTab(FluentTab tab) | ||
{ | ||
SelectedTab = tab; | ||
await Task.CompletedTask; | ||
} | ||
} |
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -36,4 +36,4 @@ | |
app.MapRazorComponents<App>() | ||
.AddInteractiveServerRenderMode(); | ||
|
||
await app.RunAsync(); | ||
await app.RunAsync(); |
71 changes: 71 additions & 0 deletions
71
test/AzureOpenAIProxy.PlaygroundApp.Tests/UI/ConfigTabComponentTest.cs
This file contains 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,71 @@ | ||
using Microsoft.Playwright; | ||
using Microsoft.Playwright.NUnit; | ||
|
||
namespace AzureOpenAIProxy.PlaygroundApp.Tests.UI; | ||
|
||
[Parallelizable(ParallelScope.Self)] | ||
[TestFixture] | ||
[Property("Category", "Integration")] | ||
public class ConfigTabComponentTest : PageTest | ||
{ | ||
public override BrowserNewContextOptions ContextOptions() => new() { IgnoreHTTPSErrors = true, }; | ||
|
||
[SetUp] | ||
public async Task SetUp() | ||
{ | ||
await Page.GotoAsync("https://localhost:5001/playground/"); | ||
await Page.WaitForLoadStateAsync(LoadState.NetworkIdle); | ||
} | ||
|
||
[Test] | ||
public async Task Given_ConfigTab_When_Endpoint_Invoked_Then_ConfigTab_Should_Be_Displayed() | ||
{ | ||
// Act | ||
var configTab = Page.Locator("fluent-tabs#config-tab"); | ||
|
||
// Assert | ||
await Expect(configTab).ToBeVisibleAsync(); | ||
} | ||
|
||
[Test] | ||
public async Task Given_ConfigTab_When_Endpoint_Invoked_Then_Id_Should_Be_System_Message_Tab() | ||
{ | ||
// Act | ||
var sysMsgPanel = Page.Locator("fluent-tab-panel#system-message-tab-panel"); | ||
var parameterPanel = Page.Locator("fluent-tab-panel#parameters-tab-panel"); | ||
|
||
// Assert | ||
await Expect(sysMsgPanel).ToBeVisibleAsync(); | ||
await Expect(parameterPanel).ToBeHiddenAsync(); | ||
} | ||
|
||
[Test] | ||
[TestCase( | ||
"fluent-tab#parameters-tab", | ||
"fluent-tab-panel#parameters-tab-panel", | ||
"fluent-tab-panel#system-message-tab-panel" | ||
)] | ||
[TestCase( | ||
"fluent-tab#system-message-tab", | ||
"fluent-tab-panel#system-message-tab-panel", | ||
"fluent-tab-panel#parameters-tab-panel" | ||
)] | ||
public async Task Given_ConfigTab_When_Changed_Then_Tab_Should_Be_Updated( | ||
string selectedTabSelector, | ||
string selectedPanelSelector, | ||
string hiddenPanelSelector | ||
) | ||
{ | ||
// Arrange | ||
var selectedTab = Page.Locator(selectedTabSelector); | ||
var selectedPanel = Page.Locator(selectedPanelSelector); | ||
var hiddenPanel = Page.Locator(hiddenPanelSelector); | ||
|
||
// Act | ||
await selectedTab.ClickAsync(); | ||
|
||
// Assert | ||
await Expect(selectedPanel).ToBeVisibleAsync(); | ||
await Expect(hiddenPanel).ToBeHiddenAsync(); | ||
} | ||
} |