Skip to content

Commit 0f54caf

Browse files
committed
refactor: Add stepName to snapshot type for easier debugging
1 parent ca0b43e commit 0f54caf

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

packages/test-case-component/src/generateHtml.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ function getDuringSnapshot(data: DataFixture): ExtendedTestCaseSnapshot {
127127
return {
128128
...base,
129129
...data.ide,
130-
finalStateMarkHelpers: {
131-
thatMark: data?.finalState?.thatMark,
132-
sourceMark: data?.finalState?.sourceMark
133-
}
130+
stepName: "during",
134131
};
135132
}

packages/test-case-component/src/helpers/decorations/createDecorations.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { getIdeFlashDecorations } from "./getIdeFlashDecorations";
1212
import { getSelections } from "./getSelections";
1313
import { getSourceMarks } from "./getSourceMarks";
1414
import { getThatMarks } from "./getThatMarks";
15+
import type { StepNameType } from "../../types";
1516

1617
export function createDecorations(
1718
options: {
@@ -22,13 +23,14 @@ export function createDecorations(
2223
selections?: SelectionPlainObject[]
2324
thatMark?: TargetPlainObject[]
2425
sourceMark?: TargetPlainObject[]
26+
stepName?: StepNameType
2527
finalStateMarkHelpers?: {
2628
sourceMark?: TargetPlainObject[]
2729
thatMark?: TargetPlainObject[]
2830
}
2931
} = {}
3032
): DecorationItem[][] {
31-
const { marks, ide, lines, selections, thatMark, sourceMark } = options
33+
const { marks, ide, lines, selections, thatMark, sourceMark, stepName } = options
3234

3335
const decorations: DecorationItem[][] = [];
3436

packages/test-case-component/src/helpers/decorations/getDecorations.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @param {Command} command - The command object for the test case.
66
* @returns {Promise<DecorationItem[][]>} The computed decorations for the state.
77
*/
8-
import type { ExtendedTestCaseSnapshot } from "../../types";
8+
import type { ExtendedTestCaseSnapshot, StepNameType } from "../../types";
99
import type { Command } from "@cursorless/common";
1010
import type { DecorationItem } from "shiki";
1111
import { createDecorations } from "../index";
@@ -20,6 +20,8 @@ export async function getDecorations({
2020
const { messages, flashes, highlights, finalStateMarkHelpers } = snapshot;
2121
const potentialMarks = snapshot.marks || {};
2222
const lines = snapshot.documentContents.split("\n");
23+
// Use StepNameType for stepName, and provide a fallback if undefined
24+
const stepName: StepNameType = snapshot.stepName ?? "error";
2325
const obj = {
2426
marks: potentialMarks,
2527
ide: { messages, flashes, highlights },
@@ -28,7 +30,7 @@ export async function getDecorations({
2830
selections: snapshot.selections,
2931
thatMark: snapshot.thatMark,
3032
sourceMark: snapshot.sourceMark,
31-
finalStateMarkHelpers
33+
stepName,
3234
};
3335
const decorations = createDecorations(obj);
3436
return decorations;

packages/test-case-component/src/types.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ export type StepNameType = "before" | "during" | "after";
1818

1919
export type ExtendedTestCaseSnapshot = TestCaseSnapshot &
2020
Partial<PlainSpyIDERecordedValues> & {
21-
finalStateMarkHelpers?: {
22-
thatMark?: TargetPlainObject[];
23-
sourceMark?: TargetPlainObject[];
24-
};
21+
thatMark?: TargetPlainObject[];
22+
sourceMark?: TargetPlainObject[];
23+
stepName: StepNameType;
2524
};
2625

2726
export type LineRange = { type: string; start: number; end: number };

0 commit comments

Comments
 (0)