Merge branch 'review/slice-4-recheck'

This commit is contained in:
Leonid Pershin
2026-08-20 15:05:08 +03:00
5 changed files with 163 additions and 7 deletions
@@ -186,7 +186,30 @@ public class TimetableApiTests(AppHostFixture fixture)
}
[Fact]
public async Task Saturday_HasNoOccupancyOnTheMap()
public async Task GetTimetable_ClassAndPersonFilters_NarrowTheLessons()
{
using var client = fixture.App.CreateHttpClient("server");
await SchoolApiTests.ResetAsync(client);
var school = await SchoolApiTests.CreateAsync(client, "Расписание фильтр", TuesdayMorning);
var teacher = await HireMathAsync(client, school.Id);
var table = await GetTimetableAsync(client, school.Id);
var math = table.Lessons.First(lesson => lesson.Subject == "Mathematics");
var otherClass = table.Classes.First(klass => klass.Id != math.ClassId);
var byClass = await GetTimetableAsync(client, school.Id, classId: math.ClassId);
Assert.NotEmpty(byClass.Lessons);
Assert.All(byClass.Lessons, lesson => Assert.Equal(math.ClassId, lesson.ClassId));
Assert.Contains(byClass.Lessons, lesson => lesson.Subject == "Mathematics");
Assert.DoesNotContain(byClass.Lessons, lesson => lesson.ClassId == otherClass.Id);
var byTeacher = await GetTimetableAsync(client, school.Id, personId: teacher);
Assert.NotEmpty(byTeacher.Lessons);
Assert.All(byTeacher.Lessons, lesson => Assert.Equal(teacher, lesson.TeacherId));
}
[Fact]
public async Task Saturday_StillStoresTheWeekTable()
{
using var client = fixture.App.CreateHttpClient("server");
await SchoolApiTests.ResetAsync(client);
@@ -206,10 +229,25 @@ public class TimetableApiTests(AppHostFixture fixture)
return applicant.Id;
}
private static async Task<TimetableResponse> GetTimetableAsync(HttpClient client, int schoolId)
private static async Task<TimetableResponse> GetTimetableAsync(
HttpClient client,
int schoolId,
string? classId = null,
string? personId = null)
{
var query = "lang=ru";
if (classId is not null)
{
query += $"&classId={Uri.EscapeDataString(classId)}";
}
if (personId is not null)
{
query += $"&personId={Uri.EscapeDataString(personId)}";
}
var table = await client.GetFromJsonAsync<TimetableResponse>(
$"/api/schools/{schoolId}/timetable?lang=ru",
$"/api/schools/{schoolId}/timetable?{query}",
TestContext.Current.CancellationToken);
Assert.NotNull(table);
return table;