Skip to content

Commit 5ead5b5

Browse files
committed
Refactor journey model tests to remove legacy handling of stopIds and waypoints. Update type definitions and normalize test cases to focus on stops[]. Clean up unused assertions and improve clarity in test descriptions.
1 parent f2dcf5a commit 5ead5b5

3 files changed

Lines changed: 6 additions & 49 deletions

File tree

src/modules/journey-model.test.ts

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,55 +13,35 @@ import {
1313
type JourneyResolutionContext,
1414
type JourneyStopLeg,
1515
type PackJourney,
16-
type PackWithOptionalJourney,
1716
} from "./journey-model";
1817

1918
describe("ensurePackJourneyNormalized", () => {
2019
it("creates pack.journey when absent and normalizes", () => {
21-
const pack: PackWithOptionalJourney = {};
20+
const pack: { journey?: unknown } = {};
2221
ensurePackJourneyNormalized(pack);
2322
expect(pack.journey).toEqual({ stops: [] });
2423
});
2524
});
2625

2726
describe("normalizePackJourney", () => {
28-
it("keeps unknown keys and yields empty stops when stops[] is absent", () => {
27+
it("yields empty stops when stops[] is absent", () => {
2928
const j: Record<string, unknown> = {
30-
points: [[10, 20], [30, 40]],
31-
stopIds: [],
32-
waypoints: [],
29+
foo: "bar",
3330
};
3431
normalizePackJourney(j);
35-
expect(j.points).toEqual([[10, 20], [30, 40]]);
36-
expect(j.stopIds).toEqual([]);
37-
expect(j.waypoints).toEqual([]);
3832
const normalized = j as unknown as PackJourney;
3933
expect(normalized.stops).toEqual([]);
4034
expect(journeyResolvedCoordinates(normalized)).toEqual([]);
4135
});
4236

43-
it("uses only stops[] as source of truth", () => {
37+
it("uses stops[] as source of truth", () => {
4438
const j = {
4539
stops: [{ kind: "burg" as const, id: 1 }],
46-
stopIds: ["burg:99"],
47-
waypoints: [{ id: "x" }],
40+
foo: "bar",
4841
};
4942
normalizePackJourney(j);
5043
expect(j.stops.length).toBe(1);
5144
expect(j.stops[0]).toEqual({ kind: "burg", id: 1 });
52-
expect(j.stopIds).toEqual(["burg:99"]);
53-
expect(j.waypoints).toEqual([{ id: "x" }]);
54-
});
55-
56-
it("does not infer stops from stopIds / waypoints", () => {
57-
const j: Record<string, unknown> = {
58-
stopIds: ["wp_skip", "burg:3", "marker:7"],
59-
waypoints: [{ id: "wp_skip", name: "A", x: 1, y: 2 }],
60-
};
61-
normalizePackJourney(j);
62-
expect((j as unknown as PackJourney).stops).toEqual([]);
63-
expect(j.stopIds).toEqual(["wp_skip", "burg:3", "marker:7"]);
64-
expect(j.waypoints).toEqual([{ id: "wp_skip", name: "A", x: 1, y: 2 }]);
6545
});
6646

6747
it("filters malformed stops entries only", () => {

src/modules/journey-model.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ function sanitizeStopsArray(raw: unknown[]): JourneyStopLeg[] {
119119
return out;
120120
}
121121

122-
/** Pack slice used when ensuring `pack.journey` exists and is sanitized. */
123-
export type PackWithOptionalJourney = {
122+
type PackWithOptionalJourney = {
124123
journey?: unknown;
125124
};
126125

tests/e2e/journey-layer.spec.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,6 @@ test.describe("Journey layer", () => {
6868
expect(disp).toBe("none");
6969
});
7070

71-
test("drawJourney ignores stray points key and leaves empty stops", async ({ page }) => {
72-
const snap = await page.evaluate((pts) => {
73-
const w = window as unknown as {
74-
layerIsOn: (id: string) => boolean;
75-
toggleJourney: () => void;
76-
pack: { journey: Record<string, unknown> };
77-
drawJourney: () => void;
78-
};
79-
if (!w.layerIsOn("toggleJourney")) w.toggleJourney();
80-
w.pack.journey = { points: pts };
81-
w.drawJourney();
82-
const j = w.pack.journey;
83-
return {
84-
pointsPresent: Object.prototype.hasOwnProperty.call(j, "points"),
85-
stopsLen: Array.isArray(j.stops) ? j.stops.length : -1,
86-
};
87-
}, BACKTRACK_JOURNEY_POINTS);
88-
89-
expect(snap.pointsPresent).toBe(true);
90-
expect(snap.stopsLen).toBe(0);
91-
});
92-
9371
test("drawJourney resolves a burg stop ref using pack.burgs positions", async ({ page }) => {
9472
await page.evaluate(() => {
9573
const w = window as unknown as {

0 commit comments

Comments
 (0)