diff --git a/.github/workflows/azure-dev-build-only.yml b/.github/workflows/azure-dev-build-only.yml index b0048536..fd15aa7f 100644 --- a/.github/workflows/azure-dev-build-only.yml +++ b/.github/workflows/azure-dev-build-only.yml @@ -53,11 +53,18 @@ jobs: run: | dotnet build + - name: Install playwright + shell: pwsh + run: | + $playwright = Get-ChildItem -File Microsoft.Playwright.dll -Path . -Recurse + $installer = "$($playwright[0].Directory.FullName)/playwright.ps1" + & "$installer" install + - name: Run unit tests shell: bash run: | - dotnet test ./test/AzureOpenAIProxy.AppHost.Tests --logger "trx" --collect:"XPlat Code Coverage" - dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests --logger "trx" --collect:"XPlat Code Coverage" + dotnet test ./test/AzureOpenAIProxy.AppHost.Tests --no-build --logger "trx" --collect:"XPlat Code Coverage" + dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests --no-build --logger "trx" --collect:"XPlat Code Coverage" - name: Run integration tests shell: bash @@ -68,7 +75,7 @@ jobs: sleep 30 - dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests --logger "trx" --collect:"XPlat Code Coverage" + dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests --no-build --logger "trx" --collect:"XPlat Code Coverage" kill $DOTNET_PID diff --git a/.github/workflows/azure-dev.yml b/.github/workflows/azure-dev.yml index 2217c6aa..25683217 100644 --- a/.github/workflows/azure-dev.yml +++ b/.github/workflows/azure-dev.yml @@ -65,13 +65,20 @@ jobs: - name: Build solution shell: bash run: | - dotnet build + dotnet build -c Release + + - name: Install playwright + shell: pwsh + run: | + $playwright = Get-ChildItem -File Microsoft.Playwright.dll -Path . -Recurse + $installer = "$($playwright[0].Directory.FullName)/playwright.ps1" + & "$installer" install - name: Run unit tests shell: bash run: | - dotnet test ./test/AzureOpenAIProxy.AppHost.Tests --logger "trx" --collect:"XPlat Code Coverage" - dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests --logger "trx" --collect:"XPlat Code Coverage" + dotnet test ./test/AzureOpenAIProxy.AppHost.Tests -c Release --no-build --logger "trx" --collect:"XPlat Code Coverage" + dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests -c Release --no-build --logger "trx" --collect:"XPlat Code Coverage" - name: Run integration tests shell: bash @@ -82,7 +89,7 @@ jobs: sleep 30 - dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests --logger "trx" --collect:"XPlat Code Coverage" + dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests -c Release --no-build --logger "trx" --collect:"XPlat Code Coverage" kill $DOTNET_PID diff --git a/Directory.Build.props b/Directory.Build.props index a3531f4c..e3377330 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -15,13 +15,15 @@ 1.* 1.* 6.* + 8.* 4.* 6.* 6.* 17.* 5.* - 8.* + 4.* + 1.* 2.* diff --git a/src/AzureOpenAIProxy.PlaygroundApp/Components/Layout/MainLayout.razor b/src/AzureOpenAIProxy.PlaygroundApp/Components/Layout/MainLayout.razor index 4836891f..1bad0f45 100644 --- a/src/AzureOpenAIProxy.PlaygroundApp/Components/Layout/MainLayout.razor +++ b/src/AzureOpenAIProxy.PlaygroundApp/Components/Layout/MainLayout.razor @@ -1,15 +1,14 @@ @inherits LayoutComponentBase
- - -
-
- About + @if (this._isAdmin == true) + { + + } +
@Body
diff --git a/src/AzureOpenAIProxy.PlaygroundApp/Components/Layout/MainLayout.razor.cs b/src/AzureOpenAIProxy.PlaygroundApp/Components/Layout/MainLayout.razor.cs new file mode 100644 index 00000000..4e40a58a --- /dev/null +++ b/src/AzureOpenAIProxy.PlaygroundApp/Components/Layout/MainLayout.razor.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Components; + +namespace AzureOpenAIProxy.PlaygroundApp.Components.Layout; + +/// +/// This represents the layout component for the main layout. +/// +public partial class MainLayout : LayoutComponentBase +{ + private bool _isAdmin; + + /// + /// Injects the instance. + /// + [Inject] + private NavigationManager? NavMan { get; set; } + + /// + protected override async Task OnInitializedAsync() + { + var path = new Uri(this.NavMan!.Uri).AbsolutePath; + this._isAdmin = path.StartsWith("/admin", StringComparison.CurrentCultureIgnoreCase); + + await Task.CompletedTask; + } +} diff --git a/test/AzureOpenAIProxy.ApiApp.Tests/UnitTest1.cs b/test/AzureOpenAIProxy.ApiApp.Tests/UnitTest1.cs deleted file mode 100644 index 924359ec..00000000 --- a/test/AzureOpenAIProxy.ApiApp.Tests/UnitTest1.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace AzureOpenAIProxy.ApiApp.Tests; - -public class UnitTest1 -{ - [Fact] - public void Test1() - { - } -} diff --git a/test/AzureOpenAIProxy.PlaygroundApp.Tests/AzureOpenAIProxy.PlaygroundApp.Tests.csproj b/test/AzureOpenAIProxy.PlaygroundApp.Tests/AzureOpenAIProxy.PlaygroundApp.Tests.csproj index 1a9f53fe..0b9dccf2 100644 --- a/test/AzureOpenAIProxy.PlaygroundApp.Tests/AzureOpenAIProxy.PlaygroundApp.Tests.csproj +++ b/test/AzureOpenAIProxy.PlaygroundApp.Tests/AzureOpenAIProxy.PlaygroundApp.Tests.csproj @@ -1,4 +1,4 @@ - + false @@ -15,19 +15,20 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive + - + - + diff --git a/test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/HomePageTests.cs b/test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/HomePageTests.cs new file mode 100644 index 00000000..aad307da --- /dev/null +++ b/test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/HomePageTests.cs @@ -0,0 +1,28 @@ +using Microsoft.Playwright; +using Microsoft.Playwright.NUnit; + +namespace AzureOpenAIProxy.PlaygroundApp.Tests.Pages; + +[Parallelizable(ParallelScope.Self)] +[TestFixture] +[Property("Category", "Integration")] +public class HomePageTests : PageTest +{ + public override BrowserNewContextOptions ContextOptions() => new() + { + IgnoreHTTPSErrors = true, + }; + + [Test] + public async Task Given_Root_Page_When_Navigated_Then_It_Should_No_Sidebar() + { + // Arrange + await this.Page.GotoAsync("https://localhost:5001"); + + // Act + var sidebar = this.Page.Locator("div.sidebar"); + + // Assert + Expect(sidebar).Equals(null); + } +} diff --git a/test/AzureOpenAIProxy.PlaygroundApp.Tests/UnitTest1.cs b/test/AzureOpenAIProxy.PlaygroundApp.Tests/UnitTest1.cs deleted file mode 100644 index 63e32861..00000000 --- a/test/AzureOpenAIProxy.PlaygroundApp.Tests/UnitTest1.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace AzureOpenAIProxy.PlaygroundApp.Tests; - -public class UnitTest1 -{ - [Fact] - public void Test1() - { - } -}