-
-
Notifications
You must be signed in to change notification settings - Fork 123
Closed
Description
This only fails for LoroCounter, other containers (such as LoroText) work fine:
const docA = new LoroDoc()
const docB = new LoroDoc()
docA.setPeerId("1")
docB.setPeerId("2")
const undoA = new UndoManager(docA, { mergeInterval: 0 })
const counterA = docA.getCounter("priority")
const counterB = docB.getCounter("priority")
// Step 1: A increments counter (0 → 1)
counterA.increment(1)
docA.commit()
expect(counterA.value).toBe(1)
expect(undoA.canUndo()).toBe(true)
// Step 2: Sync A → B
docB.import(docA.export({ mode: "update" }))
expect(counterB.value).toBe(1)
// Step 3: B increments counter (1 → 2)
counterB.increment(1)
docB.commit()
expect(counterB.value).toBe(2)
// Step 4: Sync B → A (A now has remote changes)
docA.import(docB.export({ mode: "update" }))
expect(counterA.value).toBe(2)
expect(undoA.canUndo()).toBe(true)
// Step 5: A tries to undo their increment
const undoResult = undoA.undo()
docA.commit()
// BUG: undo returns true but value doesn't change
console.log("undo() returned:", undoResult)
console.log("Counter value after undo:", counterA.value)
// Expected: A's increment is undone, leaving B's increment (value = 1)
// Actual: Value stays at 2
expect(counterA.value).toBe(1) // This fails!Metadata
Metadata
Assignees
Labels
No labels