-
Notifications
You must be signed in to change notification settings - Fork 18
[Playground] Add Events components #311
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
Merged
Merged
Changes from 37 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
205e71a
Implement EventItemComponent
Capella87 6425fd7
Implement EventListComponent
Capella87 be3a325
Add EventList page
Capella87 6ac59a4
Fix flex align problem and replace nested div to FluentCard
Capella87 b6a05a7
Add CSS configurations on EventItemComponent
Capella87 6fa4861
Adjust padding of EventListComponent
Capella87 a046218
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 4c06e76
Add comment on EventList page
Capella87 edae80c
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 86e4e60
Rename EventList to Events
Capella87 1644e0b
Integrate model, Add Id, Alignments
Capella87 7711baf
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 32528f6
Add progress ring during loading in EventListComponent
Capella87 e3085f2
Use parameter Id to FluentGrid's Id
Capella87 a0c6a18
Implement test methods for Event components
Capella87 3ed727f
Show a message when there are no events user joined
Capella87 adb09f7
Adjust EventItemComponent padding
Capella87 16c4eb6
Add tests for Events page in AppHost testing project
Capella87 f6e6bc0
Revert launchSettings.json
Capella87 64bf310
Remove redundant references, Make properties nullable
Capella87 905def8
Remove SetParametersAsync at EventItemComponent
Capella87 386c84a
Re-order methods by access modifiers priority
Capella87 d055178
Revert launchSettings.json with the final new line
Capella87 ac9554c
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 0fef5c7
Add async to NavigateToEventDetails
Capella87 cec6ff7
Sort entities in code behind by common .NET coding convention
Capella87 7fd9838
Rename events-list to event-list
Capella87 265cae5
Refactor no-events card with FluentCard
Capella87 99e7989
Replace event title element to FluentLabel
Capella87 3b1684e
Implement event link with FluentNavLink
Capella87 186ec85
Relocate OnInitializedAsync
Capella87 8af71f2
Remove progress ring
Capella87 585d7c5
Make color follow Fluent UI neutral layer color
Capella87 9dbeb51
Add id attributes on sub-elements in event cards
Capella87 b2f6cdd
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 10b8e0c
Rename _events to events, Add getting up to 4 events prior to the sho…
Capella87 9cb142b
Remove redundant null initialization in EventListComponent
Capella87 3b2c172
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 46e7732
Integrate linq code to foreach
Capella87 d00f0d5
Integrate no-events item to EventItemComponent and adjust breakpoints
Capella87 1abefd0
Remove breakpoint parameter, update grid's justification to center
Capella87 c6bcb4f
Adjust breakpoint for desktop size
Capella87 a985b07
Fix FluentCard's class name
Capella87 c1f121f
Add new tests dedicated to EventItemComponent
Capella87 3645a95
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 9012642
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 8441c3e
Update grid's justify to FlexStart
Capella87 9c31f67
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 8e692f2
Remove EventListComponent Id
Capella87 0ed7552
Add HasNoEvent parameter for EventItemComponent
Capella87 b0098eb
Move grid's style code to a dedicated CSS file
Capella87 35c3465
Restore EventListComponent's Id parameter and change its parameter na…
Capella87 a16bc5a
Separate CSS code for EventItemComponent to its own CSS file
Capella87 fa81259
Refactor EventsPageTests for CSS isolation work
Capella87 ca3ef52
Merge branch 'main' of github.com:aliencube/azure-openai-sdk-proxy in…
Capella87 299ad97
Prune redundant CSS configurations
Capella87 c5618a8
Integrate more CSS properties
Capella87 7c75476
Add title in Events component page
Capella87 0b25728
Adjust margin properties to prevent hiding the focus square
Capella87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/AzureOpenAIProxy.PlaygroundApp/Components/Pages/Events.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { | ||
| } |
25 changes: 25 additions & 0 deletions
25
src/AzureOpenAIProxy.PlaygroundApp/Components/UI/EventItemComponent.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; } | ||
justinyoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
83 changes: 83 additions & 0 deletions
83
src/AzureOpenAIProxy.PlaygroundApp/Components/UI/EventListComponent.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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;"> | ||
justinyoo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| @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> | ||
justinyoo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| else | ||
| { | ||
| // Shows up to 4 events that the user currently joined. | ||
| var entries = events.Take(4); | ||
justinyoo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| @foreach (var e in entries) | ||
justinyoo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| <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, | ||
| } | ||
| }); | ||
| } | ||
justinyoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
69 changes: 69 additions & 0 deletions
69
test/AzureOpenAIProxy.AppHost.Tests/PlaygroundApp/Pages/EventsPageTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
54
test/AzureOpenAIProxy.PlaygroundApp.Tests/Pages/EventsPageTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
|
||
|
|
||
| // Assert | ||
| Assert.That(childrenCount, Is.GreaterThan(0)); | ||
| Assert.That(childrenCount, Is.LessThanOrEqualTo(4)); | ||
| } | ||
|
|
||
| [TearDown] | ||
| public async Task CleanUp() | ||
| { | ||
| await Page.CloseAsync(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.