- 补入库:server/internal/db/dump.go、redis 分页/扫描预算测试、opsxdb-mcp main_test、 packages/opsxdb-mcp package-lock、docs 审计与对比文档等 37 个新文件 - 含结构扁平化进行中的 80 处修改与 155 处旧结构删除(server/ src/ src-tauri/ 为当前有效源) - 构建产物(bin/target/dist)与签名私钥仍按规则排除
33 lines
1.6 KiB
TypeScript
33 lines
1.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { cellPreview, compareCells, filterRows, suggestedColumnWidth } from "./resultView";
|
|
|
|
describe("结果展示边界", () => {
|
|
it("大整数文本排序不丢精度", () => {
|
|
expect(compareCells("9007199254740993", "9007199254740992")).toBe(1);
|
|
expect(compareCells("-9007199254740993", "-9007199254740992")).toBe(-1);
|
|
expect(compareCells(null, "")).toBe(-1);
|
|
expect(compareCells("1.2", "1.11")).toBeGreaterThan(0);
|
|
expect(compareCells("1e3", "999")).toBeGreaterThan(0);
|
|
});
|
|
it("本地筛选覆盖 NULL、JSON、布尔值,不修改原数组", () => {
|
|
const rows = [{ x: null }, { x: { name: "Alice" } }, { x: false }, { x: "" }];
|
|
expect(filterRows(rows, ["x"], "alice")).toEqual([rows[1]]);
|
|
expect(filterRows(rows, ["x"], "NULL")).toEqual([rows[0]]);
|
|
expect(filterRows(rows, ["x"], "false")).toEqual([rows[2]]);
|
|
expect(filterRows(rows, ["x"], " ")).toBe(rows);
|
|
expect(rows).toHaveLength(4);
|
|
});
|
|
it("长 JSON 与文本都截断预览,原值保留", () => {
|
|
const value = { text: "x".repeat(500) };
|
|
expect(cellPreview(value)).toHaveLength(121);
|
|
expect(value.text).toHaveLength(500);
|
|
expect(cellPreview(false)).toBe("false");
|
|
expect(cellPreview(0)).toBe("0");
|
|
});
|
|
it("自动列宽有上下限并考虑中文宽度", () => {
|
|
expect(suggestedColumnWidth("id", [])).toBe(88);
|
|
expect(suggestedColumnWidth("数据", [{ 数据: "中".repeat(100) }])).toBe(480);
|
|
expect(suggestedColumnWidth("name", [{ name: "中国数据库" }])).toBeGreaterThan(88);
|
|
});
|
|
});
|