Increase coverage with identity and filter tests

This commit is contained in:
2026-02-05 18:28:44 +01:00
parent 875b12db3f
commit 9096e089ab
5 changed files with 258 additions and 1 deletions

View File

@@ -3,6 +3,9 @@ using System.Net.Http.Json;
using System.Text.Json;
using GameList.Domain;
using GameList.Tests.Support;
using Microsoft.EntityFrameworkCore;
using GameList.Data;
using Microsoft.Extensions.DependencyInjection;
namespace GameList.Tests;
@@ -102,4 +105,34 @@ public class StateTests
var resp = await factory.CreateClient().GetFromJsonAsync<JsonElement>("/health");
Assert.Equal("ok", resp.GetProperty("status").GetString());
}
[Fact]
public async Task GetPhase_aligns_to_results_when_open()
{
using var factory = new TestWebApplicationFactory();
await factory.WithDbContextAsync(async db =>
{
var player = new Player
{
Id = Guid.NewGuid(),
Username = "phase",
NormalizedUsername = "phase",
PasswordHash = new byte[] { 1 },
PasswordSalt = new byte[] { 1 },
DisplayName = "phase",
CurrentPhase = Phase.Vote
};
db.Players.Add(player);
var state = await db.AppState.FirstAsync();
state.ResultsOpen = true;
await db.SaveChangesAsync();
});
using var scope = factory.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
var playerId = await db.Players.Select(p => p.Id).FirstAsync();
var phase = await GameList.Endpoints.EndpointHelpers.GetPhase(db, playerId);
Assert.Equal(Phase.Results, phase);
}
}