64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readSource } from './helpers.ts'
|
|
import {
|
|
dedupeGroupSummaryOf,
|
|
parseDedupeGroupOptionList,
|
|
type DedupeGroupOption,
|
|
} from '../src/pages/asin/dedupe-total-model.ts'
|
|
|
|
/** 对齐 admin.js:4355-4380 renderDedupeGroupSummary / 3362-3365 导出等待 / 3306 未分组。 */
|
|
|
|
function group(id: number, name: string, leaderUserId: number | null = null): DedupeGroupOption {
|
|
return { id, name, leaderUserId }
|
|
}
|
|
|
|
test('align_dedupe_summary_super_admin_shows_all_count', () => {
|
|
const summary = dedupeGroupSummaryOf([group(1, 'A组'), group(2, 'B组')], 99, 'super_admin')
|
|
assert.deepEqual(summary, { kind: 'all', count: 2 })
|
|
})
|
|
|
|
test('align_dedupe_summary_non_super_empty_shows_not_joined', () => {
|
|
const summary = dedupeGroupSummaryOf([], 7, 'admin')
|
|
assert.deepEqual(summary, { kind: 'none' })
|
|
})
|
|
|
|
test('align_dedupe_summary_chips_with_relation', () => {
|
|
const summary = dedupeGroupSummaryOf([group(1, 'A组', 7), group(2, 'B组', 9)], 7, 'admin')
|
|
assert.deepEqual(summary, {
|
|
kind: 'chips',
|
|
chips: [
|
|
{ name: 'A组', relation: '组长' },
|
|
{ name: 'B组', relation: '组员' },
|
|
],
|
|
extra: 0,
|
|
})
|
|
})
|
|
|
|
test('align_dedupe_summary_caps_at_four_with_extra', () => {
|
|
const groups = [1, 2, 3, 4, 5, 6].map((id) => group(id, `G${id}`, 9))
|
|
const summary = dedupeGroupSummaryOf(groups, 7, 'admin')
|
|
assert.equal(summary.kind, 'chips')
|
|
if (summary.kind === 'chips') {
|
|
assert.equal(summary.chips.length, 4)
|
|
assert.equal(summary.extra, 2)
|
|
}
|
|
})
|
|
|
|
test('align_dedupe_group_option_parses_leader', () => {
|
|
const options = parseDedupeGroupOptionList({
|
|
success: true,
|
|
data: { items: [{ id: 3, group_name: 'C组', leader_user_id: 12 }] },
|
|
})
|
|
assert.deepEqual(options, [{ id: 3, name: 'C组', leaderUserId: 12 }])
|
|
})
|
|
|
|
test('align_dedupe_page_summary_and_export_wait_wiring', () => {
|
|
const page = readSource('src/pages/asin/DedupeRegistryPage.vue')
|
|
assert.match(page, /数据权限分组/, '页顶数据权限分组汇总卡')
|
|
assert.match(page, /dedupeGroupSummaryOf/, '汇总走纯模型')
|
|
assert.match(page, /正在生成导出文件/, '导出等待遮罩文案对齐')
|
|
assert.match(page, /已等待/, '导出等待含等待秒数')
|
|
assert.match(page, /未分组/, '分组空值显示未分组')
|
|
})
|