Test and localize approval deadline guidance
This commit is contained in:
1 parent
54b314afe0
commit
7e13c6bd0e
5 files changed
+56
-2
No files matched your search
@@ -2,6 +2,7 @@ using Jiaowu.Api.Controllers;
|
||||
using Jiaowu.Api.Contracts;
|
||||
using Jiaowu.Api.Domain.Academic;
|
||||
using Jiaowu.Api.Domain.Identity;
|
||||
using Jiaowu.Api.Domain.System;
|
||||
using Jiaowu.Api.Infrastructure.Auth;
|
||||
using Jiaowu.Api.Infrastructure.Attachments;
|
||||
using Jiaowu.Api.Infrastructure.Branding;
|
||||
@@ -19,6 +20,33 @@ namespace Jiaowu.Api.Tests;
|
||||
|
||||
public sealed class ApprovalsControllerTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task Pending_timeliness_reports_missing_holiday_years_only_when_enabled()
|
||||
{
|
||||
await using var fixture = await ApprovalFixture.CreateAsync();
|
||||
var setting = new SystemFeatureSetting { Key = "ApprovalTimeliness", IsEnabled = true };
|
||||
fixture.Db.AddRange(setting, new CourseExemption {
|
||||
StudentId = fixture.Student.Id, TeachingTaskId = fixture.CurrentTask.Id, Reason = "跨年申请",
|
||||
SubmittedAt = new DateTime(2026, 12, 31, 8, 0, 0, DateTimeKind.Utc)
|
||||
});
|
||||
await fixture.Db.SaveChangesAsync();
|
||||
var controller = new ApprovalsController(fixture.Db, new ManagerDataScope());
|
||||
var result = await controller.GetPending(1, 20, CancellationToken.None, type: "CourseExemption");
|
||||
var page = Assert.IsType<ApprovalPendingResult>(Assert.IsType<OkObjectResult>(result.Result).Value);
|
||||
var item = Assert.Single(page.Items);
|
||||
Assert.True(page.TimelinessEnabled);
|
||||
Assert.NotNull(item.DeadlineUtc);
|
||||
Assert.Equal(new[] { 2026, 2027 }, item.MissingHolidayYears);
|
||||
|
||||
setting.IsEnabled = false;
|
||||
await fixture.Db.SaveChangesAsync();
|
||||
result = await controller.GetPending(1, 20, CancellationToken.None, type: "CourseExemption");
|
||||
page = Assert.IsType<ApprovalPendingResult>(Assert.IsType<OkObjectResult>(result.Result).Value);
|
||||
item = Assert.Single(page.Items);
|
||||
Assert.False(page.TimelinessEnabled);
|
||||
Assert.Null(item.DeadlineUtc);
|
||||
Assert.Null(item.MissingHolidayYears);
|
||||
}
|
||||
[Fact]
|
||||
public async Task Development_migration_adds_stage_to_an_existing_review_event_table()
|
||||
{
|
||||
|
||||
@@ -2,6 +2,28 @@ import { expect, test } from '@playwright/test'
|
||||
|
||||
test.use({ serviceWorkers: 'block' })
|
||||
|
||||
test('pending items warn when holiday data is missing', async ({ page }) => {
|
||||
const user = { id: 'reviewer', userName: 'reviewer', displayName: '审核员', roles: ['AcademicAdmin'], permissions: [], effectiveDataScope: 'All' }
|
||||
await page.addInitScript(savedUser => {
|
||||
localStorage.setItem('jiaowu_token', 'test-token')
|
||||
localStorage.setItem('jiaowu_user', JSON.stringify(savedUser))
|
||||
localStorage.setItem('jiaowu_access_expires_at', '2099-01-01T00:00:00Z')
|
||||
localStorage.setItem('jiaowu_session_expires_at', '2099-01-01T00:00:00Z')
|
||||
}, user)
|
||||
await page.route(url => url.pathname.startsWith('/api/'), async route => {
|
||||
const path = new URL(route.request().url()).pathname
|
||||
if (path === '/api/approvals/pending') return route.fulfill({ json: { items: [{ id: 'item-1', type: 'CourseExemption', title: '测试申请', desc: '申请事由', time: '2026-12-31T08:00:00Z', deadlineUtc: '2027-01-01T04:00:00Z', missingHolidayYears: [2026, 2027], college: '学院' }], total: 1, page: 1, pageSize: 20, counts: { CourseExemption: 1 }, timelinessEnabled: true } })
|
||||
if (path === '/api/auth/me') return route.fulfill({ json: user })
|
||||
if (path === '/api/approvals/reviewed') return route.fulfill({ json: { items: [], total: 0 } })
|
||||
if (path === '/api/student-leaves/pending' || path === '/api/plugins/runtime' || path === '/api/approvals/grade-records') return route.fulfill({ json: [] })
|
||||
return route.fulfill({ json: {} })
|
||||
})
|
||||
await page.goto('/approvals?tab=pending')
|
||||
const card = page.locator('.appr-card').filter({ hasText: '测试申请' })
|
||||
await expect(card.getByText('未发现 2026, 2027 年的已启用节假日同步数据,处理目标可能不准确,请联系管理员核查校历。')).toBeVisible()
|
||||
await expect(card.getByText(/北京时间/)).toBeVisible()
|
||||
})
|
||||
|
||||
test('a teacher can open a specific attendance appeal and return to all pending items', async ({ page }) => {
|
||||
const user = { id: 'teacher', userName: 'teacher', displayName: '教师', roles: ['Teacher'], permissions: [], effectiveDataScope: 'Self' }
|
||||
await page.addInitScript(savedUser => {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
export default {
|
||||
approvalDeadlineOverdue: "Overdue · {time} (Beijing time)",
|
||||
approvalDeadlineTarget: "Target · {time} (Beijing time)",
|
||||
approvalHolidayMissing: "No enabled holiday data found for {years}. The target may be inaccurate; ask an administrator to check the calendar.",
|
||||
approvalCurrentCycleOnly: "Only the current submission cycle is shown.",
|
||||
approvalTeacherCurrentCycle:
|
||||
|
||||
Loaded 3 of 5 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user