feat: 新增 target description 字段,收紧 id/name 长度,调整延迟列和名称列
This commit is contained in:
@@ -9,6 +9,7 @@ import { OverviewTab } from "../../../src/web/components/OverviewTab";
|
||||
describe("OverviewTab", () => {
|
||||
const target: TargetStatus = {
|
||||
currentStreak: null,
|
||||
description: null,
|
||||
group: "default",
|
||||
id: "1",
|
||||
interval: "30s",
|
||||
|
||||
@@ -19,6 +19,7 @@ describe("TargetBoard", () => {
|
||||
const targets: TargetStatus[] = [
|
||||
{
|
||||
currentStreak: null,
|
||||
description: null,
|
||||
group: "default",
|
||||
id: "1",
|
||||
interval: "30s",
|
||||
@@ -31,6 +32,7 @@ describe("TargetBoard", () => {
|
||||
},
|
||||
{
|
||||
currentStreak: null,
|
||||
description: null,
|
||||
group: "production",
|
||||
id: "2",
|
||||
interval: "30s",
|
||||
|
||||
@@ -9,6 +9,7 @@ import { TargetDetailDrawer } from "../../../src/web/components/TargetDetailDraw
|
||||
describe("TargetDetailDrawer", () => {
|
||||
const target: TargetStatus = {
|
||||
currentStreak: null,
|
||||
description: null,
|
||||
group: "default",
|
||||
id: "1",
|
||||
interval: "30s",
|
||||
|
||||
@@ -15,6 +15,7 @@ describe("TargetGroup", () => {
|
||||
const targets: TargetStatus[] = [
|
||||
{
|
||||
currentStreak: null,
|
||||
description: null,
|
||||
group: "default",
|
||||
id: "1",
|
||||
interval: "30s",
|
||||
@@ -33,6 +34,7 @@ describe("TargetGroup", () => {
|
||||
},
|
||||
{
|
||||
currentStreak: null,
|
||||
description: null,
|
||||
group: "default",
|
||||
id: "2",
|
||||
interval: "30s",
|
||||
|
||||
@@ -20,6 +20,7 @@ function getColumn(columns: Array<PrimaryTableCol<TargetStatus>>, colKey: string
|
||||
function makeTarget(overrides: Partial<TargetStatus> = {}): TargetStatus {
|
||||
return {
|
||||
currentStreak: null,
|
||||
description: null,
|
||||
group: "default",
|
||||
id: "1",
|
||||
interval: "5s",
|
||||
@@ -119,7 +120,40 @@ describe("createTargetTableColumns", () => {
|
||||
rowIndex: 0,
|
||||
});
|
||||
|
||||
expect(element.props.children).toBe("9999+ms");
|
||||
expect(element.props.children).toBe("9999+");
|
||||
expect(element.props.className).toContain("latency-value");
|
||||
});
|
||||
|
||||
test("延迟列标题为 延迟(ms)", () => {
|
||||
const latencyColumn = getColumn(createTargetTableColumns(["http"]), "latestCheck.durationMs");
|
||||
expect(latencyColumn.title).toBe("延迟(ms)");
|
||||
});
|
||||
|
||||
test("延迟列正常值不包含 ms 单位", () => {
|
||||
const latencyColumn = getColumn(createTargetTableColumns(["http"]), "latestCheck.durationMs");
|
||||
const renderCell = latencyColumn.cell as (params: PrimaryTableCellParams<TargetStatus>) => {
|
||||
props: { children: string; className: string };
|
||||
};
|
||||
const element = renderCell({
|
||||
col: latencyColumn,
|
||||
colIndex: 6,
|
||||
row: makeTarget({
|
||||
latestCheck: {
|
||||
durationMs: 123,
|
||||
failure: null,
|
||||
matched: true,
|
||||
statusDetail: "200",
|
||||
timestamp: "2026-01-01T00:00:00.000Z",
|
||||
},
|
||||
}),
|
||||
rowIndex: 0,
|
||||
});
|
||||
expect(element.props.children).toBe("123");
|
||||
});
|
||||
|
||||
test("名称列无排序配置", () => {
|
||||
const nameColumn = getColumn(createTargetTableColumns(["http"]), "name");
|
||||
expect(nameColumn.sorter).toBeUndefined();
|
||||
expect(nameColumn.sortType).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,16 +2,12 @@ import { describe, expect, test } from "bun:test";
|
||||
|
||||
import type { TargetStatus } from "../../../src/shared/api";
|
||||
|
||||
import {
|
||||
availabilitySorter,
|
||||
latencySorter,
|
||||
nameSorter,
|
||||
statusSorter,
|
||||
} from "../../../src/web/constants/target-table-sorters";
|
||||
import { availabilitySorter, latencySorter, statusSorter } from "../../../src/web/constants/target-table-sorters";
|
||||
|
||||
function makeTarget(overrides: Partial<TargetStatus> = {}): TargetStatus {
|
||||
return {
|
||||
currentStreak: null,
|
||||
description: null,
|
||||
group: "default",
|
||||
id: "1",
|
||||
interval: "5s",
|
||||
@@ -97,18 +93,3 @@ describe("latencySorter", () => {
|
||||
expect(latencySorter(noLatency, hasLatency)).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("nameSorter", () => {
|
||||
test("按名称字母排序", () => {
|
||||
const a = makeTarget({ name: "Alpha" });
|
||||
const b = makeTarget({ name: "Beta" });
|
||||
expect(nameSorter(a, b)).toBeLessThan(0);
|
||||
});
|
||||
|
||||
test("中文名称排序", () => {
|
||||
const a = makeTarget({ name: "百度" });
|
||||
const b = makeTarget({ name: "谷歌" });
|
||||
const result = nameSorter(a, b);
|
||||
expect(typeof result).toBe("number");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user