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

import { resolveAiSidebarBusinessViewIds } from '../src/utils/aiSidebarBusinessAccess.js'

test('AI sidebar shows three business entries for regular employees', () => {
  assert.deepEqual(resolveAiSidebarBusinessViewIds({ name: '普通员工', roleCodes: [] }), [
    'documents',
    'receiptFolder',
    'policies'
  ])
})

test('AI sidebar adds budget management for budget monitors', () => {
  assert.deepEqual(resolveAiSidebarBusinessViewIds({ name: '预算管理员', roleCodes: ['budget_monitor'] }), [
    'documents',
    'receiptFolder',
    'policies',
    'budget'
  ])
})

test('AI sidebar adds finance capabilities for finance users', () => {
  assert.deepEqual(resolveAiSidebarBusinessViewIds({ name: '财务负责人', roleCodes: ['finance'] }), [
    'documents',
    'receiptFolder',
    'policies',
    'overview',
    'audit',
    'digitalEmployees'
  ])
})

test('AI sidebar keeps workbench and settings out of the steward business layer', () => {
  const viewIds = resolveAiSidebarBusinessViewIds({ username: 'admin', isAdmin: true, roleCodes: ['admin'] })

  assert.equal(viewIds.includes('workbench'), false)
  assert.equal(viewIds.includes('settings'), false)
})
