Skip to content

Commit dc8c102

Browse files
committed
test(mothership): cover migrate keeping its first record
1 parent f68a2aa commit dc8c102

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎apps/sim/stores/mothership-queue/store.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,24 @@ describe('useMothershipQueueStore', () => {
212212
])
213213
})
214214

215+
it('keeps the first move when the same new-chat queue is migrated again', () => {
216+
useMothershipQueueStore.getState().enqueue('chat-W', message('older'))
217+
useMothershipQueueStore.getState().enqueue('pending::twice', message('moved'))
218+
useMothershipQueueStore.getState().migrate('pending::twice', 'chat-W')
219+
useMothershipQueueStore.getState().enqueue('chat-W', message('written-later'))
220+
useMothershipQueueStore.getState().migrate('pending::twice', 'chat-W')
221+
222+
const position = liveQueuePosition('pending::twice', [])
223+
useMothershipQueueStore.getState().insertAt(position.chatKey, position.index, message('late'))
224+
225+
expect(useMothershipQueueStore.getState().queues['chat-W']?.map((m) => m.id)).toEqual([
226+
'older',
227+
'late',
228+
'moved',
229+
'written-later',
230+
])
231+
})
232+
215233
it('keeps a late write in order when messages ahead of it were removed meanwhile', () => {
216234
useMothershipQueueStore.getState().enqueue('chat-Z', message('older'))
217235
useMothershipQueueStore.getState().enqueue('pending::sent', message('later'))

0 commit comments

Comments
 (0)