import assert from 'node:assert/strict'
import test from 'node:test'

import { resolveProgressStepsForViewer } from '../src/utils/requestProgressViewer.js'

test('progress viewer keeps approver name for applicant view', () => {
  const steps = [
    {
      label: '等待 李经理 批复',
      rawLabel: '直属领导审批',
      current: true,
      title: '当前等待 李经理 批复已停留 3小时15分钟'
    }
  ]

  assert.deepEqual(
    resolveProgressStepsForViewer(steps, {
      isApplicationDocument: true,
      isCurrentDirectManagerApprover: false
    }),
    steps
  )
})

test('progress viewer hides approver name for current direct manager approval view', () => {
  const steps = [
    {
      label: '等待 李经理 批复',
      rawLabel: '直属领导审批',
      current: true,
      title: '当前等待 李经理 批复已停留 3小时15分钟'
    }
  ]

  assert.deepEqual(
    resolveProgressStepsForViewer(steps, {
      isApplicationDocument: true,
      isCurrentDirectManagerApprover: true
    }),
    [
      {
        label: '等待批复',
        rawLabel: '直属领导审批',
        current: true,
        title: '当前等待批复已停留 3小时15分钟'
      }
    ]
  )
})
