Enable direct review and filter approval queues

This commit is contained in:
biss committed 2026-11-07 20:22:47 +08:00
1 parent 2d1a43fd39
commit 88ef93022d
6 files changed
+169 -26

No files matched your search

@@ -13,6 +13,28 @@ namespace Jiaowu.Api.Tests;
public sealed class ApprovalsControllerTests
{
[Fact]
public async Task Counselor_queue_shows_the_status_change_stage_and_type()
{
await using var fixture = await ApprovalFixture.CreateAsync();
var counselorId = Guid.NewGuid();
fixture.Db.Users.Add(new ApplicationUser { Id = counselorId, UserName = "counselor-test", DisplayName = "辅导员" });
var administrativeClass = await fixture.Db.AdministrativeClasses.FindAsync(fixture.Student.AdministrativeClassId);
administrativeClass!.CounselorUserId = counselorId;
fixture.Db.StudentStatusChanges.Add(new StudentStatusChange
{
StudentId = fixture.Student.Id, Type = StudentStatusChangeType.Suspension,
Reason = "需要休学", State = StudentStatusChangeState.Submitted
});
await fixture.Db.SaveChangesAsync();
var response = await new ApprovalsController(fixture.Db, new CounselorDataScope(counselorId))
.GetPending(1, 20, CancellationToken.None);
var result = Assert.IsType<ApprovalPendingResult>(Assert.IsType<OkObjectResult>(response.Result).Value);
var item = Assert.Single(result.Items);
Assert.Equal("counselor", item.Stage);
Assert.Contains("休学", item.Title);
}
[Fact]
public async Task Clearance_pending_only_includes_the_responsible_role()
{
@@ -164,6 +186,12 @@ public sealed class ApprovalsControllerTests
var oldestPage = Assert.IsType<ApprovalPendingResult>(Assert.IsType<OkObjectResult>(oldest.Result).Value);
Assert.Equal("较早提交", Assert.Single(oldestPage.Items).Desc);
Assert.Equal(2, oldestPage.Total);
var filtered = await controller.GetPending(1, 1, CancellationToken.None, type: "CourseExemption");
var filteredPage = Assert.IsType<ApprovalPendingResult>(Assert.IsType<OkObjectResult>(filtered.Result).Value);
Assert.Equal(1, filteredPage.Total);
Assert.Equal("CourseExemption", Assert.Single(filteredPage.Items).Type);
Assert.Equal(1, filteredPage.Counts["DeferredExam"]);
}
[Fact]
@@ -477,4 +505,11 @@ public sealed class ApprovalsControllerTests
Guid.NewGuid(), "学院管理员", collegeId, DataScope.College,
new HashSet<string>([SystemRoles.CollegeAdmin]));
}
private sealed class CounselorDataScope(Guid userId) : ICurrentUserDataScope
{
public CurrentUserScope Current { get; } = new(
userId, "辅导员", null, DataScope.Class,
new HashSet<string>([SystemRoles.Counselor]));
}
}