mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
fix(record): keep committed empty fill steps in exported traces
This commit is contained in:
1 parent
67b7227abf
commit
61a0e0d218
2 files changed
+19
-3
No files matched your search
@@ -166,8 +166,8 @@ describe("reduceTraceSteps v3", () => {
|
|||||||
|
|
||||||
const { steps, stepIdByDraftId } = reduceTraceSteps(
|
const { steps, stepIdByDraftId } = reduceTraceSteps(
|
||||||
[
|
[
|
||||||
// Dropped: blank fill.
|
// Dropped: bare typing press.
|
||||||
{ op: "fill", target: { ref: "e1" }, value: " ", preStateId: s1, postStateId: s1 },
|
{ op: "press", key: "a", preStateId: s1, postStateId: s1 },
|
||||||
{ op: "click", target: { ref: "e2" }, preStateId: s1, postStateId: s1 },
|
{ op: "click", target: { ref: "e2" }, preStateId: s1, postStateId: s1 },
|
||||||
],
|
],
|
||||||
registry,
|
registry,
|
||||||
@@ -178,6 +178,23 @@ describe("reduceTraceSteps v3", () => {
|
|||||||
expect(stepIdByDraftId.get(2)).toBe(1);
|
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", () => {
|
it("keeps hover steps before menu clicks", () => {
|
||||||
resetStateIdCounterForTests();
|
resetStateIdCounterForTests();
|
||||||
const registry = new Map();
|
const registry = new Map();
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export function shouldRecordPress(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function shouldIncludeDraft(step: DraftTraceStep): boolean {
|
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;
|
if (step.op === "press" && !shouldRecordPress(step.key, step.modifiers)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user