cmvr-wms/mobile-app/tests/production-connection.test.mjs
lixiaolong 95effeeff2 feat(app): 优化移动端应用配置和功能实现
- 添加生产环境服务器地址配置支持内外网切换
- 实现采购列表只看我创建的功能开关
- 更新构建脚本中的默认生产环境API地址
- 优化采购单表格单元格编辑体验改用自动补全组件
- 调整应用更新检查逻辑增强生产环境兼容性
- 修复开发服务器切换时的一些验证问题
- 增强应用启动时的服务地址配置灵活性
2026-10-29 17:27:46 +08:00

17 lines
1.2 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {createRequire} from 'node:module';
import {productionServer,PRODUCTION_PUBLIC_URL,PRODUCTION_INTERNAL_URL,internalUrl} from '../src/core/network.ts';
const require=createRequire(import.meta.url);
const {internal}=require('../config/environment.cjs');
test('production connection choices are fixed to trusted endpoints',()=>{
assert.equal(productionServer(PRODUCTION_PUBLIC_URL),PRODUCTION_PUBLIC_URL);
assert.equal(productionServer(PRODUCTION_INTERNAL_URL),PRODUCTION_INTERNAL_URL);
for(const value of ['http://wms.svc.cmvr-iot.icu/prod-api','https://wms.svc.cmvr-iot.icu.evil.test/prod-api','https://wms.svc.cmvr-iot.icu/other','https://wms.svc.cmvr-iot.icu/prod-api?x=1','http://192.168.0.1/prod-api']) assert.throws(()=>productionServer(value));
assert.throws(()=>internalUrl(PRODUCTION_PUBLIC_URL,true));
assert.equal(internal('https://wms.svc.cmvr-iot.icu',false,true),'https://wms.svc.cmvr-iot.icu');
assert.throws(()=>internal('https://wms.svc.cmvr-iot.icu',true,false));
assert.throws(()=>internal('http://wms.svc.cmvr-iot.icu',false,true));
assert.throws(()=>internal('https://wms.svc.cmvr-iot.icu.evil.test',false,true));
});