feat(category): 类目树、类目属性、属性字典维护系统构建完成

This commit is contained in:
R524809
2026-09-20 15:11:32 +08:00
parent 388429dbd0
commit 880e441bc6
48 changed files with 5127 additions and 1159 deletions
@@ -0,0 +1,44 @@
import assert from 'node:assert/strict';
import { describe, it } from 'vitest';
import { productCatalogCacheStatus } from '../src/product-editor/product-editor.catalog-cache.js';
describe('商品编辑器平台目录新鲜度边界', () => {
const day = 86_400_000;
const now = Date.parse('2026-09-20T00:00:00.000Z');
it('从未成功同步时为 missing', () => {
assert.equal(productCatalogCacheStatus(null, 14, 21, now), 'missing');
});
it('14 天前为 fresh,恰好 14 天进入 stale', () => {
assert.equal(
productCatalogCacheStatus(
new Date(now - 14 * day + 1),
14,
21,
now,
),
'fresh',
);
assert.equal(
productCatalogCacheStatus(new Date(now - 14 * day), 14, 21, now),
'stale',
);
});
it('恰好 21 天仍 stale,严格超过才 expired', () => {
assert.equal(
productCatalogCacheStatus(new Date(now - 21 * day), 14, 21, now),
'stale',
);
assert.equal(
productCatalogCacheStatus(
new Date(now - 21 * day - 1),
14,
21,
now,
),
'expired',
);
});
});