mirror of
https://github.com/MeshCore-Beacon/beacon-web.git
synced 2026-10-18 17:39:57 +00:00
Lands the stacked web PRs #75, #79, #80, #81, #83, #85, #87, #89, #92, #95 and #99 in one squash. Server counterparts #166-#176 are merged. Remaining review items follow in a fix PR.
23 lines
1.5 KiB
TypeScript
23 lines
1.5 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { buildPacketPaths, packetPathsToFeatures } from "../../../src/features/map/packet-path";
|
|
import { resolvedPathNodes } from "../../../src/features/map/packet-flow";
|
|
import type { PacketDetail, ResolvedHop } from "../../../src/types/api";
|
|
|
|
const hop = (id: string): ResolvedHop => ({ confidence: "high", nodes: [{ id, publicKey: id, latitude: 45, longitude: -75 + Number(id) }] });
|
|
function detail(hops: ResolvedHop[]): PacketDetail {
|
|
return { header: { payloadType: 2 }, observations: [{ id: 1, observerId: "observer", resolvedPath: hops }] } as unknown as PacketDetail;
|
|
}
|
|
it("does not choose the located candidate in an ambiguous relay", () => {
|
|
const ambiguous: ResolvedHop = { confidence: "ambiguous", nodes: [{ id: "unknown", publicKey: "a" }, ...hop("1").nodes] };
|
|
const paths = buildPacketPaths(detail([hop("0"), ambiguous, hop("2"), hop("3")]));
|
|
expect(paths[0].points.map(p => p.id)).toEqual(["0", "2", "3"]);
|
|
expect(packetPathsToFeatures(paths, null).lines.features.map(f => f.geometry.coordinates)).toEqual([[[-73,45],[-72,45]]]);
|
|
});
|
|
it("keeps isolated known locations without drawing a link over an unknown hop", () => {
|
|
const paths = buildPacketPaths(detail([hop("0"), { confidence: "none", nodes: [] }, hop("2")]));
|
|
const data = packetPathsToFeatures(paths, null);
|
|
expect(data.lines.features).toHaveLength(0);
|
|
expect(data.points.features).toHaveLength(2);
|
|
expect(resolvedPathNodes([hop("0"), { confidence: "none", nodes: [] }, hop("2")])).toEqual([]);
|
|
});
|