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

[Admin/Playground] Add NuGet package for Fluent UI #253

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions .github/workflows/azure-dev-build-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,18 @@ jobs:
dotnet test ./test/AzureOpenAIProxy.AppHost.Tests --logger "trx" --collect:"XPlat Code Coverage"
dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests --logger "trx" --collect:"XPlat Code Coverage"

# - name: Run integration tests
# shell: bash
# run: |
# dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests --logger "trx" --collect:"XPlat Code Coverage"
- name: Run integration tests
shell: bash
run: |
dotnet run --project ./src/AzureOpenAIProxy.AppHost &

DOTNET_PID=$!

sleep 30

dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests --logger "trx" --collect:"XPlat Code Coverage"

kill $DOTNET_PID

- name: Publish test results
if: ${{ !cancelled() }}
Expand Down
18 changes: 16 additions & 2 deletions .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,24 @@ jobs:
run: |
dotnet build

- name: Test solution
- name: Run unit tests
shell: bash
run: |
dotnet test --logger "trx" --collect:"XPlat Code Coverage"
dotnet test ./test/AzureOpenAIProxy.AppHost.Tests --logger "trx" --collect:"XPlat Code Coverage"
dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests --logger "trx" --collect:"XPlat Code Coverage"

- name: Run integration tests
shell: bash
run: |
dotnet run --project ./src/AzureOpenAIProxy.AppHost &

DOTNET_PID=$!

sleep 30

dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests --logger "trx" --collect:"XPlat Code Coverage"

kill $DOTNET_PID

- name: Publish test results
uses: bibipkins/dotnet-test-reporter@main
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<OpenTelemetryExtensionsVersion>1.*</OpenTelemetryExtensionsVersion>
<OpenTelemetryInstrumentationVersion>1.*</OpenTelemetryInstrumentationVersion>
<SwashbuckleVersion>6.*</SwashbuckleVersion>
<FluentUIVersion>4.*</FluentUIVersion>

<CoverletVersion>6.*</CoverletVersion>
<FluentAssertionsVersion>6.*</FluentAssertionsVersion>
Expand Down
4 changes: 0 additions & 4 deletions src/AzureOpenAIProxy.ApiApp/AzureOpenAIProxy.ApiApp.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>

<AssemblyName>AzureOpenAIProxy.ApiApp</AssemblyName>
<RootNamespace>AzureOpenAIProxy.ApiApp</RootNamespace>
</PropertyGroup>
Expand Down
7 changes: 4 additions & 3 deletions src/AzureOpenAIProxy.AppHost/AzureOpenAIProxy.AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>

<UserSecretsId>f6c81741-4dbe-4a07-86e3-83a42810f5ec</UserSecretsId>

<AssemblyName>AzureOpenAIProxy.AppHost</AssemblyName>
<RootNamespace>AzureOpenAIProxy.AppHost</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>


<AssemblyName>AzureOpenAIProxy.PlaygroundApp</AssemblyName>
<RootNamespace>AzureOpenAIProxy.PlaygroundApp</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" Version="$(AzureOpenAIVersion)" />
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components" Version="$(FluentUIVersion)" />
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components.Emoji" Version="$(FluentUIVersion)" />
<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components.Icons" Version="$(FluentUIVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/AzureOpenAIProxy.PlaygroundApp/Components/App.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
<link rel="stylesheet" href="bootstrap/bootstrap.min.css" />
<link rel="stylesheet" href="app.css" />
<link rel="stylesheet" href="AzureOpenAIProxy.PlaygroundApp.styles.css" />
<link href="_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css" rel="stylesheet" />
<link rel="icon" type="image/png" href="favicon.png" />
<HeadOutlet />
</head>

<body>
<Routes />
<script src="_framework/blazor.web.js"></script>
<script src="_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.lib.module.js" type="module" async></script>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>

<FluentToastProvider />
<FluentDialogProvider />
<FluentTooltipProvider />
<FluentMessageBarProvider />
8 changes: 7 additions & 1 deletion src/AzureOpenAIProxy.PlaygroundApp/Components/_Imports.razor
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
@using System.Net.Http
@using System.Net.Http.Json

@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using Microsoft.AspNetCore.Components.Web.Virtualization

@using Microsoft.FluentUI.AspNetCore.Components

@using Microsoft.JSInterop

@using static Microsoft.AspNetCore.Components.Web.RenderMode

@using AzureOpenAIProxy.PlaygroundApp
@using AzureOpenAIProxy.PlaygroundApp.Components
4 changes: 4 additions & 0 deletions src/AzureOpenAIProxy.PlaygroundApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using AzureOpenAIProxy.PlaygroundApp.Clients;

using Microsoft.FluentUI.AspNetCore.Components;

using App = AzureOpenAIProxy.PlaygroundApp.Components.App;

var builder = WebApplication.CreateBuilder(args);
Expand All @@ -10,6 +12,8 @@
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();

builder.Services.AddFluentUIComponents();

builder.Services.AddScoped<IOpenAIApiClient, OpenAIApiClient>();

var app = builder.Build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireSharedProject>true</IsAspireSharedProject>

<AssemblyName>AzureOpenAIProxy.ServiceDefaults</AssemblyName>
<RootNamespace>AzureOpenAIProxy.ServiceDefaults</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System.Net;

using AzureOpenAIProxy.AppHost.Tests.Fixtures;

using FluentAssertions;

namespace AzureOpenAIProxy.AppHost.Tests.PlaygroundApp.Pages;

public class HomePageTests(AspireAppHostFixture host) : IClassFixture<AspireAppHostFixture>
{
[Fact]
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_OK()
{
// Arrange
using var httpClient = host.App!.CreateHttpClient("playgroundapp");

// Act
var response = await httpClient.GetAsync("/");

// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
}

[Theory]
[InlineData("_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css")]
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_CSS_Elements(string expected)
{
// Arrange
using var httpClient = host.App!.CreateHttpClient("playgroundapp");

// Act
var html = await httpClient.GetStringAsync("/");

// Assert
html.Should().Contain(expected);
}

[Theory]
[InlineData("_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.lib.module.js")]
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_JavaScript_Elements(string expected)
{
// Arrange
using var httpClient = host.App!.CreateHttpClient("playgroundapp");

// Act
var html = await httpClient.GetStringAsync("/");

// Assert
html.Should().Contain(expected);
}

[Theory]
[InlineData("<div class=\"fluent-tooltip-provider\"></div>")]
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_HTML_Elements(string expected)
{
// Arrange
using var httpClient = host.App!.CreateHttpClient("playgroundapp");

// Act
var html = await httpClient.GetStringAsync("/");

// Assert
html.Should().Contain(expected);
}
}