Skip to content

Commit ed1e262

Browse files
authored
Update main layout to show/hide the sidebar (#254)
1 parent 919c4ae commit ed1e262

File tree

9 files changed

+91
-39
lines changed

9 files changed

+91
-39
lines changed

.github/workflows/azure-dev-build-only.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,18 @@ jobs:
5353
run: |
5454
dotnet build
5555
56+
- name: Install playwright
57+
shell: pwsh
58+
run: |
59+
$playwright = Get-ChildItem -File Microsoft.Playwright.dll -Path . -Recurse
60+
$installer = "$($playwright[0].Directory.FullName)/playwright.ps1"
61+
& "$installer" install
62+
5663
- name: Run unit tests
5764
shell: bash
5865
run: |
59-
dotnet test ./test/AzureOpenAIProxy.AppHost.Tests --logger "trx" --collect:"XPlat Code Coverage"
60-
dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests --logger "trx" --collect:"XPlat Code Coverage"
66+
dotnet test ./test/AzureOpenAIProxy.AppHost.Tests --no-build --logger "trx" --collect:"XPlat Code Coverage"
67+
dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests --no-build --logger "trx" --collect:"XPlat Code Coverage"
6168
6269
- name: Run integration tests
6370
shell: bash
@@ -68,7 +75,7 @@ jobs:
6875
6976
sleep 30
7077
71-
dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests --logger "trx" --collect:"XPlat Code Coverage"
78+
dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests --no-build --logger "trx" --collect:"XPlat Code Coverage"
7279
7380
kill $DOTNET_PID
7481

.github/workflows/azure-dev.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,20 @@ jobs:
6565
- name: Build solution
6666
shell: bash
6767
run: |
68-
dotnet build
68+
dotnet build -c Release
69+
70+
- name: Install playwright
71+
shell: pwsh
72+
run: |
73+
$playwright = Get-ChildItem -File Microsoft.Playwright.dll -Path . -Recurse
74+
$installer = "$($playwright[0].Directory.FullName)/playwright.ps1"
75+
& "$installer" install
6976
7077
- name: Run unit tests
7178
shell: bash
7279
run: |
73-
dotnet test ./test/AzureOpenAIProxy.AppHost.Tests --logger "trx" --collect:"XPlat Code Coverage"
74-
dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests --logger "trx" --collect:"XPlat Code Coverage"
80+
dotnet test ./test/AzureOpenAIProxy.AppHost.Tests -c Release --no-build --logger "trx" --collect:"XPlat Code Coverage"
81+
dotnet test ./test/AzureOpenAIProxy.ApiApp.Tests -c Release --no-build --logger "trx" --collect:"XPlat Code Coverage"
7582
7683
- name: Run integration tests
7784
shell: bash
@@ -82,7 +89,7 @@ jobs:
8289
8390
sleep 30
8491
85-
dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests --logger "trx" --collect:"XPlat Code Coverage"
92+
dotnet test ./test/AzureOpenAIProxy.PlaygroundApp.Tests -c Release --no-build --logger "trx" --collect:"XPlat Code Coverage"
8693
8794
kill $DOTNET_PID
8895

Directory.Build.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
<OpenTelemetryExtensionsVersion>1.*</OpenTelemetryExtensionsVersion>
1616
<OpenTelemetryInstrumentationVersion>1.*</OpenTelemetryInstrumentationVersion>
1717
<SwashbuckleVersion>6.*</SwashbuckleVersion>
18+
<SystemTextJsonVersion>8.*</SystemTextJsonVersion>
1819
<FluentUIVersion>4.*</FluentUIVersion>
1920

2021
<CoverletVersion>6.*</CoverletVersion>
2122
<FluentAssertionsVersion>6.*</FluentAssertionsVersion>
2223
<MicrosoftTestSdkVersion>17.*</MicrosoftTestSdkVersion>
2324
<NSubstituteVersion>5.*</NSubstituteVersion>
24-
<SystemTextJsonVersion>8.*</SystemTextJsonVersion>
25+
<NUnitVersion>4.*</NUnitVersion>
26+
<PlaywrightVersion>1.*</PlaywrightVersion>
2527
<XunitVersion>2.*</XunitVersion>
2628
</PropertyGroup>
2729
</Project>

src/AzureOpenAIProxy.PlaygroundApp/Components/Layout/MainLayout.razor

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
@inherits LayoutComponentBase
22

33
<div class="page">
4-
<div class="sidebar">
5-
<NavMenu />
6-
</div>
7-
8-
<main>
9-
<div class="top-row px-4">
10-
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
4+
@if (this._isAdmin == true)
5+
{
6+
<div class="sidebar">
7+
<NavMenu />
118
</div>
9+
}
1210

11+
<main>
1312
<article class="content px-4">
1413
@Body
1514
</article>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.AspNetCore.Components;
2+
3+
namespace AzureOpenAIProxy.PlaygroundApp.Components.Layout;
4+
5+
/// <summary>
6+
/// This represents the layout component for the main layout.
7+
/// </summary>
8+
public partial class MainLayout : LayoutComponentBase
9+
{
10+
private bool _isAdmin;
11+
12+
/// <summary>
13+
/// Injects the <see cref="NavigationManager"/> instance.
14+
/// </summary>
15+
[Inject]
16+
private NavigationManager? NavMan { get; set; }
17+
18+
/// <inheritdoc />
19+
protected override async Task OnInitializedAsync()
20+
{
21+
var path = new Uri(this.NavMan!.Uri).AbsolutePath;
22+
this._isAdmin = path.StartsWith("/admin", StringComparison.CurrentCultureIgnoreCase);
23+
24+
await Task.CompletedTask;
25+
}
26+
}

test/AzureOpenAIProxy.ApiApp.Tests/UnitTest1.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/AzureOpenAIProxy.PlaygroundApp.Tests/AzureOpenAIProxy.PlaygroundApp.Tests.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<IsPackable>false</IsPackable>
@@ -15,19 +15,20 @@
1515
</PackageReference>
1616
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
1717
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftTestSdkVersion)" />
18-
<PackageReference Include="xunit" Version="$(XunitVersion)" />
19-
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)">
18+
<PackageReference Include="Microsoft.Playwright.NUnit" Version="$(PlaywrightVersion)" />
19+
<PackageReference Include="NUnit.Analyzers" Version="$(NUnitVersion)">
2020
<PrivateAssets>all</PrivateAssets>
2121
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2222
</PackageReference>
23+
<PackageReference Include="NUnit3TestAdapter" Version="$(NUnitVersion)" />
2324
</ItemGroup>
2425

25-
<ItemGroup>
26+
<!--<ItemGroup>
2627
<ProjectReference Include="..\..\src\AzureOpenAIProxy.PlaygroundApp\AzureOpenAIProxy.PlaygroundApp.csproj" />
27-
</ItemGroup>
28+
</ItemGroup>-->
2829

2930
<ItemGroup>
30-
<Using Include="Xunit" />
31+
<Using Include="NUnit.Framework" />
3132
</ItemGroup>
3233

3334
</Project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Microsoft.Playwright;
2+
using Microsoft.Playwright.NUnit;
3+
4+
namespace AzureOpenAIProxy.PlaygroundApp.Tests.Pages;
5+
6+
[Parallelizable(ParallelScope.Self)]
7+
[TestFixture]
8+
[Property("Category", "Integration")]
9+
public class HomePageTests : PageTest
10+
{
11+
public override BrowserNewContextOptions ContextOptions() => new()
12+
{
13+
IgnoreHTTPSErrors = true,
14+
};
15+
16+
[Test]
17+
public async Task Given_Root_Page_When_Navigated_Then_It_Should_No_Sidebar()
18+
{
19+
// Arrange
20+
await this.Page.GotoAsync("https://localhost:5001");
21+
22+
// Act
23+
var sidebar = this.Page.Locator("div.sidebar");
24+
25+
// Assert
26+
Expect(sidebar).Equals(null);
27+
}
28+
}

test/AzureOpenAIProxy.PlaygroundApp.Tests/UnitTest1.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)