Skip to content

Commit 5134347

Browse files
paddymulclaude
andcommitted
test(#89): failing tests for review-found follow-up bugs
Adversarial review of the deferred follow-ups confirmed two defects: - promote_diff reports the wrong checkpoint_step: it self-checkpoints AND is non-exempt, so the decorator appends a trailing empty commit and the backfill names THAT step (observed step_before+2, not the cascade's +1). - Stage C navigation yanks a focused/mid-edit user, discarding unsaved code — recalcTarget ignores focus, unlike the #27 NewEntryPill policy. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0ee095c commit 5134347

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

packages/app/src/recalcRefresh.test.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,26 @@ import { recalcTarget } from "./recalcRefresh";
88
// hash to refresh — but only that view; an unrelated or older hash stays put.
99
describe("recalcTarget", () => {
1010
it("returns null when no hash is being viewed (catalog index)", () => {
11-
expect(recalcTarget(undefined, { old: "new" })).toBeNull();
11+
expect(recalcTarget(undefined, { old: "new" }, false)).toBeNull();
1212
});
1313

1414
it("returns null when there is no remap", () => {
15-
expect(recalcTarget("abc", undefined)).toBeNull();
16-
expect(recalcTarget("abc", {})).toBeNull();
15+
expect(recalcTarget("abc", undefined, false)).toBeNull();
16+
expect(recalcTarget("abc", {}, false)).toBeNull();
1717
});
1818

1919
it("returns null when the viewed hash was not remapped", () => {
20-
expect(recalcTarget("abc", { other: "new" })).toBeNull();
20+
expect(recalcTarget("abc", { other: "new" }, false)).toBeNull();
2121
});
2222

23-
it("returns the recomputed hash when the viewed entry was remapped", () => {
24-
expect(recalcTarget("old", { old: "new", x: "y" })).toBe("new");
23+
it("returns the recomputed hash for a backgrounded view that was remapped", () => {
24+
expect(recalcTarget("old", { old: "new", x: "y" }, false)).toBe("new");
25+
});
26+
27+
// Don't yank a user actively looking at the page (mirrors NewEntryPill / #27):
28+
// a focused view — which includes a mid-edit code editor whose unsaved text the
29+
// hash-keyed remount would discard — stays put even when its head was remapped.
30+
it("returns null when the page is focused, even if the viewed entry was remapped", () => {
31+
expect(recalcTarget("old", { old: "new" }, true)).toBeNull();
2532
});
2633
});

tests/test_promote_diff.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,13 @@ def test_catalog_promote_diff_repoint_cascades_to_follower_atomically(project: s
271271
assert foll2 != foll # the follower was recomputed
272272
assert out["recalc"]["remap"].get(foll) == foll2
273273

274+
# The reported checkpoint_step names the revision the promote + cascade landed
275+
# in, AND it is exactly one revision — promote_diff self-checkpoints, so it
276+
# must be checkpoint-exempt; a redundant dispatch-decorator checkpoint would
277+
# both append a trailing empty commit and make the report name THAT step.
278+
assert out["recalc"]["checkpoint_step"] == step_before + 1
279+
assert current_step(project) == step_before + 1
280+
274281
# Atomic: reset_to before the re-promote restores BOTH the diff alias and the follower.
275282
reset_to(project, step_before)
276283
assert get_alias(project, "mydiff") == d1

0 commit comments

Comments
 (0)