refactor: remove residual campus and department fields
This commit is contained in:
31
apps/server/src/archive/archive-report.service.spec.ts
Normal file
31
apps/server/src/archive/archive-report.service.spec.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { ArchiveReportService } from './archive-report.service';
|
||||
|
||||
describe('ArchiveReportService retired profile fields', () => {
|
||||
it('does not render the retired campus field in a student report', async () => {
|
||||
const service = new ArchiveReportService(
|
||||
{ findOne: jest.fn().mockResolvedValue({ campusLocation: '旧校区', grade: '高三' }) } as never,
|
||||
{ find: jest.fn().mockResolvedValue([]) } as never,
|
||||
{ find: jest.fn().mockResolvedValue([]) } as never,
|
||||
{ find: jest.fn().mockResolvedValue([]) } as never,
|
||||
{ findOne: jest.fn().mockResolvedValue(null) } as never,
|
||||
{ find: jest.fn().mockResolvedValue([]) } as never,
|
||||
{
|
||||
findOne: jest.fn().mockResolvedValue({
|
||||
id: 1,
|
||||
name: '测试学生',
|
||||
gender: '男',
|
||||
phone: '',
|
||||
ethnicity: '',
|
||||
emergencyContact: '',
|
||||
emergencyPhone: '',
|
||||
}),
|
||||
} as never,
|
||||
);
|
||||
|
||||
const html = await service.generateReportHtml(1);
|
||||
|
||||
expect(html).not.toContain('旧校区');
|
||||
expect(html).not.toContain('<span>校区</span>');
|
||||
expect(html).toContain('高三');
|
||||
});
|
||||
});
|
||||
@@ -308,7 +308,6 @@ ${this.buildLearningAndResult(learnings, result, now)}
|
||||
<div class="summary-row"><span>民族</span><span>${this.esc(student.ethnicity || '-')}</span></div>
|
||||
<div class="summary-row"><span>紧急联系人</span><span>${this.esc(student.emergencyContact || '-')}</span></div>
|
||||
<div class="summary-row"><span>紧急电话</span><span>${this.esc(student.emergencyPhone || '-')}</span></div>
|
||||
<div class="summary-row"><span>校区</span><span>${this.esc(profile?.campusLocation || '-')}</span></div>
|
||||
<div class="summary-row"><span>年级</span><span>${this.esc(profile?.grade || '-')}</span></div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
18
apps/server/src/archive/dto/archive.dto.spec.ts
Normal file
18
apps/server/src/archive/dto/archive.dto.spec.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'reflect-metadata';
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
import { validate } from 'class-validator';
|
||||
import { UpsertProfileDto } from './archive.dto';
|
||||
|
||||
describe('UpsertProfileDto retired fields', () => {
|
||||
it('removes the retired campusLocation field under whitelist validation', async () => {
|
||||
const dto = plainToInstance(UpsertProfileDto, {
|
||||
grade: '高三',
|
||||
campusLocation: '旧校区',
|
||||
});
|
||||
|
||||
await validate(dto, { whitelist: true });
|
||||
|
||||
expect(dto).toMatchObject({ grade: '高三' });
|
||||
expect(dto).not.toHaveProperty('campusLocation');
|
||||
});
|
||||
});
|
||||
@@ -5,7 +5,6 @@ export class UpsertProfileDto {
|
||||
@IsOptional() @IsString() targetMajor?: string;
|
||||
@IsOptional() @IsString() subjectDirection?: string;
|
||||
@IsOptional() @IsString() grade?: string;
|
||||
@IsOptional() @IsString() campusLocation?: string;
|
||||
@IsOptional() @IsDateString() profileDate?: string;
|
||||
@IsOptional() @IsString() notes?: string;
|
||||
}
|
||||
|
||||
@@ -33,9 +33,6 @@ export class StudentProfile {
|
||||
@Column({ length: 20, nullable: true })
|
||||
grade: string;
|
||||
|
||||
@Column({ name: 'campus_location', length: 100, nullable: true })
|
||||
campusLocation: string;
|
||||
|
||||
@Column({ name: 'profile_date', type: 'date', nullable: true })
|
||||
profileDate: string;
|
||||
|
||||
|
||||
@@ -27,3 +27,21 @@ describe('schedule notes validation', () => {
|
||||
expect(errors.some((error) => error.property === 'notes')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('removes the retired departmentId field from create requests', async () => {
|
||||
const dto = Object.assign(new CreateScheduleDto(), {
|
||||
classId: 1,
|
||||
classroomId: 2,
|
||||
weekDay: 1,
|
||||
startTime: '09:00',
|
||||
endTime: '10:00',
|
||||
startDate: '2026-07-01',
|
||||
endDate: '2026-07-31',
|
||||
subject: '语文',
|
||||
departmentId: 99,
|
||||
});
|
||||
|
||||
await validate(dto, { whitelist: true });
|
||||
|
||||
expect(dto).not.toHaveProperty('departmentId');
|
||||
});
|
||||
|
||||
@@ -63,9 +63,6 @@ export class CreateScheduleDto {
|
||||
@MaxLength(500)
|
||||
notes?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
departmentId?: number;
|
||||
}
|
||||
|
||||
export class UpdateScheduleDto {
|
||||
|
||||
Reference in New Issue
Block a user