Add course adjustment Word form
This commit is contained in:
1 parent
e6351d33df
commit
f858ccee00
5 files changed
+68
-6
No files matched your search
@@ -655,13 +655,26 @@ public sealed class ApprovalsControllerTests
|
||||
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 };
|
||||
var draft = new CourseAdjustment { TeachingTaskId = fixture.CurrentTask.Id, ApplicantUserId = fixture.Student.UserId!.Value, Status = CourseAdjustmentStatus.Draft,
|
||||
Type = CourseAdjustmentType.Reschedule, SourceDate = new DateOnly(2026, 11, 20), SourceWeek = 12,
|
||||
SourceStartPeriod = 1, SourcePeriodCount = 2, TargetDate = new DateOnly(2026, 11, 23), StartPeriod = 3, PeriodCount = 2, Reason = "申请调课" };
|
||||
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 file = Assert.IsType<FileContentResult>(await fixture.Controller.DownloadApprovalForm("CourseAdjustment", draft.Id, CancellationToken.None));
|
||||
using (var word = DocumentFormat.OpenXml.Packaging.WordprocessingDocument.Open(new MemoryStream(file.FileContents), false))
|
||||
{
|
||||
var text = word.MainDocumentPart!.Document!.Body!.InnerText;
|
||||
Assert.Contains("2026-11-20", text);
|
||||
Assert.Contains("2026-11-23", text);
|
||||
Assert.Contains("未提交", text);
|
||||
Assert.Contains("申请调课", text);
|
||||
}
|
||||
var outsider = new ApprovalsController(fixture.Db, new StudentDataScope(Guid.NewGuid()));
|
||||
Assert.IsType<NotFoundResult>(await outsider.DownloadApprovalForm("CourseAdjustment", draft.Id, CancellationToken.None));
|
||||
var dualRole = new ApprovalsController(fixture.Db, new DualRoleDataScope(fixture.Student.UserId!.Value));
|
||||
Assert.IsType<OkObjectResult>((await dualRole.GetProgress("CourseAdjustment", draft.Id, CancellationToken.None)).Result);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user