52 lines
3.2 KiB
TypeScript
52 lines
3.2 KiB
TypeScript
import { currentSalaryMonth, getSalaryTemplate, resolveSalaryMonth, salaryDetailsHref, salaryMonthLabel } from '@/lib/performance-salary-templates'
|
||
|
||
describe('薪资模板月份与字段', () => {
|
||
test('上海时区跨月及非法查询参数', () => {
|
||
const now = new Date('2026-12-31T16:00:00Z')
|
||
expect(currentSalaryMonth(now)).toBe('2027-01')
|
||
for (const value of [undefined, '', '2026-13', '2026-1', '0000-01', ['2026-09'], '2026-09<script>']) {
|
||
expect(resolveSalaryMonth(value, now)).toBe('2027-01')
|
||
}
|
||
expect(resolveSalaryMonth('2026-09', now)).toBe('2026-09')
|
||
expect(salaryMonthLabel('2027-01', -1)).toBe('2026年12月')
|
||
expect(salaryMonthLabel('2027-01', -2)).toBe('2026年11月')
|
||
expect(salaryDetailsHref('management', '2027-01')).toBe('/workspaces/organization/performance-review?role=management&month=2027-01')
|
||
})
|
||
|
||
test('AI按原表保留25列,并删除三项保底字段', () => {
|
||
const template = getSalaryTemplate('ai-planning', '2026-09')
|
||
expect(template.columns.map(column => column.label)).toEqual([
|
||
'姓名', '花名', '部门', '品牌', '基本工资', '职级工资', '绩效工资', '2026年9月积分',
|
||
'品牌调性评审案例评分', '品牌调性评审绩效占比100%', '跨部门协同评分', '跨部门协同绩效占比0%',
|
||
'创意成果市场验证评分', '创意成果市场验证绩效占比10%', '项目按时交付率', '项目按时交付率绩效占比90%',
|
||
'知识分享/月度复盘分享', '知识分享/月度复盘分享0%', '工作配合度评分', '工作配合度绩效占比100%',
|
||
'绩效得分', '2026年9月合计总薪资', '2026年8月合计总薪资', '基础薪资差值', '备注',
|
||
])
|
||
})
|
||
|
||
test('摄影保留16列,薪资比较月份跨年', () => {
|
||
const template = getSalaryTemplate('photography', '2027-01')
|
||
expect(template.columns).toHaveLength(16)
|
||
expect(template.grouped).toBe(false)
|
||
expect(template.columns.slice(11, 14).map(column => column.label)).toEqual(['2027年1月合计薪资', '2026年12月合计薪资', '2026年11月合计薪资'])
|
||
})
|
||
|
||
test('空间视觉21列,保留原表不同的分区与单项权重,不建立公式', () => {
|
||
const template = getSalaryTemplate('spatial-visual', '2026-10')
|
||
expect(template.columns).toHaveLength(21)
|
||
expect(template.columns.map(column => column.label)).not.toEqual(expect.arrayContaining(['百分比', '实际绩效']))
|
||
expect(template.groups.find(group => group.key === 'cooperation')?.label).toBe('配合度 · 维度权重5%')
|
||
expect(template.columns.map(column => column.label)).toContain('工作配合度绩效占比6%')
|
||
})
|
||
|
||
test('管理岗合并为23列,身份唯一,保留得分与系数', () => {
|
||
const template = getSalaryTemplate('management', '2027-01')
|
||
const labels = template.columns.map(column => column.label)
|
||
expect(labels).toHaveLength(23)
|
||
expect(labels.filter(label => ['姓名', '花名', '部门'].includes(label))).toEqual(['姓名', '花名', '部门'])
|
||
expect(labels).not.toContain('保护提成')
|
||
expect(labels).toEqual(expect.arrayContaining(['2027年1月绩效得分', '绩效系数', '2027年1月新薪资', '2026年12月薪资']))
|
||
expect(new Set(template.columns.map(column => column.key)).size).toBe(23)
|
||
})
|
||
})
|