Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
205e71a
Implement EventItemComponent
Capella87 Sep 5, 2024
6425fd7
Implement EventListComponent
Capella87 Sep 5, 2024
be3a325
Add EventList page
Capella87 Sep 5, 2024
6ac59a4
Fix flex align problem and replace nested div to FluentCard
Capella87 Sep 6, 2024
b6a05a7
Add CSS configurations on EventItemComponent
Capella87 Sep 7, 2024
6fa4861
Adjust padding of EventListComponent
Capella87 Sep 7, 2024
a046218
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 Sep 7, 2024
4c06e76
Add comment on EventList page
Capella87 Sep 7, 2024
edae80c
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 Sep 7, 2024
86e4e60
Rename EventList to Events
Capella87 Sep 7, 2024
1644e0b
Integrate model, Add Id, Alignments
Capella87 Sep 7, 2024
7711baf
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 Sep 7, 2024
32528f6
Add progress ring during loading in EventListComponent
Capella87 Sep 8, 2024
e3085f2
Use parameter Id to FluentGrid's Id
Capella87 Sep 8, 2024
a0c6a18
Implement test methods for Event components
Capella87 Sep 8, 2024
3ed727f
Show a message when there are no events user joined
Capella87 Sep 8, 2024
adb09f7
Adjust EventItemComponent padding
Capella87 Sep 8, 2024
16c4eb6
Add tests for Events page in AppHost testing project
Capella87 Sep 8, 2024
f6e6bc0
Revert launchSettings.json
Capella87 Sep 11, 2024
64bf310
Remove redundant references, Make properties nullable
Capella87 Sep 11, 2024
905def8
Remove SetParametersAsync at EventItemComponent
Capella87 Sep 11, 2024
386c84a
Re-order methods by access modifiers priority
Capella87 Sep 11, 2024
d055178
Revert launchSettings.json with the final new line
Capella87 Sep 13, 2024
ac9554c
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 Sep 13, 2024
0fef5c7
Add async to NavigateToEventDetails
Capella87 Sep 13, 2024
cec6ff7
Sort entities in code behind by common .NET coding convention
Capella87 Sep 13, 2024
7fd9838
Rename events-list to event-list
Capella87 Sep 13, 2024
265cae5
Refactor no-events card with FluentCard
Capella87 Sep 13, 2024
99e7989
Replace event title element to FluentLabel
Capella87 Sep 14, 2024
3b1684e
Implement event link with FluentNavLink
Capella87 Sep 14, 2024
186ec85
Relocate OnInitializedAsync
Capella87 Sep 14, 2024
8af71f2
Remove progress ring
Capella87 Sep 14, 2024
585d7c5
Make color follow Fluent UI neutral layer color
Capella87 Sep 14, 2024
9dbeb51
Add id attributes on sub-elements in event cards
Capella87 Sep 14, 2024
b2f6cdd
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 Sep 19, 2024
10b8e0c
Rename _events to events, Add getting up to 4 events prior to the sho…
Capella87 Sep 19, 2024
9cb142b
Remove redundant null initialization in EventListComponent
Capella87 Sep 19, 2024
3b2c172
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 Sep 20, 2024
46e7732
Integrate linq code to foreach
Capella87 Sep 20, 2024
d00f0d5
Integrate no-events item to EventItemComponent and adjust breakpoints
Capella87 Sep 22, 2024
1abefd0
Remove breakpoint parameter, update grid's justification to center
Capella87 Sep 23, 2024
c6bcb4f
Adjust breakpoint for desktop size
Capella87 Sep 23, 2024
a985b07
Fix FluentCard's class name
Capella87 Sep 23, 2024
c1f121f
Add new tests dedicated to EventItemComponent
Capella87 Sep 23, 2024
3645a95
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 Sep 23, 2024
9012642
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 Oct 2, 2024
8441c3e
Update grid's justify to FlexStart
Capella87 Oct 2, 2024
9c31f67
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 Oct 3, 2024
8e692f2
Remove EventListComponent Id
Capella87 Oct 5, 2024
0ed7552
Add HasNoEvent parameter for EventItemComponent
Capella87 Oct 5, 2024
b0098eb
Move grid's style code to a dedicated CSS file
Capella87 Oct 5, 2024
35c3465
Restore EventListComponent's Id parameter and change its parameter na…
Capella87 Oct 5, 2024
a16bc5a
Separate CSS code for EventItemComponent to its own CSS file
Capella87 Oct 7, 2024
fa81259
Refactor EventsPageTests for CSS isolation work
Capella87 Oct 7, 2024
ca3ef52
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 Oct 7, 2024
299ad97
Prune redundant CSS configurations
Capella87 Oct 7, 2024
c5618a8
Integrate more CSS properties
Capella87 Oct 7, 2024
7c75476
Add title in Events component page
Capella87 Oct 7, 2024
0b25728
Adjust margin properties to prevent hiding the focus square
Capella87 Oct 7, 2024
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
10 changes: 10 additions & 0 deletions src/AzureOpenAIProxy.PlaygroundApp/Components/Pages/Events.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@page "/events"

<PageTitle>Events</PageTitle>

<p>This component demonstrates showing up to 4 events that user joined.</p>

<EventListComponent Id="event-list" @rendermode="InteractiveServer" />

@code {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<FluentGridItem Id="@Id" xs="12" sm="6" Justify="JustifyContent.Center" Style="text-align: center;">
<FluentCard Id="event-title" Style="flex-grow: 1; padding: 0em; display: flex; flex-direction: column; align-items: normal;">
<FluentNavLink Id="eventdetails-link" Href="@($"/events/{Id}")" Style="flex-grow: 0; align-self: center;">
<FluentLabel Typo="Typography.PaneHeader" Style="margin-block: 0.5em;">
@Title
</FluentLabel>
</FluentNavLink>
<div id="event-summary" class="card border" style="background-color: var(--neutral-layer-2); padding: 1em; padding-inline: 1.5em; flex-grow: 1">
<div class="card-body">
<h5>@Summary</h5>
</div>
</div>
</FluentCard>
</FluentGridItem>

@code {
[Parameter]
public string? Id { get; set; }

[Parameter]
public string? Title { get; set; }

[Parameter]
public string? Summary { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
@using AzureOpenAIProxy.PlaygroundApp.Models;

<FluentGrid AdaptiveRendering="true"
Id="@Id"
Spacing="3"
Justify="JustifyContent.FlexStart"
Style="background-color: var(--neutral-layer-4);
padding-block: 1.5em;
padding-inline: 1.0em; align-items: center; margin-top: 18px; border-radius: 8px;">

@if (events == null || events.Any() == false)
{
<FluentGridItem Id="no-events" xs="12" sm="12" Justify="JustifyContent.Center" Style="text-align: center; flex-grow: 1;">
<FluentCard MinimalStyle="true" Style="flex-grow: 1; background-color: var(--neutral-layer-2); display: flex; padding: 0em; flex-direction: row; align-items: center; align-content: center; justify-content: center; background-color: transparent; box-shadow: none !important; border: hidden;">
<FluentLabel Typo="Typography.Header">You don’t have any events you have participated in now.</FluentLabel>
</FluentCard>
</FluentGridItem>
}
else
{
// Shows up to 4 events that the user currently joined.
var entries = events.Take(4);
@foreach (var e in entries)
{
<EventItemComponent Id="@e.EventId.ToString()"
Title="@e.Title"
Summary="@e.Summary">
</EventItemComponent>
}
}
</FluentGrid>

@code {
private List<EventDetails>? events;

[Parameter]
public string? Id { get; set; }

protected override async Task OnInitializedAsync()
{
// TODO: Fetch events from the API server.
events = await CreateEventDetailsAsync();
}

private async Task<List<EventDetails>> CreateEventDetailsAsync()
{
return await Task.FromResult(new List<EventDetails>
{
new EventDetails
{
EventId = Guid.NewGuid(),
Title = "Event 1",
Summary = "Summary 1",
MaxTokenCap = 1000,
DailyRequestCap = 100
},
new EventDetails
{
EventId = Guid.NewGuid(),
Title = "Event 2",
Summary = "Et iusto clita ipsum et. Amet lorem est lorem takimata et aliquyam. Aliquyam invidunt dolor erat eu sed ut sadipscing justo sed justo amet magna ea lorem ipsum exerci. Erat diam tempor imperdiet lorem duis. Amet est sanctus tempor kasd erat odio diam accumsan stet. Voluptua aliquyam magna at no vulputate justo labore labore eos stet. Dolore ut ad sadipscing sit elitr ipsum commodo nam invidunt wisi labore vero feugait sanctus sea ad et sadipscing. Possim tempor nonummy erat et no erat lorem in dolore consequat eos feugiat justo vero. Ut eirmod et duis accusam dolore est sea duis dolor et duis illum. Esse ut aliquyam placerat enim amet et labore sadipscing sed stet duo eos at consequat autem accusam lorem invidunt. Sea clita rebum eum et no dolore et sit. Liber aliquyam duo eu. Feugiat sadipscing sed eos sanctus gubergren dolore amet. Erat liber nam ea aliquam ut autem dolores magna aliquyam illum vero vulputate ut accusam est rebum. Et takimata est dolore ut elitr gubergren sanctus ipsum magna magna at sed amet dolores amet. Rebum dolore sit ea et gubergren. Dolore aliquam ipsum in at est justo justo ipsum. Ipsum nisl sea lorem.",
MaxTokenCap = 2000,
DailyRequestCap = 200,
},
new EventDetails
{
EventId = Guid.NewGuid(),
Title = "Event 3",
Summary = "Lorem ipsum dolor sit amet stet ipsum invidunt amet invidunt magna vero delenit tempor invidunt no rebum eirmod. Duo labore eu no nonumy consequat lobortis consequat consetetur ipsum et ipsum ea eirmod esse. Eirmod rebum voluptua duo et autem eirmod vero amet dolores tincidunt lorem ipsum stet dolore sed aliquyam nonumy consetetur. Rebum no invidunt justo consetetur gubergren sea luptatum ut et amet ut aliquyam lorem ipsum. Nonummy et dolor placerat sit hendrerit invidunt. Et est dolore magna et suscipit duo aliquyam sed dolore ipsum erat nonummy eirmod. Nonummy consequat et et et accusam hendrerit et dolor et. Sanctus gubergren elitr sit takimata accusam lobortis quod sit nonumy nonumy diam clita clita. Ea takimata dolor molestie duo tempor invidunt amet nobis lorem accumsan duo rebum diam ipsum dolores erat ea. Amet nulla eirmod takimata no vel in et sea lobortis ut ullamcorper sadipscing delenit duo takimata ipsum eos consectetuer. Et et ea no duis eu labore quod ipsum feugiat esse lorem clita et nibh iriure diam magna. Sit duis tempor dolore sed et no magna et dolor labore clita erat sed dolores accusam molestie clita. Quis amet eum sit magna kasd eu invidunt nihil. Labore diam erat dignissim labore ipsum qui clita vel eos. Nisl praesent amet consequat ipsum justo quod tempor sed est aliquyam labore lorem accusam diam.",
MaxTokenCap = 3000,
DailyRequestCap = 300,
},
new EventDetails
{
EventId = Guid.NewGuid(),
Title = "Event 4",
Summary = "Summary 4",
MaxTokenCap = 3000,
DailyRequestCap = 300,
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System.Net;

using AzureOpenAIProxy.AppHost.Tests.Fixtures;

using FluentAssertions;

namespace AzureOpenAIProxy.AppHost.Tests.PlaygroundApp.Pages;

public class EventsPageTests(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");
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));

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

// 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");
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));

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

// 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");
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));

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

// 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");
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));

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

// Assert
html.Should().Contain(expected);
}
}
54 changes: 54 additions & 0 deletions test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/EventsPageTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using FluentAssertions;

using Microsoft.Playwright;
using Microsoft.Playwright.NUnit;

namespace AzureOpenAIProxy.PlaygroundApp.Tests.Pages;

[Parallelizable(ParallelScope.Self)]
[TestFixture]
[Property("Category", "Integration")]
public class EventsPageTests : PageTest
{
public override BrowserNewContextOptions ContextOptions() => new()
{
IgnoreHTTPSErrors = true,
};

[SetUp]
public async Task Init()
{
await Page.GotoAsync("https://localhost:5001/events");
await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
}

// Grid check
[Test]
public async Task Given_Events_Page_When_Navigated_Then_It_Should_Have_EventListComponent()
{
// Act
var eventListComponent = await Page.QuerySelectorAsync("#event-list");

// Assert
eventListComponent.Should().NotBeNull();
}

[Test]
public async Task Given_Events_When_Loaded_Then_It_Should_Have_Less_Than_Or_Equal_To_Four_EventItemComponents()
{
// Act
var availableEvents = await Page.QuerySelectorAsync("#event-list");

var childrenCount = await availableEvents.EvaluateAsync<int>("elist => elist.children.length");

Check warning on line 42 in test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/EventsPageTests.cs

View workflow job for this annotation

GitHub Actions / build-test

Dereference of a possibly null reference.

Check warning on line 42 in test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/EventsPageTests.cs

View workflow job for this annotation

GitHub Actions / build-test

Dereference of a possibly null reference.

// Assert
Assert.That(childrenCount, Is.GreaterThan(0));
Assert.That(childrenCount, Is.LessThanOrEqualTo(4));
}

[TearDown]
public async Task CleanUp()
{
await Page.CloseAsync();
}
}
Loading