d5279b124f
Storage Persistence Guard / storage-persistence-audit (push) Has been cancelled
Client Quality Gates / Shared client and Web (push) Has been cancelled
Client Quality Gates / macOS Desktop (push) Has been cancelled
Client Quality Gates / Shared client and Web (pull_request) Has been cancelled
Client Quality Gates / macOS Desktop (pull_request) Has been cancelled
Storage Persistence Guard / storage-persistence-audit (pull_request) Has been cancelled
88 lines
3.8 KiB
TypeScript
88 lines
3.8 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { readFileSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
|
|
const readSource = () => readFileSync(resolve(__dirname, "./PermissionIpLocations.vue"), "utf8");
|
|
|
|
describe("PermissionIpLocations", () => {
|
|
it("integrates source metrics into a compact overview above the map", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).toContain('class="ip-overview"');
|
|
expect(source).toContain('aria-label="来源指标"');
|
|
expect(source).toContain('class="distribution-card"');
|
|
expect(source).toContain("min-height: 44px");
|
|
expect(source).toContain("grid-template-columns: minmax(0, 1fr) 300px");
|
|
expect(source).toContain("padding: 10px");
|
|
});
|
|
|
|
it("keeps compact metric grids responsive", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).toContain("@media (max-width: 1100px)");
|
|
expect(source).toContain("@media (max-width: 520px)");
|
|
expect(source).toContain(".metric-card:nth-child(odd)");
|
|
});
|
|
|
|
it("uses the complete desktop viewport for fullscreen maps", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).toContain('modal-class="source-map-overlay"');
|
|
expect(source).toContain(':option="fullscreenSourceMapOption"');
|
|
expect(source).toContain("buildFlowMapOption(flowSourceData.value, \"ctms-world\", 1, \"全球访问链路\")");
|
|
expect(source).toContain("buildFlowMapOption(chinaFlowSourceData.value, \"ctms-china\", 0.92, \"中国访问链路\")");
|
|
expect(source).toContain(".source-map-overlay .source-map-dialog.el-dialog.is-fullscreen");
|
|
expect(source).toContain("inset: 0 !important");
|
|
expect(source).toContain("flex: 1 1 auto");
|
|
expect(source).toContain("height: 100%;");
|
|
expect(source).toContain("min-height: 48px");
|
|
});
|
|
|
|
it("keeps the all-time label and request semantics consistent", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).toContain('all: "全部"');
|
|
expect(source).toContain("all: undefined");
|
|
expect(source).toContain('all_time: timeRangePreset.value === "all"');
|
|
expect(source).not.toContain('all: "近 90 天"');
|
|
});
|
|
|
|
it("keeps fullscreen animation sharp without multiplying large canvas layers", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).toContain('v-if="!fullscreenVisible"');
|
|
expect(source).toContain("useDirtyRect: true");
|
|
expect(source).toContain("Math.min(getDevicePixelRatio(), 2)");
|
|
expect(source).not.toContain("getDevicePixelRatio() * 1.5");
|
|
expect(source).not.toContain("zlevel:");
|
|
expect(source).toContain("constantSpeed: 72");
|
|
expect(source).toContain("trailLength: 0");
|
|
expect(source).toContain('symbol: "circle"');
|
|
expect(source).toContain('type: "scatter"');
|
|
expect(source).toContain("chartAutoresize = { throttle: 120 }");
|
|
});
|
|
|
|
it("does not classify foreign locations as abnormal by geography alone", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).toContain('mapMetric = ref<"traffic" | "risk">("traffic")');
|
|
expect(source).toContain("riskColor(item.risk_level)");
|
|
expect(source).not.toContain('item.country !== "中国"');
|
|
});
|
|
|
|
it("uses backend coordinates and keeps unmapped locations in the ranking", () => {
|
|
const source = readSource();
|
|
|
|
expect(source).toContain('const mapView = ref<MapView>("flow");');
|
|
expect(source).toContain('load: () => import("../assets/china.json")');
|
|
expect(source).toContain('load: () => import("../assets/world.json")');
|
|
expect(source).toContain("item.longitude");
|
|
expect(source).toContain("item.latitude");
|
|
expect(source).toContain("external_fallback_ip_count");
|
|
expect(source).toContain("外部补全");
|
|
expect(source).toContain("chinaRankRows");
|
|
expect(source).toContain('全部(保留期 ${periodMetadata.value.retention_days} 天)');
|
|
expect(source).not.toContain('from "./worldMapSource"');
|
|
});
|
|
});
|