Expand approval progress to additional workflows
This commit is contained in:
1 parent
5d2c24d702
commit
c5ad71e8fa
10 files changed
+241
-23
No files matched your search
@@ -67,7 +67,10 @@ public sealed class ApprovalsController(
|
||||
{
|
||||
case "CourseExemption":
|
||||
{
|
||||
var query = manager ? Scoped<CourseExemption>(x => x.Id == id) : db.CourseExemptions.AsNoTracking().Where(x => x.Id == id && x.Student!.UserId == userId);
|
||||
var restrictedCollegeId = current.RestrictedCollegeId;
|
||||
var allColleges = manager && current.Scope == DataScope.All;
|
||||
var query = db.CourseExemptions.AsNoTracking().Where(x => x.Id == id &&
|
||||
(x.Student!.UserId == userId || (manager && (allColleges || x.TeachingTask!.Course!.CollegeId == restrictedCollegeId))));
|
||||
var item = await query.FirstOrDefaultAsync(ct);
|
||||
if (item is null) return NotFound();
|
||||
AddSingleApprovalSteps(steps, item.SubmittedAt, item.ReviewedAt, item.Status, item.ReviewComment);
|
||||
@@ -75,7 +78,10 @@ public sealed class ApprovalsController(
|
||||
}
|
||||
case "DeferredExam":
|
||||
{
|
||||
var query = manager ? Scoped<DeferredExam>(x => x.Id == id) : db.DeferredExams.AsNoTracking().Where(x => x.Id == id && x.Student!.UserId == userId);
|
||||
var restrictedCollegeId = current.RestrictedCollegeId;
|
||||
var allColleges = manager && current.Scope == DataScope.All;
|
||||
var query = db.DeferredExams.AsNoTracking().Where(x => x.Id == id &&
|
||||
(x.Student!.UserId == userId || (manager && (allColleges || x.TeachingTask!.Course!.CollegeId == restrictedCollegeId))));
|
||||
var item = await query.FirstOrDefaultAsync(ct);
|
||||
if (item is null) return NotFound();
|
||||
AddSingleApprovalSteps(steps, item.SubmittedAt, item.ReviewedAt, item.Status, item.ReviewComment);
|
||||
@@ -83,7 +89,10 @@ public sealed class ApprovalsController(
|
||||
}
|
||||
case "CourseSubstitution":
|
||||
{
|
||||
var query = manager ? Scoped<CourseSubstitution>(x => x.Id == id) : db.CourseSubstitutions.AsNoTracking().Where(x => x.Id == id && x.Student!.UserId == userId);
|
||||
var restrictedCollegeId = current.RestrictedCollegeId;
|
||||
var allColleges = manager && current.Scope == DataScope.All;
|
||||
var query = db.CourseSubstitutions.AsNoTracking().Where(x => x.Id == id &&
|
||||
(x.Student!.UserId == userId || (manager && (allColleges || x.Student.AdministrativeClass!.Major!.CollegeId == restrictedCollegeId))));
|
||||
var item = await query.FirstOrDefaultAsync(ct);
|
||||
if (item is null) return NotFound();
|
||||
AddSingleApprovalSteps(steps, item.SubmittedAt, item.ReviewedAt, item.Status, item.ReviewComment);
|
||||
@@ -91,7 +100,10 @@ public sealed class ApprovalsController(
|
||||
}
|
||||
case "GradeModification":
|
||||
{
|
||||
var query = manager ? Scoped<GradeModification>(x => x.Id == id) : db.GradeModifications.AsNoTracking().Where(x => x.Id == id && x.ApplicantUserId == userId);
|
||||
var restrictedCollegeId = current.RestrictedCollegeId;
|
||||
var allColleges = manager && current.Scope == DataScope.All;
|
||||
var query = db.GradeModifications.AsNoTracking().Where(x => x.Id == id &&
|
||||
(x.ApplicantUserId == userId || (manager && (allColleges || x.GradeRecord!.GradeSheet!.TeachingTask!.Course!.CollegeId == restrictedCollegeId))));
|
||||
var item = await query.FirstOrDefaultAsync(ct);
|
||||
if (item is null) return NotFound();
|
||||
steps.Add(new("submitted", item.SubmittedAt, item.Reason));
|
||||
@@ -104,15 +116,95 @@ public sealed class ApprovalsController(
|
||||
steps.Add(new(item.Status == GradeModificationStatus.Rejected ? "finalRejected" : "finalApproved", finalTime, item.ReviewComment));
|
||||
break;
|
||||
}
|
||||
case "TeacherCourseApplication":
|
||||
{
|
||||
var query = db.TeacherCourseApplications.AsNoTracking().Where(x => x.Id == id);
|
||||
if (manager)
|
||||
{
|
||||
if (current.RestrictedCollegeId is { } collegeId)
|
||||
query = query.Where(x => x.Teacher!.CollegeId == collegeId || x.Teacher.UserId == userId);
|
||||
}
|
||||
else query = query.Where(x => x.Teacher!.UserId == userId);
|
||||
var item = await query.FirstOrDefaultAsync(ct);
|
||||
if (item is null) return NotFound();
|
||||
steps.Add(new("started", item.SubmittedAt, null));
|
||||
if (item.ReviewedAt is { } time && item.Status is TeacherCourseApplicationStatus.Approved or TeacherCourseApplicationStatus.Rejected)
|
||||
steps.Add(new(item.Status == TeacherCourseApplicationStatus.Approved ? "approved" : "rejected", time, item.ReviewComment));
|
||||
if ((item.Status is TeacherCourseApplicationStatus.Approved or TeacherCourseApplicationStatus.Rejected) && item.ReviewedAt is null ||
|
||||
item.Status == TeacherCourseApplicationStatus.Withdrawn)
|
||||
historyIncomplete = true;
|
||||
break;
|
||||
}
|
||||
case "ClassroomReservation":
|
||||
{
|
||||
var collegeId = current.CollegeId;
|
||||
var canReview = current.IsInRole(SystemRoles.CollegeAdmin) && collegeId.HasValue;
|
||||
var item = await db.ClassroomReservations.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id &&
|
||||
(x.ApplicantUserId == userId || (canReview && x.ApplicantCollegeId == collegeId)), ct);
|
||||
if (item is null) return NotFound();
|
||||
steps.Add(new("submitted", item.CreatedAt, null));
|
||||
if (item.ReviewedAt is { } time && item.Status is ClassroomReservationStatus.Approved or ClassroomReservationStatus.Rejected or ClassroomReservationStatus.Cancelled)
|
||||
steps.Add(new(item.Status == ClassroomReservationStatus.Rejected ? "rejected" : "approved", time, item.ReviewComment));
|
||||
if (item.CancelledAt is { } cancelledAt && item.Status == ClassroomReservationStatus.Cancelled)
|
||||
steps.Add(new("cancelled", cancelledAt, null));
|
||||
if ((item.Status is ClassroomReservationStatus.Approved or ClassroomReservationStatus.Rejected) && item.ReviewedAt is null ||
|
||||
item.Status == ClassroomReservationStatus.Cancelled && item.CancelledAt is null)
|
||||
historyIncomplete = true;
|
||||
break;
|
||||
}
|
||||
case "CourseAdjustment":
|
||||
{
|
||||
var restrictedCollegeId = current.RestrictedCollegeId;
|
||||
var allColleges = manager && current.Scope == DataScope.All;
|
||||
var query = db.CourseAdjustments.AsNoTracking().Where(x => x.Id == id &&
|
||||
(x.ApplicantUserId == userId || (manager && (allColleges || x.TeachingTask!.Course!.CollegeId == restrictedCollegeId))));
|
||||
var item = await query.FirstOrDefaultAsync(ct);
|
||||
if (item is null) return NotFound();
|
||||
if (item.SubmittedAt is { } submittedAt) steps.Add(new("submitted", submittedAt, null));
|
||||
else if (item.Status == CourseAdjustmentStatus.Draft) steps.Add(new("created", item.CreatedAt, null));
|
||||
else historyIncomplete = true;
|
||||
if (item.ReviewedAt is { } reviewedAt && item.Status is CourseAdjustmentStatus.Approved or CourseAdjustmentStatus.Rejected)
|
||||
steps.Add(new(item.Status == CourseAdjustmentStatus.Approved ? "approved" : "rejected", reviewedAt, item.ReviewComment));
|
||||
else if (item.Status is CourseAdjustmentStatus.Approved or CourseAdjustmentStatus.Rejected) historyIncomplete = true;
|
||||
break;
|
||||
}
|
||||
case "DormitoryApplication":
|
||||
{
|
||||
var viewer = manager || current.IsInRole(SystemRoles.DormitoryAdmin) || current.IsInRole(SystemRoles.Counselor);
|
||||
var query = db.DormitoryApplications.AsNoTracking().Where(x => x.Id == id);
|
||||
if (!viewer) query = query.Where(x => x.Student!.UserId == userId);
|
||||
else if (current.Scope == DataScope.College)
|
||||
query = query.Where(x => x.Student!.UserId == userId || x.Student.AdministrativeClass!.Major!.CollegeId == current.RestrictedCollegeId);
|
||||
else if (current.Scope == DataScope.Class)
|
||||
query = query.Where(x => x.Student!.UserId == userId || x.Student.AdministrativeClass!.CounselorUserId == userId);
|
||||
else if (current.Scope != DataScope.All)
|
||||
query = query.Where(x => x.Student!.UserId == userId);
|
||||
var item = await query.FirstOrDefaultAsync(ct);
|
||||
if (item is null) return NotFound();
|
||||
steps.Add(new("submitted", item.SubmittedAt, null));
|
||||
if (item.CounselorReviewedAt is { } counselorAt)
|
||||
{
|
||||
var rejected = item.Status == DormitoryApplicationStatus.Rejected && item.FinalReviewedAt is null;
|
||||
steps.Add(new(rejected ? "counselorRejected" : "counselorApproved", counselorAt, item.CounselorComment));
|
||||
}
|
||||
if (item.FinalReviewedAt is { } finalAt && item.Status is DormitoryApplicationStatus.Approved or DormitoryApplicationStatus.Rejected)
|
||||
steps.Add(new(item.Status == DormitoryApplicationStatus.Approved ? "dormitoryApproved" : "dormitoryRejected", finalAt, item.FinalComment));
|
||||
if (item.Status == DormitoryApplicationStatus.Cancelled ||
|
||||
item.Status == DormitoryApplicationStatus.CounselorApproved && item.CounselorReviewedAt is null ||
|
||||
item.Status == DormitoryApplicationStatus.Approved && (item.CounselorReviewedAt is null || item.FinalReviewedAt is null) ||
|
||||
item.Status == DormitoryApplicationStatus.Rejected && item.CounselorReviewedAt is null)
|
||||
historyIncomplete = true;
|
||||
break;
|
||||
}
|
||||
case "StudentStatusChange":
|
||||
{
|
||||
var query = db.StudentStatusChanges.AsNoTracking().Where(x => x.Id == id);
|
||||
if (manager || current.IsInRole(SystemRoles.Counselor))
|
||||
{
|
||||
if (current.Scope == DataScope.College)
|
||||
query = query.Where(x => x.Student!.AdministrativeClass!.Major!.CollegeId == current.RestrictedCollegeId);
|
||||
query = query.Where(x => x.Student!.UserId == userId || x.Student.AdministrativeClass!.Major!.CollegeId == current.RestrictedCollegeId);
|
||||
else if (current.Scope == DataScope.Class)
|
||||
query = query.Where(x => x.Student!.AdministrativeClass!.CounselorUserId == userId);
|
||||
query = query.Where(x => x.Student!.UserId == userId || x.Student.AdministrativeClass!.CounselorUserId == userId);
|
||||
else if (current.Scope != DataScope.All)
|
||||
query = query.Where(x => x.Student!.UserId == userId);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,109 @@ namespace Jiaowu.Api.Tests;
|
||||
|
||||
public sealed class ApprovalsControllerTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Classroom_progress_preserves_approval_and_later_cancellation_with_role_scope()
|
||||
{
|
||||
await using var fixture = await ApprovalFixture.CreateAsync();
|
||||
var campus = new Campus { Code = "CAMP", Name = "校区" };
|
||||
var building = new Building { Code = "BLD", Name = "教学楼", CampusId = campus.Id };
|
||||
var room = new Classroom { Code = "R1", Name = "教室", BuildingId = building.Id };
|
||||
var created = DateTime.UtcNow.AddHours(-3);
|
||||
var reservation = new ClassroomReservation
|
||||
{
|
||||
ApplicantUserId = fixture.Student.UserId!.Value, ApplicantName = fixture.Student.Name,
|
||||
ApplicantCollegeId = fixture.CurrentCourse.CollegeId, AcademicTermId = fixture.CurrentTerm.Id,
|
||||
ClassroomId = room.Id, Purpose = "活动", ContactPhone = "123456", Status = ClassroomReservationStatus.Cancelled,
|
||||
CreatedAt = created, ReviewedAt = created.AddHours(1), CancelledAt = created.AddHours(2), ReviewComment = "同意"
|
||||
};
|
||||
fixture.Db.AddRange(campus, building, room, reservation);
|
||||
await fixture.Db.SaveChangesAsync();
|
||||
var own = await fixture.Controller.GetProgress("ClassroomReservation", reservation.Id, CancellationToken.None);
|
||||
var progress = Assert.IsType<ApprovalProgressResponse>(Assert.IsType<OkObjectResult>(own.Result).Value);
|
||||
Assert.Equal(new[] { "submitted", "approved", "cancelled" }, progress.Steps.Select(x => x.Kind));
|
||||
Assert.False(progress.HistoryIncomplete);
|
||||
var otherCollege = new ApprovalsController(fixture.Db, new CollegeDataScope(Guid.NewGuid()));
|
||||
Assert.IsType<NotFoundResult>((await otherCollege.GetProgress("ClassroomReservation", reservation.Id, CancellationToken.None)).Result);
|
||||
var superOnly = new ApprovalsController(fixture.Db, new ManagerDataScope());
|
||||
Assert.IsType<NotFoundResult>((await superOnly.GetProgress("ClassroomReservation", reservation.Id, CancellationToken.None)).Result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Dormitory_progress_uses_recorded_stage_decisions_and_scoped_access()
|
||||
{
|
||||
await using var fixture = await ApprovalFixture.CreateAsync();
|
||||
var submitted = DateTime.UtcNow.AddDays(-1);
|
||||
var application = new DormitoryApplication
|
||||
{
|
||||
StudentId = fixture.Student.Id, Reason = "住宿申请", Status = DormitoryApplicationStatus.Rejected,
|
||||
SubmittedAt = submitted, CounselorReviewedAt = submitted.AddHours(1), CounselorComment = "初审同意",
|
||||
FinalReviewedAt = submitted.AddHours(2), FinalComment = "床位不足"
|
||||
};
|
||||
fixture.Db.DormitoryApplications.Add(application);
|
||||
await fixture.Db.SaveChangesAsync();
|
||||
var response = await fixture.Controller.GetProgress("DormitoryApplication", application.Id, CancellationToken.None);
|
||||
var result = Assert.IsType<ApprovalProgressResponse>(Assert.IsType<OkObjectResult>(response.Result).Value);
|
||||
Assert.Equal(new[] { "submitted", "counselorApproved", "dormitoryRejected" }, result.Steps.Select(x => x.Kind));
|
||||
Assert.Equal("床位不足", result.Steps[2].Comment);
|
||||
var outsider = new ApprovalsController(fixture.Db, new CounselorDataScope(Guid.NewGuid()));
|
||||
Assert.IsType<NotFoundResult>((await outsider.GetProgress("DormitoryApplication", application.Id, CancellationToken.None)).Result);
|
||||
var dualRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(fixture.Student.UserId!.Value));
|
||||
Assert.IsType<OkObjectResult>((await dualRole.GetProgress("DormitoryApplication", application.Id, CancellationToken.None)).Result);
|
||||
application.Status = DormitoryApplicationStatus.Cancelled;
|
||||
application.CounselorReviewedAt = null;
|
||||
application.FinalReviewedAt = null;
|
||||
await fixture.Db.SaveChangesAsync();
|
||||
var cancelled = await fixture.Controller.GetProgress("DormitoryApplication", application.Id, CancellationToken.None);
|
||||
var cancelledProgress = Assert.IsType<ApprovalProgressResponse>(Assert.IsType<OkObjectResult>(cancelled.Result).Value);
|
||||
Assert.True(cancelledProgress.HistoryIncomplete);
|
||||
Assert.Equal("submitted", Assert.Single(cancelledProgress.Steps).Kind);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Teacher_course_progress_is_visible_only_to_owner_or_scoped_manager()
|
||||
{
|
||||
await using var fixture = await ApprovalFixture.CreateAsync();
|
||||
var teacher = new Teacher { TeacherNumber = "T-HISTORY", Name = "教师", CollegeId = fixture.CurrentCourse.CollegeId, UserId = fixture.Student.UserId };
|
||||
var application = new TeacherCourseApplication
|
||||
{
|
||||
TeacherId = teacher.Id, CourseId = fixture.CurrentCourse.Id, AcademicTermId = fixture.CurrentTerm.Id,
|
||||
Status = TeacherCourseApplicationStatus.Rejected, ReviewedAt = DateTime.UtcNow, ReviewComment = "不符合条件"
|
||||
};
|
||||
fixture.Db.AddRange(teacher, application);
|
||||
await fixture.Db.SaveChangesAsync();
|
||||
var response = await fixture.Controller.GetProgress("TeacherCourseApplication", application.Id, CancellationToken.None);
|
||||
var result = Assert.IsType<ApprovalProgressResponse>(Assert.IsType<OkObjectResult>(response.Result).Value);
|
||||
Assert.Equal(new[] { "started", "rejected" }, result.Steps.Select(x => x.Kind));
|
||||
var otherCollege = new ApprovalsController(fixture.Db, new CollegeDataScope(Guid.NewGuid()));
|
||||
Assert.IsType<NotFoundResult>((await otherCollege.GetProgress("TeacherCourseApplication", application.Id, CancellationToken.None)).Result);
|
||||
var sameCollege = new ApprovalsController(fixture.Db, new CollegeDataScope(fixture.CurrentCourse.CollegeId));
|
||||
Assert.IsType<OkObjectResult>((await sameCollege.GetProgress("TeacherCourseApplication", application.Id, CancellationToken.None)).Result);
|
||||
var dualRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(fixture.Student.UserId!.Value));
|
||||
Assert.IsType<OkObjectResult>((await dualRole.GetProgress("TeacherCourseApplication", application.Id, CancellationToken.None)).Result);
|
||||
application.Status = TeacherCourseApplicationStatus.Withdrawn;
|
||||
application.ReviewedAt = null;
|
||||
await fixture.Db.SaveChangesAsync();
|
||||
var withdrawn = await fixture.Controller.GetProgress("TeacherCourseApplication", application.Id, CancellationToken.None);
|
||||
var withdrawnProgress = Assert.IsType<ApprovalProgressResponse>(Assert.IsType<OkObjectResult>(withdrawn.Result).Value);
|
||||
Assert.True(withdrawnProgress.HistoryIncomplete);
|
||||
Assert.Equal("started", Assert.Single(withdrawnProgress.Steps).Kind);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Adjustment_draft_does_not_claim_it_was_submitted()
|
||||
{
|
||||
await using var fixture = await ApprovalFixture.CreateAsync();
|
||||
var draft = new CourseAdjustment { TeachingTaskId = fixture.CurrentTask.Id, ApplicantUserId = fixture.Student.UserId!.Value, Status = CourseAdjustmentStatus.Draft };
|
||||
fixture.Db.CourseAdjustments.Add(draft);
|
||||
await fixture.Db.SaveChangesAsync();
|
||||
var response = await fixture.Controller.GetProgress("CourseAdjustment", draft.Id, CancellationToken.None);
|
||||
var result = Assert.IsType<ApprovalProgressResponse>(Assert.IsType<OkObjectResult>(response.Result).Value);
|
||||
Assert.Equal("created", Assert.Single(result.Steps).Kind);
|
||||
Assert.False(result.HistoryIncomplete);
|
||||
var dualRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(fixture.Student.UserId!.Value));
|
||||
Assert.IsType<OkObjectResult>((await dualRole.GetProgress("CourseAdjustment", draft.Id, CancellationToken.None)).Result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Overdue_filter_translates_with_mysql_provider()
|
||||
{
|
||||
@@ -127,6 +230,8 @@ public sealed class ApprovalsControllerTests
|
||||
Assert.Equal(3, await fixture.Db.StudentStatusChangeEvents.CountAsync());
|
||||
var outsider = new ApprovalsController(fixture.Db, new CounselorDataScope(Guid.NewGuid()));
|
||||
Assert.IsType<NotFoundResult>((await outsider.GetProgress("StudentStatusChange", change.Id, CancellationToken.None)).Result);
|
||||
var dualRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(fixture.Student.UserId!.Value));
|
||||
Assert.IsType<OkObjectResult>((await dualRole.GetProgress("StudentStatusChange", change.Id, CancellationToken.None)).Result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -169,6 +274,9 @@ public sealed class ApprovalsControllerTests
|
||||
Assert.Equal(new[] { "submitted", "collegeApproved", "finalRejected" }, result.Steps.Select(x => x.Kind));
|
||||
Assert.Null(result.Steps[1].Comment);
|
||||
Assert.Equal("校级未通过", result.Steps[2].Comment);
|
||||
var applicantWithOtherCollegeRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(change.ApplicantUserId));
|
||||
Assert.IsType<OkObjectResult>((await applicantWithOtherCollegeRole.GetProgress("GradeModification", change.Id, CancellationToken.None)).Result);
|
||||
Assert.IsType<NotFoundResult>((await fixture.Controller.GetProgress("GradeModification", change.Id, CancellationToken.None)).Result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -194,6 +302,8 @@ public sealed class ApprovalsControllerTests
|
||||
Assert.IsType<NotFoundResult>((await outsider.GetProgress("CourseExemption", exemption.Id, CancellationToken.None)).Result);
|
||||
var otherCollege = new ApprovalsController(fixture.Db, new CollegeDataScope(Guid.NewGuid()));
|
||||
Assert.IsType<NotFoundResult>((await otherCollege.GetProgress("CourseExemption", exemption.Id, CancellationToken.None)).Result);
|
||||
var dualRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(fixture.Student.UserId!.Value));
|
||||
Assert.IsType<OkObjectResult>((await dualRole.GetProgress("CourseExemption", exemption.Id, CancellationToken.None)).Result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -695,4 +805,11 @@ public sealed class ApprovalsControllerTests
|
||||
userId, "辅导员", null, DataScope.Class,
|
||||
new HashSet<string>([SystemRoles.Counselor]));
|
||||
}
|
||||
|
||||
private sealed class DualRoleDataScope(Guid userId) : ICurrentUserDataScope
|
||||
{
|
||||
public CurrentUserScope Current { get; } = new(
|
||||
userId, "多角色用户", Guid.NewGuid(), DataScope.College,
|
||||
new HashSet<string>([SystemRoles.CollegeAdmin, SystemRoles.Student, SystemRoles.Teacher]));
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,14 @@ import { expect, test } from '@playwright/test'
|
||||
const cases: { type: string; stage: string | null; secondaryId?: string; endpoint: string; body: Record<string, unknown> | null; reject?: boolean; progress?: boolean }[] = [
|
||||
{ type: 'AttendanceAppeal', stage: null, secondaryId: 'sheet-1', endpoint: '/api/attendance/appeals/sheet-1/item-1/review', body: { approve: true, comment: null } },
|
||||
{ type: 'StudentStatusChange', stage: 'final', endpoint: '/api/student-status-changes/item-1/review', body: { approved: true, comment: null }, progress: true },
|
||||
{ type: 'TeacherCourseApplication', stage: null, endpoint: '/api/teacher-course-applications/item-1/review', body: { status: 'Approved', reviewComment: null } },
|
||||
{ type: 'ClassroomReservation', stage: null, endpoint: '/api/classroom-reservations/item-1/approve', body: { comment: null } },
|
||||
{ type: 'TeacherCourseApplication', stage: null, endpoint: '/api/teacher-course-applications/item-1/review', body: { status: 'Approved', reviewComment: null }, progress: true },
|
||||
{ type: 'ClassroomReservation', stage: null, endpoint: '/api/classroom-reservations/item-1/approve', body: { comment: null }, progress: true },
|
||||
{ type: 'CampusRegistration', stage: null, endpoint: '/api/campus-registrations/applications/item-1/review', body: { approved: true, comment: null } },
|
||||
{ type: 'DormitoryApplication', stage: 'counselor', endpoint: '/api/dormitory-services/applications/item-1/counselor-review', body: { approved: true, comment: null } },
|
||||
{ type: 'DormitoryApplication', stage: 'counselor', endpoint: '/api/dormitory-services/applications/item-1/counselor-review', body: { approved: true, comment: null }, progress: true },
|
||||
{ type: 'AttendanceAppeal', stage: null, secondaryId: 'sheet-1', endpoint: '/api/attendance/appeals/sheet-1/item-1/review', body: { approve: false, comment: '理由不充分' }, reject: true },
|
||||
{ type: 'TeacherCourseApplication', stage: null, endpoint: '/api/teacher-course-applications/item-1/review', body: { status: 'Rejected', reviewComment: '理由不充分' }, reject: true },
|
||||
{ type: 'CourseExemption', stage: null, endpoint: '/api/approvals/exemptions/item-1/approve', body: null, progress: true },
|
||||
{ type: 'CourseAdjustment', stage: null, endpoint: '/api/course-adjustments/item-1/approve', body: null, progress: true },
|
||||
]
|
||||
|
||||
for (const scenario of cases) test(`${scenario.type} can be ${scenario.reject ? 'rejected' : 'approved'} from the approval center`, async ({ page }) => {
|
||||
@@ -41,7 +42,7 @@ for (const scenario of cases) test(`${scenario.type} can be ${scenario.reject ?
|
||||
return route.fulfill({ status: 204 })
|
||||
}
|
||||
if (url.pathname === `/api/approvals/progress/${scenario.type}/item-1`)
|
||||
return route.fulfill({ json: { type: scenario.type, id: 'item-1', historyIncomplete: scenario.type === 'StudentStatusChange', steps: [{ kind: 'submitted', time: '2026-11-01T00:00:00Z', comment: null }] } })
|
||||
return route.fulfill({ json: { type: scenario.type, id: 'item-1', historyIncomplete: scenario.type === 'StudentStatusChange', steps: [{ kind: scenario.type === 'TeacherCourseApplication' ? 'started' : 'submitted', time: '2026-11-01T00:00:00Z', comment: null }] } })
|
||||
if (url.pathname === '/api/auth/me') return route.fulfill({ json: user })
|
||||
if (url.pathname === '/api/plugins/runtime') return route.fulfill({ json: [] })
|
||||
return route.fulfill({ json: {} })
|
||||
@@ -57,8 +58,8 @@ for (const scenario of cases) test(`${scenario.type} can be ${scenario.reject ?
|
||||
if (scenario.progress) {
|
||||
await card.getByRole('button', { name: '办理进度' }).click()
|
||||
const dialog = page.getByRole('dialog')
|
||||
await expect(dialog.getByText('已提交')).toBeVisible()
|
||||
if (scenario.type === 'StudentStatusChange') await expect(dialog.getByText('该申请较早的审核详情未留存。')).toBeVisible()
|
||||
await expect(dialog.getByText(scenario.type === 'TeacherCourseApplication' ? '本次申报开始' : '已提交')).toBeVisible()
|
||||
if (scenario.type === 'StudentStatusChange') await expect(dialog.getByText('该申请部分办理详情未留存。')).toBeVisible()
|
||||
await dialog.locator('.el-dialog__headerbtn').click()
|
||||
}
|
||||
if (scenario.reject) {
|
||||
|
||||
Loaded 3 of 10 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user