Skip to content
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

[Playground] Component - Tab for system message and parameters (UI only) #225 #244

Merged
merged 11 commits into from
Aug 31, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

Welcome to your new app.

<ChatWindowComponent @rendermode="InteractiveServer" />
<ChatWindowComponent @rendermode="InteractiveServer"/>
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

<PageTitle>Playground Page</PageTitle>

<h1>playground page!</h1>
<h1>playground page!</h1>

<ConfigTabComponent @rendermode="InteractiveServer"/>
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@

@using AzureOpenAIProxy.PlaygroundApp
@using AzureOpenAIProxy.PlaygroundApp.Components
@using AzureOpenAIProxy.PlaygroundApp.Components.UI
2 changes: 1 addition & 1 deletion src/AzureOpenAIProxy.PlaygroundApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();

await app.RunAsync();
await app.RunAsync();
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();
}
}