fix(ui): 修复登录与并发请求并统一表格、主题和页面展示

验证:868 项单测、ESLint、Prettier、UI 依赖审计和差异检查通过。
This commit is contained in:
zhanjunhao
2026-11-19 18:58:46 +08:00
parent 99fe167103
commit 13105bdba5
128 changed files with 4672 additions and 5391 deletions
+60
View File
@@ -0,0 +1,60 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import assert from 'node:assert/strict';
import test from 'node:test';
import {
formatPercent,
formatRatioPercent,
formatIdReference,
formatUserReference,
toFiniteNumber,
} from '../../src/helpers/safeDisplay.js';
test('toFiniteNumber rejects missing and non-finite display values', () => {
assert.equal(toFiniteNumber(undefined), null);
assert.equal(toFiniteNumber(''), null);
assert.equal(toFiniteNumber('not-a-number'), null);
assert.equal(toFiniteNumber('12.5'), 12.5);
assert.equal(toFiniteNumber(Infinity), null);
});
test('percent formatters never expose invalid values', () => {
assert.equal(formatPercent(undefined), '-');
assert.equal(formatPercent('12.5'), '12.5%');
assert.equal(formatRatioPercent(undefined, 10), '-');
assert.equal(formatRatioPercent(2, 0), '-');
assert.equal(formatRatioPercent(2, 4), '50.0%');
});
test('user references never interpolate an undefined id', () => {
assert.equal(formatUserReference('Alice', undefined), 'Alice');
assert.equal(formatUserReference('', 42), 'User#42');
assert.equal(formatUserReference(undefined, undefined), '-');
assert.equal(
formatUserReference(undefined, 'bad', 'Unknown user'),
'Unknown user',
);
});
test('id references never expose a missing identifier', () => {
assert.equal(formatIdReference(undefined), '-');
assert.equal(formatIdReference(''), '-');
assert.equal(formatIdReference(42), '#42');
});