Add comprehensive backend test suite and helper access

This commit is contained in:
2026-02-05 18:03:50 +01:00
parent 330d87b432
commit 912da11809
11 changed files with 591 additions and 4 deletions

View File

@@ -0,0 +1,28 @@
using System.Net;
using GameList.Tests.Support;
namespace GameList.Tests;
public class MiddlewareTests
{
[Fact]
public async Task Deleted_player_cookie_is_signed_out()
{
using var factory = new TestWebApplicationFactory();
var client = factory.CreateClientWithCookies();
await client.RegisterAsync("ghost");
var playerId = await client.GetProfileIdAsync();
await factory.WithDbContextAsync(async db =>
{
var player = await db.Players.FindAsync(playerId);
db.Players.Remove(player!);
await db.SaveChangesAsync();
});
var resp = await client.GetAsync("/api/state");
Assert.Equal(HttpStatusCode.Unauthorized, resp.StatusCode);
Assert.Contains(resp.Headers, h => h.Key.Equals("Set-Cookie", StringComparison.OrdinalIgnoreCase));
}
}