fix(record): keep committed empty fill steps in exported traces

This commit is contained in:
“haonan”
2026-08-17 11:02:10 +08:00
parent 67b7227abf
commit 61a0e0d218
2 changed files with 19 additions and 3 deletions
@@ -166,8 +166,8 @@ describe("reduceTraceSteps v3", () => {
const { steps, stepIdByDraftId } = reduceTraceSteps(
[
// Dropped: blank fill.
{ op: "fill", target: { ref: "e1" }, value: " ", preStateId: s1, postStateId: s1 },
// Dropped: bare typing press.
{ op: "press", key: "a", preStateId: s1, postStateId: s1 },
{ op: "click", target: { ref: "e2" }, preStateId: s1, postStateId: s1 },
],
registry,
@@ -178,6 +178,23 @@ describe("reduceTraceSteps v3", () => {
expect(stepIdByDraftId.get(2)).toBe(1);
});
it("keeps committed empty fills", () => {
resetStateIdCounterForTests();
const registry = new Map();
const s1 = registerObservation(registry, { url: "https://a.example/", rawVomText: "a" });
const { steps } = reduceTraceSteps(
[
{ op: "fill", target: { ref: "e1", role: "textbox", name: "Search" }, value: "", preStateId: s1, postStateId: s1 },
{ op: "click", target: { ref: "e2", role: "button", name: "Apply" }, preStateId: s1, postStateId: s1 },
],
registry,
);
expect(steps.map((step) => step.op)).toEqual(["fill", "click"]);
expect(steps[0]).toMatchObject({ op: "fill", value: "" });
});
it("keeps hover steps before menu clicks", () => {
resetStateIdCounterForTests();
const registry = new Map();
-1
View File
@@ -30,7 +30,6 @@ export function shouldRecordPress(
}
function shouldIncludeDraft(step: DraftTraceStep): boolean {
if (step.op === "fill" && !(step.value ?? "").trim() && !step.redacted) return false;
if (step.op === "press" && !shouldRecordPress(step.key, step.modifiers)) return false;
return true;
}