Unfinalize everyone on suggestion linking changes
This commit is contained in:
@@ -359,6 +359,41 @@ public class AdminTests
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Link_unfinalizes_all_players()
|
||||
{
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var admin = factory.CreateClientWithCookies();
|
||||
await admin.RegisterAsync("admin", admin: true);
|
||||
var p1 = factory.CreateClientWithCookies();
|
||||
await p1.RegisterAsync("p1");
|
||||
var p2 = factory.CreateClientWithCookies();
|
||||
await p2.RegisterAsync("p2");
|
||||
|
||||
var a = await p1.CreateSuggestionAsync("A");
|
||||
var b = await p1.CreateSuggestionAsync("B");
|
||||
|
||||
await admin.PostAsJsonAsync("/api/me/phase/next", new { });
|
||||
await p1.PostAsJsonAsync("/api/me/phase/next", new { });
|
||||
await p2.PostAsJsonAsync("/api/me/phase/next", new { });
|
||||
|
||||
await p1.PostAsJsonAsync("/api/votes/finalize", new { Final = true });
|
||||
await p2.PostAsJsonAsync("/api/votes/finalize", new { Final = true });
|
||||
|
||||
var link = await admin.PostAsJsonAsync("/api/admin/link-suggestions", new
|
||||
{
|
||||
SourceSuggestionId = a,
|
||||
TargetSuggestionId = b
|
||||
});
|
||||
link.EnsureSuccessStatusCode();
|
||||
|
||||
await factory.WithDbContextAsync(async db =>
|
||||
{
|
||||
var players = await db.Players.Where(p => !p.IsAdmin).ToListAsync();
|
||||
Assert.All(players, p => Assert.False(p.VotesFinal));
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Unlink_not_found_returns_empty_payload()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user