Skip to content

Commit d7aab48

Browse files
authored
[Playground] Component - Tab for system message and parameters (UI only) #225 (#244)
1 parent 1988498 commit d7aab48

File tree

6 files changed

+97
-3
lines changed

6 files changed

+97
-3
lines changed

src/AzureOpenAIProxy.PlaygroundApp/Components/Pages/Home.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77

88
Welcome to your new app.
99

10-
<ChatWindowComponent @rendermode="InteractiveServer" />
10+
<ChatWindowComponent @rendermode="InteractiveServer"/>

src/AzureOpenAIProxy.PlaygroundApp/Components/Pages/Playground.razor

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22

33
<PageTitle>Playground Page</PageTitle>
44

5-
<h1>playground page!</h1>
5+
<h1>playground page!</h1>
6+
7+
<ConfigTabComponent @rendermode="InteractiveServer"/>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<FluentTabs Id="config-tab" ActiveTabId="system-message" OnTabChange="ChangeTab">
2+
<FluentTab Label="System message" Id="system-message-tab">
3+
This is "System message" tab.
4+
</FluentTab>
5+
<FluentTab Label="Parameters" Id="parameters-tab">
6+
This is "Parameters" tab.
7+
</FluentTab>
8+
</FluentTabs>
9+
10+
<p id="active-tab">[TEST] Active tab changed to: @SelectedTab?.Id</p>
11+
12+
@code {
13+
FluentTab? SelectedTab;
14+
15+
private async Task ChangeTab(FluentTab tab)
16+
{
17+
SelectedTab = tab;
18+
await Task.CompletedTask;
19+
}
20+
}

src/AzureOpenAIProxy.PlaygroundApp/Components/_Imports.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414

1515
@using AzureOpenAIProxy.PlaygroundApp
1616
@using AzureOpenAIProxy.PlaygroundApp.Components
17+
@using AzureOpenAIProxy.PlaygroundApp.Components.UI

src/AzureOpenAIProxy.PlaygroundApp/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@
3636
app.MapRazorComponents<App>()
3737
.AddInteractiveServerRenderMode();
3838

39-
await app.RunAsync();
39+
await app.RunAsync();
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
using Microsoft.Playwright;
2+
using Microsoft.Playwright.NUnit;
3+
4+
namespace AzureOpenAIProxy.PlaygroundApp.Tests.UI;
5+
6+
[Parallelizable(ParallelScope.Self)]
7+
[TestFixture]
8+
[Property("Category", "Integration")]
9+
public class ConfigTabComponentTest : PageTest
10+
{
11+
public override BrowserNewContextOptions ContextOptions() => new() { IgnoreHTTPSErrors = true, };
12+
13+
[SetUp]
14+
public async Task SetUp()
15+
{
16+
await Page.GotoAsync("https://localhost:5001/playground/");
17+
await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
18+
}
19+
20+
[Test]
21+
public async Task Given_ConfigTab_When_Endpoint_Invoked_Then_ConfigTab_Should_Be_Displayed()
22+
{
23+
// Act
24+
var configTab = Page.Locator("fluent-tabs#config-tab");
25+
26+
// Assert
27+
await Expect(configTab).ToBeVisibleAsync();
28+
}
29+
30+
[Test]
31+
public async Task Given_ConfigTab_When_Endpoint_Invoked_Then_Id_Should_Be_System_Message_Tab()
32+
{
33+
// Act
34+
var sysMsgPanel = Page.Locator("fluent-tab-panel#system-message-tab-panel");
35+
var parameterPanel = Page.Locator("fluent-tab-panel#parameters-tab-panel");
36+
37+
// Assert
38+
await Expect(sysMsgPanel).ToBeVisibleAsync();
39+
await Expect(parameterPanel).ToBeHiddenAsync();
40+
}
41+
42+
[Test]
43+
[TestCase(
44+
"fluent-tab#parameters-tab",
45+
"fluent-tab-panel#parameters-tab-panel",
46+
"fluent-tab-panel#system-message-tab-panel"
47+
)]
48+
[TestCase(
49+
"fluent-tab#system-message-tab",
50+
"fluent-tab-panel#system-message-tab-panel",
51+
"fluent-tab-panel#parameters-tab-panel"
52+
)]
53+
public async Task Given_ConfigTab_When_Changed_Then_Tab_Should_Be_Updated(
54+
string selectedTabSelector,
55+
string selectedPanelSelector,
56+
string hiddenPanelSelector
57+
)
58+
{
59+
// Arrange
60+
var selectedTab = Page.Locator(selectedTabSelector);
61+
var selectedPanel = Page.Locator(selectedPanelSelector);
62+
var hiddenPanel = Page.Locator(hiddenPanelSelector);
63+
64+
// Act
65+
await selectedTab.ClickAsync();
66+
67+
// Assert
68+
await Expect(selectedPanel).ToBeVisibleAsync();
69+
await Expect(hiddenPanel).ToBeHiddenAsync();
70+
}
71+
}

0 commit comments

Comments
 (0)