mirror of
https://github.com/Matysh/houseplan-card
synced 2026-10-03 13:18:58 +00:00
test(adoption): revision guard witness for optimistic rollback (#500 AC6)
Issue: #500 User-Visible: no
This commit is contained in:
@@ -380,6 +380,19 @@ test('AC6: a conflict reload or a newer mutation wins over a rejected candidate
|
||||
assert.equal(same.config.spaces[0].title, 'Newer local edit');
|
||||
});
|
||||
|
||||
test('AC6: an attempt from an older revision cannot roll back the same content accepted at a newer one (#442 AC2)', () => {
|
||||
const adoption = adoptedWith(cfg('Server before'), 3);
|
||||
const attempted = cfg('Draft');
|
||||
const attempt = adoption.beginOptimistic(adoption.config, attempted);
|
||||
adoption.stageLocalConfig(attempted);
|
||||
// the queued write for the very same body was accepted meanwhile
|
||||
adoption.acceptConfigWrite(attempted, { rev: 4 });
|
||||
assert.equal(contentFingerprint(adoption.config), attempt.attemptedFingerprint, 'content is identical — only the revision differs');
|
||||
assert.equal(adoption.rollbackOptimistic(attempt), false, 'the revision guard alone must refuse');
|
||||
assert.equal(adoption.config, attempted);
|
||||
assert.equal(adoption.configRev, 4);
|
||||
});
|
||||
|
||||
test('AC6: newer in-place content on the attempted root also wins (#442)', () => {
|
||||
const adoption = adoptedWith(cfg('Server before'), 3);
|
||||
const attempted = cfg('Draft');
|
||||
|
||||
Reference in New Issue
Block a user