2aa9d73325
集中保留原版权声明,移除文件头检查和全局测试忽略规则。验证:全量单测、受影响用例复测及静态检查通过。
90 lines
2.9 KiB
JavaScript
90 lines
2.9 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
import test from 'node:test';
|
|
|
|
const hook = readFileSync(
|
|
new URL('../src/hooks/task-logs/useTaskLogsData.js', import.meta.url),
|
|
'utf8',
|
|
);
|
|
const columns = readFileSync(
|
|
new URL(
|
|
'../src/components/table/task-logs/TaskLogsColumnDefs.jsx',
|
|
import.meta.url,
|
|
),
|
|
'utf8',
|
|
);
|
|
const actions = readFileSync(
|
|
new URL(
|
|
'../src/components/table/task-logs/TaskLogsActions.jsx',
|
|
import.meta.url,
|
|
),
|
|
'utf8',
|
|
);
|
|
const filters = readFileSync(
|
|
new URL(
|
|
'../src/components/table/task-logs/TaskLogsFilters.jsx',
|
|
import.meta.url,
|
|
),
|
|
'utf8',
|
|
);
|
|
const orgLogs = readFileSync(
|
|
new URL('../src/pages/Organization/OrgLogs.jsx', import.meta.url),
|
|
'utf8',
|
|
);
|
|
const orgTaskRecords = readFileSync(
|
|
new URL(
|
|
'../src/pages/Organization/components/OrgTaskRecords.jsx',
|
|
import.meta.url,
|
|
),
|
|
'utf8',
|
|
);
|
|
const usageRecord = readFileSync(
|
|
new URL('../src/pages/UserCenter/UsageRecord.jsx', import.meta.url),
|
|
'utf8',
|
|
);
|
|
|
|
test('enterprise task records use the organization-scoped endpoint', () => {
|
|
assert.match(hook, /organizationMode/);
|
|
assert.match(hook, /`\/api\/org\/tasks\?\$\{params\.toString\(\)\}`/);
|
|
assert.match(hook, /DEFAULT_TASK_RANGE_DAYS = 7/);
|
|
assert.match(hook, /const usesSharedDateRange/);
|
|
assert.match(filters, /hideDateRange = false/);
|
|
assert.match(filters, /!hideDateRange/);
|
|
});
|
|
|
|
// 2026-11-07 用户确认:与原型一致,“绘图与视频”使用自身可编辑的时间范围,不再复用“明细日志”已提交区间
|
|
test('enterprise task records keep their own editable date range', () => {
|
|
assert.match(orgLogs, /<OrgTaskRecords \/>/);
|
|
assert.doesNotMatch(orgLogs, /sharedStartTimestamp=/);
|
|
assert.match(
|
|
orgTaskRecords,
|
|
/useTaskLogsData\(\{ organizationMode: true \}\)/,
|
|
);
|
|
assert.doesNotMatch(orgTaskRecords, /hideDateRange/);
|
|
assert.match(orgTaskRecords, /<TaskLogsFilters \{\.\.\.taskLogsData\} usageRecordMode \/>/);
|
|
});
|
|
|
|
test('platform is not exposed as a task-log presentation field', () => {
|
|
assert.doesNotMatch(columns, /COLUMN_KEYS\.PLATFORM/);
|
|
assert.doesNotMatch(columns, /title: t\('平台'\)/);
|
|
assert.doesNotMatch(actions, /key: 'platform'/);
|
|
assert.doesNotMatch(actions, /title: t\('平台'\)/);
|
|
});
|
|
|
|
test('task details can only be opened by the system root user', () => {
|
|
assert.match(
|
|
hook,
|
|
/import \{[\s\S]*isRoot[\s\S]*\} from '\.\.\/\.\.\/helpers';/,
|
|
);
|
|
assert.match(hook, /const isRootUser = !organizationMode && isRoot\(\);/);
|
|
assert.match(columns, /isRootUser = false/);
|
|
assert.match(columns, /isRootUser\s*\?\s*\(\) => openContentModal/);
|
|
assert.match(columns, /isRootUser\s*\?\s*'cursor-pointer/);
|
|
});
|
|
|
|
test('personal usage records reuse the same platform-free task view', () => {
|
|
assert.match(usageRecord, /<TaskLogsTable usageRecordMode \/>/);
|
|
assert.doesNotMatch(actions, /key: 'platform'/);
|
|
assert.match(columns, /isRootUser\s*\?\s*\(\) => openContentModal/);
|
|
});
|