Add admin status combobox to move voters back to suggest
This commit is contained in:
@@ -59,6 +59,63 @@ public class AdminTests
|
||||
Assert.Equal(HttpStatusCode.BadRequest, give.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Admin_can_move_vote_player_back_to_suggest()
|
||||
{
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var admin = factory.CreateClientWithCookies();
|
||||
await admin.RegisterAsync("admin", admin: true);
|
||||
var player = factory.CreateClientWithCookies();
|
||||
await player.RegisterAsync("player");
|
||||
await player.CreateSuggestionAsync("Game");
|
||||
await player.PostAsJsonAsync("/api/me/phase/next", new { });
|
||||
|
||||
await factory.WithDbContextAsync(async db =>
|
||||
{
|
||||
var p = await db.Players.SingleAsync(x => x.Username == "player");
|
||||
p.VotesFinal = true;
|
||||
await db.SaveChangesAsync();
|
||||
});
|
||||
|
||||
var resp = await admin.PostAsJsonAsync("/api/admin/player-phase", new
|
||||
{
|
||||
playerId = await player.GetProfileIdAsync(),
|
||||
phase = nameof(Phase.Suggest)
|
||||
});
|
||||
resp.EnsureSuccessStatusCode();
|
||||
|
||||
await factory.WithDbContextAsync(async db =>
|
||||
{
|
||||
var p = await db.Players.SingleAsync(x => x.Username == "player");
|
||||
Assert.Equal(Phase.Suggest, p.CurrentPhase);
|
||||
Assert.False(p.VotesFinal);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Admin_player_phase_requires_vote_phase_and_suggest_target()
|
||||
{
|
||||
await using var factory = new TestWebApplicationFactory();
|
||||
var admin = factory.CreateClientWithCookies();
|
||||
await admin.RegisterAsync("admin", admin: true);
|
||||
var player = factory.CreateClientWithCookies();
|
||||
await player.RegisterAsync("player");
|
||||
|
||||
var wrongTarget = await admin.PostAsJsonAsync("/api/admin/player-phase", new
|
||||
{
|
||||
playerId = await player.GetProfileIdAsync(),
|
||||
phase = nameof(Phase.Results)
|
||||
});
|
||||
Assert.Equal(HttpStatusCode.BadRequest, wrongTarget.StatusCode);
|
||||
|
||||
var wrongCurrentPhase = await admin.PostAsJsonAsync("/api/admin/player-phase", new
|
||||
{
|
||||
playerId = await player.GetProfileIdAsync(),
|
||||
phase = nameof(Phase.Suggest)
|
||||
});
|
||||
Assert.Equal(HttpStatusCode.BadRequest, wrongCurrentPhase.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Delete_player_cascades_suggestions_and_votes()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user