Events-MVC (example with htmx)

This commit is contained in:
Boris Milašinović
2026-04-25 22:21:35 +02:00
parent eb04483417
commit 0ee1b22f61
114 changed files with 7966 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
using System.Net;
using Events.Tests.IntegrationTests.Infrastructure;
namespace Events.Tests.IntegrationTests;
public class SportsPageShould
{
[Fact]
public async Task ReturnPageWithSportsListWhenSportsExist()
{
await using var factory = new CustomWebApplicationFactory(TestDataSeeder.SeedSports);
using var client = factory.CreateClient();
var response = await client.GetAsync("/Sports");
var html = await response.Content.ReadAsStringAsync();
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Contains("Sports list", html);
Assert.Contains("Football", html);
Assert.Contains("Basketball", html);
}
[Fact]
public async Task ReturnOnlySportsPartialForHtmxRequest()
{
await using var factory = new CustomWebApplicationFactory(TestDataSeeder.SeedSports);
using var client = factory.CreateClient();
client.DefaultRequestHeaders.Add(Events.MVC.Constants.HtmxHeaders.Request, "true");
var response = await client.GetAsync("/Sports");
var html = await response.Content.ReadAsStringAsync();
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Contains("id=\"sports-list\"", html);
Assert.DoesNotContain("<html", html, StringComparison.OrdinalIgnoreCase);
Assert.DoesNotContain("navbar", html, StringComparison.OrdinalIgnoreCase);
}
}