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] Update main layout to show/hide the sidebar #254

Merged
merged 7 commits 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
13 changes: 10 additions & 3 deletions .github/workflows/azure-dev-build-only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
15 changes: 11 additions & 4 deletions .github/workflows/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 3 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
<OpenTelemetryExtensionsVersion>1.*</OpenTelemetryExtensionsVersion>
<OpenTelemetryInstrumentationVersion>1.*</OpenTelemetryInstrumentationVersion>
<SwashbuckleVersion>6.*</SwashbuckleVersion>
<SystemTextJsonVersion>8.*</SystemTextJsonVersion>
<FluentUIVersion>4.*</FluentUIVersion>

<CoverletVersion>6.*</CoverletVersion>
<FluentAssertionsVersion>6.*</FluentAssertionsVersion>
<MicrosoftTestSdkVersion>17.*</MicrosoftTestSdkVersion>
<NSubstituteVersion>5.*</NSubstituteVersion>
<SystemTextJsonVersion>8.*</SystemTextJsonVersion>
<NUnitVersion>4.*</NUnitVersion>
<PlaywrightVersion>1.*</PlaywrightVersion>
<XunitVersion>2.*</XunitVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
@inherits LayoutComponentBase

<div class="page">
<div class="sidebar">
<NavMenu />
</div>

<main>
<div class="top-row px-4">
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
@if (this._isAdmin == true)
{
<div class="sidebar">
<NavMenu />
</div>
}

<main>
<article class="content px-4">
@Body
</article>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Microsoft.AspNetCore.Components;

namespace AzureOpenAIProxy.PlaygroundApp.Components.Layout;

/// <summary>
/// This represents the layout component for the main layout.
/// </summary>
public partial class MainLayout : LayoutComponentBase
{
private bool _isAdmin;

/// <summary>
/// Injects the <see cref="NavigationManager"/> instance.
/// </summary>
[Inject]
private NavigationManager? NavMan { get; set; }

/// <inheritdoc />
protected override async Task OnInitializedAsync()
{
var path = new Uri(this.NavMan!.Uri).AbsolutePath;
this._isAdmin = path.StartsWith("/admin", StringComparison.CurrentCultureIgnoreCase);

await Task.CompletedTask;
}
}
9 changes: 0 additions & 9 deletions test/AzureOpenAIProxy.ApiApp.Tests/UnitTest1.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsPackable>false</IsPackable>
Expand All @@ -15,19 +15,20 @@
</PackageReference>
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftTestSdkVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)">
<PackageReference Include="Microsoft.Playwright.NUnit" Version="$(PlaywrightVersion)" />
<PackageReference Include="NUnit.Analyzers" Version="$(NUnitVersion)">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" Version="$(NUnitVersion)" />
</ItemGroup>

<ItemGroup>
<!--<ItemGroup>
<ProjectReference Include="..\..\src\AzureOpenAIProxy.PlaygroundApp\AzureOpenAIProxy.PlaygroundApp.csproj" />
</ItemGroup>
</ItemGroup>-->

<ItemGroup>
<Using Include="Xunit" />
<Using Include="NUnit.Framework" />
</ItemGroup>

</Project>
28 changes: 28 additions & 0 deletions test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/HomePageTests.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
9 changes: 0 additions & 9 deletions test/AzureOpenAIProxy.PlaygroundApp.Tests/UnitTest1.cs

This file was deleted.