Add school dress rules tab in Management with tests.

This commit is contained in:
Leonid Pershin
2026-08-20 06:20:06 +03:00
parent c541156614
commit aab0c00988
13 changed files with 724 additions and 15 deletions
@@ -54,6 +54,38 @@ public class DressRulesApiTests(AppHostFixture fixture)
Assert.Equal(before.Worn.Select(row => row.DefName), after.Worn.Select(row => row.DefName));
}
[Fact]
public async Task UnknownForm_Returns400()
{
using var client = fixture.App.CreateHttpClient("server");
await SchoolApiTests.ResetAsync(client);
var school = await SchoolApiTests.CreateAsync(client, "Плохая форма", Start, seed: 35);
using var response = await client.PostAsJsonAsync(
$"/api/schools/{school.Id}/dress-rules",
new { students = new { form = "tuxedo", color = "noBright" } },
TestContext.Current.CancellationToken);
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
Assert.Equal("unknown-form", await SchoolApiTests.ProblemCodeAsync(response));
}
[Fact]
public async Task UnknownColor_Returns400()
{
using var client = fixture.App.CreateHttpClient("server");
await SchoolApiTests.ResetAsync(client);
var school = await SchoolApiTests.CreateAsync(client, "Плохой цвет", Start, seed: 35);
using var response = await client.PostAsJsonAsync(
$"/api/schools/{school.Id}/dress-rules",
new { students = new { form = "regular", color = "neon" } },
TestContext.Current.CancellationToken);
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
Assert.Equal("unknown-color", await SchoolApiTests.ProblemCodeAsync(response));
}
private sealed record DressRulesDto(DressRulePairDto Students, DressRulePairDto Staff);
private sealed record DressRulePairDto(string Form, string Color);