Skip to content

Commit 421e073

Browse files
authored
Add new event page (#296)
1 parent 43ed061 commit 421e073

File tree

5 files changed

+143
-1
lines changed

5 files changed

+143
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@page "/admin/events/new"
2+
3+
<PageTitle>New event</PageTitle>
4+
5+
<h1>New event</h1>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using System.Net;
2+
3+
using AzureOpenAIProxy.AppHost.Tests.Fixtures;
4+
5+
using FluentAssertions;
6+
7+
namespace AzureOpenAIProxy.AppHost.Tests.PlaygroundApp.Pages;
8+
9+
public class AdminNewEventPageTests(AspireAppHostFixture host) : IClassFixture<AspireAppHostFixture>
10+
{
11+
[Fact]
12+
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_OK()
13+
{
14+
// Arrange
15+
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
16+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
17+
18+
// Act
19+
var response = await httpClient.GetAsync("/admin/events/new");
20+
21+
// Assert
22+
response.StatusCode.Should().Be(HttpStatusCode.OK);
23+
}
24+
25+
[Theory]
26+
[InlineData("_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css")]
27+
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_CSS_Elements(string expected)
28+
{
29+
// Arrange
30+
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
31+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
32+
33+
// Act
34+
var html = await httpClient.GetStringAsync("/admin/events/new");
35+
36+
// Assert
37+
html.Should().Contain(expected);
38+
}
39+
40+
[Theory]
41+
[InlineData("_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.lib.module.js")]
42+
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_JavaScript_Elements(string expected)
43+
{
44+
// Arrange
45+
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
46+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
47+
48+
// Act
49+
var html = await httpClient.GetStringAsync("/admin/events/new");
50+
51+
// Assert
52+
html.Should().Contain(expected);
53+
}
54+
55+
[Theory]
56+
[InlineData("<div class=\"fluent-tooltip-provider\"></div>")]
57+
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_HTML_Elements(string expected)
58+
{
59+
// Arrange
60+
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
61+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
62+
63+
// Act
64+
var html = await httpClient.GetStringAsync("/admin/events/new");
65+
66+
// Assert
67+
html.Should().Contain(expected);
68+
}
69+
}

test/AzureOpenAIProxy.AppHost.Tests/PlaygroundApp/Pages/AdminPageTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using FluentAssertions;
66

77
namespace AzureOpenAIProxy.AppHost.Tests.PlaygroundApp.Pages;
8+
89
public class AdminPageTests(AspireAppHostFixture host) : IClassFixture<AspireAppHostFixture>
910
{
1011
[Fact]
@@ -21,12 +22,28 @@ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_OK(
2122
response.StatusCode.Should().Be(HttpStatusCode.OK);
2223
}
2324

25+
[Theory]
26+
[InlineData("_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css")]
27+
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_CSS_Elements(string expected)
28+
{
29+
// Arrange
30+
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
31+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
32+
33+
// Act
34+
var html = await httpClient.GetStringAsync("/admin");
35+
36+
// Assert
37+
html.Should().Contain(expected);
38+
}
39+
2440
[Theory]
2541
[InlineData("_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.lib.module.js")]
2642
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_JavaScript_Elements(string expected)
2743
{
2844
// Arrange
2945
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
46+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
3047

3148
// Act
3249
var html = await httpClient.GetStringAsync("/admin");
@@ -41,6 +58,7 @@ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_HTM
4158
{
4259
// Arrange
4360
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
61+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
4462

4563
// Act
4664
var html = await httpClient.GetStringAsync("/admin");

test/AzureOpenAIProxy.AppHost.Tests/PlaygroundApp/Pages/HomePageTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_CSS
2828
{
2929
// Arrange
3030
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
31+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
3132

3233
// Act
3334
var html = await httpClient.GetStringAsync("/");
@@ -42,6 +43,7 @@ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Jav
4243
{
4344
// Arrange
4445
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
46+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
4547

4648
// Act
4749
var html = await httpClient.GetStringAsync("/");
@@ -56,6 +58,7 @@ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_HTM
5658
{
5759
// Arrange
5860
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
61+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
5962

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

test/AzureOpenAIProxy.AppHost.Tests/PlaygroundApp/Pages/PlaygroundPageTests.cs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using AzureOpenAIProxy.AppHost.Tests.Fixtures;
22

3+
using FluentAssertions;
4+
35
namespace AzureOpenAIProxy.AppHost.Tests.PlaygroundApp.Pages;
46

57
public class PlaygroundPageTests(AspireAppHostFixture host) : IClassFixture<AspireAppHostFixture>
@@ -15,6 +17,51 @@ public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_OK(
1517
var response = await httpClient.GetAsync("/playground");
1618

1719
// Assert
18-
response.EnsureSuccessStatusCode(); // Status Code 200-299
20+
response.EnsureSuccessStatusCode();
21+
}
22+
23+
[Theory]
24+
[InlineData("_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css")]
25+
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_CSS_Elements(string expected)
26+
{
27+
// Arrange
28+
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
29+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
30+
31+
// Act
32+
var html = await httpClient.GetStringAsync("/playground");
33+
34+
// Assert
35+
html.Should().Contain(expected);
36+
}
37+
38+
[Theory]
39+
[InlineData("_content/Microsoft.FluentUI.AspNetCore.Components/Microsoft.FluentUI.AspNetCore.Components.lib.module.js")]
40+
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_JavaScript_Elements(string expected)
41+
{
42+
// Arrange
43+
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
44+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
45+
46+
// Act
47+
var html = await httpClient.GetStringAsync("/playground");
48+
49+
// Assert
50+
html.Should().Contain(expected);
51+
}
52+
53+
[Theory]
54+
[InlineData("<div class=\"fluent-tooltip-provider\"></div>")]
55+
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_HTML_Elements(string expected)
56+
{
57+
// Arrange
58+
using var httpClient = host.App!.CreateHttpClient("playgroundapp");
59+
await host.ResourceNotificationService.WaitForResourceAsync("playgroundapp", KnownResourceStates.Running).WaitAsync(TimeSpan.FromSeconds(30));
60+
61+
// Act
62+
var html = await httpClient.GetStringAsync("/playground");
63+
64+
// Assert
65+
html.Should().Contain(expected);
1966
}
2067
}

0 commit comments

Comments
 (0)