|
|
@@ -158,6 +158,32 @@ describe('parse-api 字段归一(兼容非标准容器)', () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ describe('balance 归一:容器复刻脚本键名', () => {
|
|
|
+ it('🔴 容器发 {"cny":91.46} → remainCny 有值(修复余额不显示)', async () => {
|
|
|
+ stubFetch({ code: 200, agents: [{ agentId: 'a', balance: '{"source":"session","cny":91.46}' }] });
|
|
|
+ const [a] = await api.fetchAgents();
|
|
|
+ expect(a.balance?.remainCny).toBe(91.46);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('契约标准 remainCny 优先于 cny', async () => {
|
|
|
+ stubFetch({ code: 200, agents: [{ agentId: 'a', balance: '{"remainCny":10,"cny":99}' }] });
|
|
|
+ const [a] = await api.fetchAgents();
|
|
|
+ expect(a.balance?.remainCny).toBe(10);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('旧键 remainRmb 仍兼容', async () => {
|
|
|
+ stubFetch({ code: 200, agents: [{ agentId: 'a', balance: '{"remainRmb":7.5}' }] });
|
|
|
+ const [a] = await api.fetchAgents();
|
|
|
+ expect(a.balance?.remainCny).toBe(7.5);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('source=none 无金额 → remainCny 为 undefined(UI 显示 —)', async () => {
|
|
|
+ stubFetch({ code: 200, agents: [{ agentId: 'a', balance: '{"source":"none"}' }] });
|
|
|
+ const [a] = await api.fetchAgents();
|
|
|
+ expect(a.balance?.remainCny).toBeUndefined();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
describe('综合:非标准容器的完整映射', () => {
|
|
|
it('数组 channels + cpuLoad1 + probedAt → 全部归一正确', async () => {
|
|
|
stubFetch({
|