Integrate leave and discipline approval tasks

This commit is contained in:
biss committed 2026-12-01 10:14:54 +08:00
1 parent 167af46687
commit 784b5b76f2
6 files changed
+80 -7

No files matched your search

@@ -1695,6 +1695,26 @@ public sealed class ApprovalsControllerTests
Assert.Equal(1, filteredPage.Counts["DeferredExam"]);
}
[Fact]
public async Task Pending_includes_leave_and_discipline_only_for_authorized_scope_and_stage()
{
await using var fixture = await ApprovalFixture.CreateAsync();
fixture.Db.StudentLeaves.Add(new StudentLeave { StudentId = fixture.Student.Id, Type = StudentLeaveType.Sick, StartAt = DateTime.UtcNow, EndAt = DateTime.UtcNow.AddDays(1), Reason = "病假" });
fixture.Db.StudentDisciplines.Add(new StudentDiscipline { StudentId = fixture.Student.Id, DisciplineType = "警告", Facts = "事实", Basis = "依据", DecisionNumber = "1", DecisionAuthority = "学院", DecisionDate = DateOnly.FromDateTime(DateTime.Today), EffectiveDate = DateOnly.FromDateTime(DateTime.Today), CreatedByUserId = Guid.NewGuid(), State = StudentDisciplineState.Submitted, SubmittedAt = DateTime.UtcNow });
await fixture.Db.SaveChangesAsync();
var manager = new ApprovalsController(fixture.Db, new ManagerDataScope());
var result = await manager.GetPending(1, 20, CancellationToken.None);
var page = Assert.IsType<ApprovalPendingResult>(Assert.IsType<OkObjectResult>(result.Result).Value);
Assert.Equal(1, page.Counts["StudentLeave"]);
Assert.Equal("college", Assert.Single(page.Items, x => x.Type == "StudentDiscipline").Stage);
var outsider = new ApprovalsController(fixture.Db, new CollegeDataScope(Guid.NewGuid()));
var otherResult = await outsider.GetPending(1, 20, CancellationToken.None);
var otherPage = Assert.IsType<ApprovalPendingResult>(Assert.IsType<OkObjectResult>(otherResult.Result).Value);
Assert.DoesNotContain(otherPage.Items, x => x.Type is "StudentLeave" or "StudentDiscipline");
}
[Fact]
public async Task MyCourses_IncludesPublishedScheduledTaskAfterCurrentTermChanges()
{