来源仓库:jxc/ai-fresh-delivery 来源提交:f0b1a180e2deb7e4673b9d1c8542619f7bc0f73d 快照树: 09f679334ff38f0ff25e907961c94a8223bcaedd(与来源 HEAD 工作树逐字节一致,3801 个文件) 按约定本仓库不带任何历史提交:来源仓库的历史中含真实凭据 (生产 SSH 私钥 deploy/id_rsa_tencent、server/.env、.env.tencent/.env.production/.env.gitea、 deploy/小程序AppSecret.txt,其中 MP_APPSECRET / S3 AccessKey 经哈希比对与线上同值), 整包推送会把这些凭据永久带入本仓库,故只取「当前版本」的单提交快照。 供应商系统后续开发自本提交开始。
40 lines
1.9 KiB
TypeScript
40 lines
1.9 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
||
import { describe, expect, it } from 'vitest';
|
||
|
||
/**
|
||
* 系统配置页「智能分配」开关(仅管理员)回归。
|
||
*
|
||
* 背景:原「手动分配」页 /orders/allocation 删除后,该开关曾三次尝试都以「看不见」告终:
|
||
* 1) 只补保存逻辑,未处理缺配置行;
|
||
* 2) 做成配置行渲染,但落在 showPlatformConfigSections(= 超管 && 平台范围)块内,
|
||
* 分公司管理员恒为 false,整个分组块不执行;
|
||
* 3) 配置行按分公司存储,分公司管理员读不到行、作用域过滤再收窄。
|
||
*
|
||
* 现方案:独立面板 + 专用接口(按分公司 upsert),完全不依赖 configs 表与作用域逻辑。
|
||
* 本测试锁住该结构,避免退回「依赖 configs 表」的实现。
|
||
*/
|
||
describe('smart allocation switch contract', () => {
|
||
const src = readFileSync(new URL('./SystemConfig.tsx', import.meta.url), 'utf8');
|
||
|
||
it('走专用接口读写,不经 configs 表', () => {
|
||
expect(src).toMatch(/fetchSmartAllocationConfigApi\(\)/);
|
||
expect(src).toMatch(/saveSmartAllocationConfigApi\(smartAllocationEnabled\)/);
|
||
});
|
||
|
||
it('用独立本地状态,不从 configs/drafts 取开关值', () => {
|
||
expect(src).toMatch(/const \[smartAllocationEnabled, setSmartAllocationEnabled\] = useState/);
|
||
expect(src).toMatch(/const \[smartAllocationSaving, setSmartAllocationSaving\] = useState/);
|
||
});
|
||
|
||
it('仅管理员可见,且不依赖超管专属的 showPlatformConfigSections', () => {
|
||
expect(src).toMatch(/\{showBranchSkuAiImageSection && renderSmartAllocationPanel\(\)\}/);
|
||
expect(src).not.toMatch(/showPlatformConfigSections \|\| showSmartAllocation/);
|
||
});
|
||
|
||
it('渲染面板含勾选框与保存按钮', () => {
|
||
expect(src).toMatch(/renderSmartAllocationPanel/);
|
||
expect(src).toMatch(/system\.config\.smartAlloc\.section/);
|
||
expect(src).toMatch(/saveSmartAllocationSwitch/);
|
||
});
|
||
});
|