From 7185a4ef4c262971feb9fee96384c12cca74d33a Mon Sep 17 00:00:00 2001 From: Justin Yoo Date: Thu, 22 Aug 2024 17:08:03 +0900 Subject: [PATCH] Add NuGet package for Fluent UI --- .github/workflows/azure-dev-build-only.yml | 16 +++-- .github/workflows/azure-dev.yml | 18 ++++- Directory.Build.props | 1 + .../AzureOpenAIProxy.ApiApp.csproj | 4 -- .../AzureOpenAIProxy.AppHost.csproj | 7 +- .../AzureOpenAIProxy.PlaygroundApp.csproj | 8 +-- .../Components/App.razor | 2 + .../Components/Layout/MainLayout.razor | 5 ++ .../Components/_Imports.razor | 8 ++- src/AzureOpenAIProxy.PlaygroundApp/Program.cs | 4 ++ .../AzureOpenAIProxy.ServiceDefaults.csproj | 6 +- .../PlaygroundApp/Pages/HomePageTests.cs | 65 +++++++++++++++++++ 12 files changed, 122 insertions(+), 22 deletions(-) create mode 100644 test/AzureOpenAIProxy.AppHost.Tests/PlaygroundApp/Pages/HomePageTests.cs diff --git a/.github/workflows/azure-dev-build-only.yml b/.github/workflows/azure-dev-build-only.yml index 74445c59..b0048536 100644 --- a/.github/workflows/azure-dev-build-only.yml +++ b/.github/workflows/azure-dev-build-only.yml @@ -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() }} diff --git a/.github/workflows/azure-dev.yml b/.github/workflows/azure-dev.yml index 9f93296b..2217c6aa 100644 --- a/.github/workflows/azure-dev.yml +++ b/.github/workflows/azure-dev.yml @@ -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 diff --git a/Directory.Build.props b/Directory.Build.props index 7236a166..a3531f4c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,6 +15,7 @@ 1.* 1.* 6.* + 4.* 6.* 6.* diff --git a/src/AzureOpenAIProxy.ApiApp/AzureOpenAIProxy.ApiApp.csproj b/src/AzureOpenAIProxy.ApiApp/AzureOpenAIProxy.ApiApp.csproj index 7e65d79c..92c1aae3 100644 --- a/src/AzureOpenAIProxy.ApiApp/AzureOpenAIProxy.ApiApp.csproj +++ b/src/AzureOpenAIProxy.ApiApp/AzureOpenAIProxy.ApiApp.csproj @@ -1,10 +1,6 @@ - net8.0 - enable - enable - AzureOpenAIProxy.ApiApp AzureOpenAIProxy.ApiApp diff --git a/src/AzureOpenAIProxy.AppHost/AzureOpenAIProxy.AppHost.csproj b/src/AzureOpenAIProxy.AppHost/AzureOpenAIProxy.AppHost.csproj index 42926f2d..e75fe621 100644 --- a/src/AzureOpenAIProxy.AppHost/AzureOpenAIProxy.AppHost.csproj +++ b/src/AzureOpenAIProxy.AppHost/AzureOpenAIProxy.AppHost.csproj @@ -2,11 +2,12 @@ Exe - net8.0 - enable - enable true + f6c81741-4dbe-4a07-86e3-83a42810f5ec + + AzureOpenAIProxy.AppHost + AzureOpenAIProxy.AppHost diff --git a/src/AzureOpenAIProxy.PlaygroundApp/AzureOpenAIProxy.PlaygroundApp.csproj b/src/AzureOpenAIProxy.PlaygroundApp/AzureOpenAIProxy.PlaygroundApp.csproj index eca1c41f..c9ffe317 100644 --- a/src/AzureOpenAIProxy.PlaygroundApp/AzureOpenAIProxy.PlaygroundApp.csproj +++ b/src/AzureOpenAIProxy.PlaygroundApp/AzureOpenAIProxy.PlaygroundApp.csproj @@ -1,17 +1,15 @@ - net8.0 - enable - enable - - AzureOpenAIProxy.PlaygroundApp AzureOpenAIProxy.PlaygroundApp + + + diff --git a/src/AzureOpenAIProxy.PlaygroundApp/Components/App.razor b/src/AzureOpenAIProxy.PlaygroundApp/Components/App.razor index 975b820e..6b73ab6b 100644 --- a/src/AzureOpenAIProxy.PlaygroundApp/Components/App.razor +++ b/src/AzureOpenAIProxy.PlaygroundApp/Components/App.razor @@ -8,6 +8,7 @@ + @@ -15,6 +16,7 @@ + diff --git a/src/AzureOpenAIProxy.PlaygroundApp/Components/Layout/MainLayout.razor b/src/AzureOpenAIProxy.PlaygroundApp/Components/Layout/MainLayout.razor index 5a24bb13..4836891f 100644 --- a/src/AzureOpenAIProxy.PlaygroundApp/Components/Layout/MainLayout.razor +++ b/src/AzureOpenAIProxy.PlaygroundApp/Components/Layout/MainLayout.razor @@ -21,3 +21,8 @@ Reload 🗙 + + + + + diff --git a/src/AzureOpenAIProxy.PlaygroundApp/Components/_Imports.razor b/src/AzureOpenAIProxy.PlaygroundApp/Components/_Imports.razor index f2637f09..e8aaa070 100644 --- a/src/AzureOpenAIProxy.PlaygroundApp/Components/_Imports.razor +++ b/src/AzureOpenAIProxy.PlaygroundApp/Components/_Imports.razor @@ -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 diff --git a/src/AzureOpenAIProxy.PlaygroundApp/Program.cs b/src/AzureOpenAIProxy.PlaygroundApp/Program.cs index 0481d2e2..a61639f7 100644 --- a/src/AzureOpenAIProxy.PlaygroundApp/Program.cs +++ b/src/AzureOpenAIProxy.PlaygroundApp/Program.cs @@ -1,5 +1,7 @@ using AzureOpenAIProxy.PlaygroundApp.Clients; +using Microsoft.FluentUI.AspNetCore.Components; + using App = AzureOpenAIProxy.PlaygroundApp.Components.App; var builder = WebApplication.CreateBuilder(args); @@ -10,6 +12,8 @@ builder.Services.AddRazorComponents() .AddInteractiveServerComponents(); +builder.Services.AddFluentUIComponents(); + builder.Services.AddScoped(); var app = builder.Build(); diff --git a/src/AzureOpenAIProxy.ServiceDefaults/AzureOpenAIProxy.ServiceDefaults.csproj b/src/AzureOpenAIProxy.ServiceDefaults/AzureOpenAIProxy.ServiceDefaults.csproj index 0a26159f..433b7cda 100644 --- a/src/AzureOpenAIProxy.ServiceDefaults/AzureOpenAIProxy.ServiceDefaults.csproj +++ b/src/AzureOpenAIProxy.ServiceDefaults/AzureOpenAIProxy.ServiceDefaults.csproj @@ -1,10 +1,10 @@ - net8.0 - enable - enable true + + AzureOpenAIProxy.ServiceDefaults + AzureOpenAIProxy.ServiceDefaults diff --git a/test/AzureOpenAIProxy.AppHost.Tests/PlaygroundApp/Pages/HomePageTests.cs b/test/AzureOpenAIProxy.AppHost.Tests/PlaygroundApp/Pages/HomePageTests.cs new file mode 100644 index 00000000..63bfcff1 --- /dev/null +++ b/test/AzureOpenAIProxy.AppHost.Tests/PlaygroundApp/Pages/HomePageTests.cs @@ -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 +{ + [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("
")] + 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); + } +}