fix: 识别无邪生产账号删除权限
This commit is contained in:
parent
b0f9c026bd
commit
c63ec96dab
@ -535,7 +535,7 @@ describe('考核调研顶层导航保护', () => {
|
||||
})
|
||||
|
||||
test('公共看板仅按后端权限在分数下显示删除按钮并彻底删除单项调研', async () => {
|
||||
mockSearchParams = new URLSearchParams('tab=public&workspace=pending')
|
||||
mockSearchParams = new URLSearchParams('tab=public&workspace=pending&month=2026-07')
|
||||
let dashboardRequestCount = 0
|
||||
const deleteRequests: Array<{ url: string; init?: RequestInit }> = []
|
||||
global.fetch = jest.fn(async (input, init) => {
|
||||
|
||||
@ -1105,7 +1105,8 @@ function PerformanceDashboardBoard({
|
||||
canCreateSurvey?: boolean
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const [month, setMonth] = useState(getCurrentMonthValue())
|
||||
const searchParams = useSearchParams()
|
||||
const [month, setMonth] = useState(searchParams.get('month') || getCurrentMonthValue())
|
||||
const [department, setDepartment] = useState('')
|
||||
const [employee, setEmployee] = useState<Employee | null>(null)
|
||||
const [positionGroupCode, setPositionGroupCode] = useState('')
|
||||
|
||||
@ -457,7 +457,7 @@ describe('performance survey service policies', () => {
|
||||
expect(result.permissions.canDeletePublicDashboardAssessment).toBe(false)
|
||||
})
|
||||
|
||||
test('只有无邪账号获得公共看板人员移除权限', async () => {
|
||||
test('只有无邪账号获得公共看板单项调研删除权限', async () => {
|
||||
;(prisma.user.findUnique as jest.Mock).mockResolvedValue({
|
||||
...baseUser,
|
||||
username: 'wuxie',
|
||||
@ -470,6 +470,17 @@ describe('performance survey service policies', () => {
|
||||
|
||||
expect(result.permissions.canDeletePublicDashboardAssessment).toBe(true)
|
||||
|
||||
;(prisma.user.findUnique as jest.Mock).mockResolvedValue({
|
||||
...baseUser,
|
||||
username: '无邪',
|
||||
})
|
||||
|
||||
const productionAccountResult = await getPerformanceSurveyDashboard(session, new URLSearchParams({
|
||||
view: 'public',
|
||||
month: '2026-07',
|
||||
}))
|
||||
expect(productionAccountResult.permissions.canDeletePublicDashboardAssessment).toBe(true)
|
||||
|
||||
;(prisma.user.findUnique as jest.Mock).mockResolvedValue({
|
||||
...baseUser,
|
||||
username: 'qingyun',
|
||||
@ -491,7 +502,7 @@ describe('performance survey service policies', () => {
|
||||
test('无邪可按人员、月份、岗位和考核项彻底删除调研并释放重复校验', async () => {
|
||||
;(prisma.user.findUnique as jest.Mock).mockResolvedValue({
|
||||
...baseUser,
|
||||
username: 'wuxie',
|
||||
username: '无邪',
|
||||
realName: '无邪',
|
||||
})
|
||||
transactionClient.performanceSurveyTarget.findMany.mockResolvedValue([{
|
||||
|
||||
@ -881,7 +881,8 @@ function ensureSystemAdministrator(ctx: UserContext) {
|
||||
}
|
||||
|
||||
function canDeletePerformanceSurveyPublicDashboardAssessment(ctx: UserContext) {
|
||||
return ctx.user.username.trim().toLowerCase() === 'wuxie'
|
||||
const username = ctx.user.username.trim().toLowerCase()
|
||||
return username === 'wuxie' || username === '无邪'
|
||||
}
|
||||
|
||||
function ensureCanDeletePerformanceSurveyPublicDashboardAssessment(ctx: UserContext) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user