diff --git a/src/matrix/room/timeline/persistence/GapWriter.js b/src/matrix/room/timeline/persistence/GapWriter.js index 4d8cc78c..c4c2e5bb 100644 --- a/src/matrix/room/timeline/persistence/GapWriter.js +++ b/src/matrix/room/timeline/persistence/GapWriter.js @@ -544,7 +544,7 @@ export function tests() { assert.equal(contextFragment.nextId, null); assert.equal(syncFragment.previousId, null); }, - "Context sync near another fragment appends to that fragment.": async assert => { + "Context sync after another fragment appends to that fragment.": async assert => { const mocks = await setup(); const { timelineMock } = mocks; timelineMock.append(20); @@ -556,6 +556,18 @@ export function tests() { const events = await allFragmentEvents(mocks, firstFragments[0].id); assert.deepEqual(events.map(e => e.event_id), eventIds(0, 16)); }, + "Context sync before another fragment prepends to that fragment.": async assert => { + const mocks = await setup(); + const { timelineMock } = mocks; + timelineMock.append(20); + const {fragments: firstFragments} = await contextAndWrite(mocks, eventId(11)); + const {fragments: secondFragments} = await contextAndWrite(mocks, eventId(5)); + + assert.equal(firstFragments.length, 1); + assert.equal(secondFragments.length, 0); + const events = await allFragmentEvents(mocks, firstFragments[0].id); + assert.deepEqual(events.map(e => e.event_id), eventIds(0, 16)); + }, "Context sync between two fragments links the two fragments, and fills one of them.": async assert => { const mocks = await setup(); const { timelineMock } = mocks;