Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

offline-e2e.test.ts

758 lines22.8 KB

1import { describe, expect, it } from 'vitest'
2import { NonRetriableError } from '../src/types'
3import { DefaultRetryPolicy } from '../src/retry/RetryPolicy'
4import { FakeStorageAdapter, createTestOfflineEnvironment } from './harness'
5import type { TestItem } from './harness'
6import type { OfflineMutationFnParams, OnlineDetector } from '../src/types'
7import type { PendingMutation } from '@tanstack/db'
8​
9const flushMicrotasks = () => new Promise((resolve) => setTimeout(resolve, 0))
10​
11const waitUntil = async (
12 predicate: () => boolean | Promise<boolean>,
13 timeoutMs = 5000,
14 intervalMs = 20,
15) => {
16 const deadline = Date.now() + timeoutMs
17 while (Date.now() < deadline) {
18 if (await predicate()) {
19 return
20 }
21 await new Promise((resolve) => setTimeout(resolve, intervalMs))
22 }
23 throw new Error(`Timed out waiting for condition`)
25​
26class ManualOnlineDetector implements OnlineDetector {
27 private listeners = new Set<() => void>()
28 private online: boolean
29​
30 constructor(initialOnline: boolean) {
31 this.online = initialOnline
32 }
33​
34 subscribe(callback: () => void): () => void {
35 this.listeners.add(callback)
36​
37 return () => {
38 this.listeners.delete(callback)
39 }
40 }
41​
42 notifyOnline(): void {
43 for (const listener of this.listeners) {
44 listener()
45 }
46 }
47​
48 isOnline(): boolean {
49 return this.online
50 }
51​
52 setOnline(isOnline: boolean): void {
53 this.online = isOnline
54​
55 if (isOnline) {
56 this.notifyOnline()
57 }
58 }
59​
60 dispose(): void {
61 this.listeners.clear()
62 }
64​
65describe(`offline executor end-to-end`, () => {
66 it(`resolves waiting promises for successful transactions`, async () => {
67 const env = createTestOfflineEnvironment()
68​
69 await env.waitForLeader()
70​
71 const offlineTx = env.executor.createOfflineTransaction({
72 mutationFnName: env.mutationFnName,
73 autoCommit: false,
74 })
75​
76 const waitPromise = env.executor.waitForTransactionCompletion(offlineTx.id)
77​
78 const now = new Date()
79 offlineTx.mutate(() => {
80 env.collection.insert({
81 id: `item-1`,
82 value: `hello`,
83 completed: false,
84 updatedAt: now,
85 })
86 })
87​
88 await offlineTx.commit()
89​
90 await expect(waitPromise).resolves.toBeUndefined()
91​
92 const outboxEntries = await env.executor.peekOutbox()
93 expect(outboxEntries).toEqual([])
94​
95 expect(env.mutationCalls.length).toBeGreaterThanOrEqual(1)
96 const call = env.mutationCalls[env.mutationCalls.length - 1]!
97 expect(call.transaction.mutations).toHaveLength(1)
98 expect(call.transaction.mutations[0].key).toBe(`item-1`)
99 const stored = env.collection.get(`item-1`)
100 expect(stored?.value).toBe(`hello`)
101 expect(env.serverState.get(`item-1`)?.value).toBe(`hello`)
102​
103 env.executor.dispose()
104 })
105​
106 it(`retries queued transactions when backend resumes`, async () => {
107 let online = false
108 const env = createTestOfflineEnvironment({
109 mutationFn: (params) => {
110 const runtimeOnline = online
111 const mutations = params.transaction.mutations as Array<
112 PendingMutation<TestItem>
113 >
114 if (!runtimeOnline) {
115 throw new Error(`offline`)
116 }
117 env.applyMutations(mutations)
118 return { ok: true, mutations }
119 },
120 })
121​
122 await env.waitForLeader()
123​
124 const offlineTx = env.executor.createOfflineTransaction({
125 mutationFnName: env.mutationFnName,
126 autoCommit: false,
127 })
128​
129 const now = new Date()
130 offlineTx.mutate(() => {
131 env.collection.insert({
132 id: `queued-item`,
133 value: `queued`,
134 completed: false,
135 updatedAt: now,
136 })
137 })
138​
139 // Commit should not throw for retriable errors - it persists to outbox
140 const commitPromise = offlineTx.commit()
141​
142 // Wait a bit for the transaction to be processed
143 await flushMicrotasks()
144​
145 // Check that the transaction was attempted once
146 expect(env.mutationCalls.length).toBe(1)
147​
148 // Check that the transaction is in the outbox (persisted for retry)
149 let outboxEntries = await env.executor.peekOutbox()
150 expect(outboxEntries.length).toBe(1)
151 expect(outboxEntries[0].id).toBe(offlineTx.id)
152​
153 // Now bring the system back online
154 online = true
155 env.executor.getOnlineDetector().notifyOnline()
156​
157 // Wait for the retry to succeed
158 await waitUntil(() => env.mutationCalls.length >= 2)
159​
160 // The original commit promise should now resolve
161 await expect(commitPromise).resolves.toBeDefined()
162​
163 // Check that the transaction completed successfully
164 outboxEntries = await env.executor.peekOutbox()
165 expect(outboxEntries).toEqual([])
166​
167 outboxEntries = await env.executor.peekOutbox()
168 expect(outboxEntries).toEqual([])
169 expect(env.mutationCalls.length).toBeGreaterThanOrEqual(2)
170 expect(env.serverState.get(`queued-item`)?.value).toBe(`queued`)
171​
172 env.executor.dispose()
173 })
174​
175 it(`retries beyond 10 attempts by default`, () => {
176 const policy = new DefaultRetryPolicy()
177 const error = new Error(`transient`)
178​
179 for (let i = 0; i < 50; i++) {
180 expect(policy.shouldRetry(error, i)).toBe(true)
181 }
182​
183 expect(policy.shouldRetry(new NonRetriableError(`permanent`), 0)).toBe(
184 false,
185 )
186 })
187​
188 it(`does not execute mutations while offline`, async () => {
189 const onlineDetector = new ManualOnlineDetector(false)
190 const env = createTestOfflineEnvironment({
191 config: {
192 onlineDetector,
193 },
194 })
195​
196 await env.waitForLeader()
197​
198 const offlineTx = env.executor.createOfflineTransaction({
199 mutationFnName: env.mutationFnName,
200 autoCommit: false,
201 })
202​
203 offlineTx.mutate(() => {
204 env.collection.insert({
205 id: `queued-while-offline`,
206 value: `queued`,
207 completed: false,
208 updatedAt: new Date(),
209 })
210 })
211​
212 const commitPromise = offlineTx.commit()
213​
214 await flushMicrotasks()
215 expect(env.mutationCalls).toHaveLength(0)
216 expect(await env.executor.peekOutbox()).toHaveLength(1)
217​
218 onlineDetector.setOnline(true)
219​
220 await expect(commitPromise).resolves.toBeDefined()
221 expect(env.mutationCalls).toHaveLength(1)
222 expect(await env.executor.peekOutbox()).toEqual([])
223​
224 env.executor.dispose()
225 })
226​
227 it(`rejects waiting promises for permanent failures and rolls back optimistic state`, async () => {
228 const error = new NonRetriableError(`permanent`)
229 const env = createTestOfflineEnvironment({
230 mutationFn: () => {
231 throw error
232 },
233 })
234​
235 await env.waitForLeader()
236​
237 const offlineTx = env.executor.createOfflineTransaction({
238 mutationFnName: env.mutationFnName,
239 autoCommit: false,
240 })
241​
242 const waitPromise = env.executor.waitForTransactionCompletion(offlineTx.id)
243​
244 offlineTx.mutate(() => {
245 env.collection.insert({
246 id: `perm-item`,
247 value: `nope`,
248 completed: false,
249 updatedAt: new Date(),
250 })
251 })
252​
253 await expect(offlineTx.commit()).rejects.toThrow(`permanent`)
254 await expect(waitPromise).rejects.toThrow(`permanent`)
255​
256 const outboxEntries = await env.executor.peekOutbox()
257 expect(outboxEntries).toEqual([])
258 expect(env.collection.get(`perm-item`)).toBeUndefined()
259 expect(env.serverState.get(`perm-item`)).toBeUndefined()
260​
261 env.executor.dispose()
262 })
263​
264 it(`replays persisted transactions on startup`, async () => {
265 const storage = new FakeStorageAdapter()
266​
267 const offlineErrorEnv = createTestOfflineEnvironment({
268 storage,
269 mutationFn: () => {
270 throw new Error(`offline`)
271 },
272 })
273​
274 await offlineErrorEnv.waitForLeader()
275​
276 const offlineTx = offlineErrorEnv.executor.createOfflineTransaction({
277 mutationFnName: offlineErrorEnv.mutationFnName,
278 autoCommit: false,
279 })
280​
281 offlineTx.mutate(() => {
282 offlineErrorEnv.collection.insert({
283 id: `persisted`,
284 value: `from-outbox`,
285 completed: false,
286 updatedAt: new Date(),
287 })
288 })
289​
290 // Start the commit - it will persist to outbox and keep retrying
291 // We don't await it because it will never complete (mutation always fails)
292 offlineTx.commit()
293​
294 // Wait for the transaction to be persisted to outbox
295 await waitUntil(async () => {
296 const pendingEntries = await offlineErrorEnv.executor.peekOutbox()
297 return pendingEntries.length === 1
298 }, 5000)
299​
300 // Verify it's in the outbox
301 const outboxEntries = await offlineErrorEnv.executor.peekOutbox()
302 expect(outboxEntries.length).toBe(1)
303 expect(outboxEntries[0].id).toBe(offlineTx.id)
304​
305 offlineErrorEnv.executor.dispose()
306​
307 const replayEnv = createTestOfflineEnvironment({
308 storage,
309 mutationFn: (params: OfflineMutationFnParams & { attempt: number }) => {
310 const mutations = params.transaction.mutations as Array<
311 PendingMutation<TestItem>
312 >
313 replayEnv.applyMutations(mutations)
314 return { ok: true, mutations }
315 },
316 })
317​
318 await replayEnv.waitForLeader()
319 await waitUntil(async () => {
320 const entries = await replayEnv.executor.peekOutbox()
321 return entries.length === 0
322 })
323 expect(replayEnv.serverState.get(`persisted`)?.value).toBe(`from-outbox`)
324​
325 replayEnv.executor.dispose()
326 })
327​
328 // TODO: Fix this test - hanging at await commitFirst after resolving mutation
329 it.skip(`serializes transactions targeting the same key`, async () => {
330 console.log(`[TEST] Starting serializes transactions test`)
331 const pendingResolvers: Array<() => void> = []
332 const env = createTestOfflineEnvironment({
333 mutationFn: async (params) => {
334 const mutations = params.transaction.mutations as Array<
335 PendingMutation<TestItem>
336 >
337​
338 await new Promise<void>((resolve) => {
339 pendingResolvers.push(() => {
340 env.applyMutations(mutations)
341 resolve()
342 })
343 })
344​
345 return { ok: true, mutations }
346 },
347 })
348​
349 console.log(`[TEST] Waiting for leader...`)
350 await env.waitForLeader()
351 console.log(`[TEST] Leader ready`)
352​
353 const firstTx = env.executor.createOfflineTransaction({
354 mutationFnName: env.mutationFnName,
355 autoCommit: false,
356 })
357 console.log(`[TEST] Created first transaction:`, firstTx.id)
358 const waitFirst = env.executor.waitForTransactionCompletion(firstTx.id)
359 firstTx.mutate(() => {
360 env.collection.insert({
361 id: `shared`,
362 value: `v1`,
363 completed: false,
364 updatedAt: new Date(),
365 })
366 })
367 console.log(`[TEST] Committing first transaction`)
368 const commitFirst = firstTx.commit()
369​
370 await flushMicrotasks()
371 console.log(
372 `[TEST] After flush, mutationCalls:`,
373 env.mutationCalls.length,
374 `resolvers:`,
375 pendingResolvers.length,
376 )
377 expect(env.mutationCalls.length).toBe(1)
378 expect(pendingResolvers.length).toBe(1)
379​
380 console.log(`[TEST] Creating second transaction`)
381 const secondTx = env.executor.createOfflineTransaction({
382 mutationFnName: env.mutationFnName,
383 autoCommit: false,
384 })
385 console.log(`[TEST] Created second transaction:`, secondTx.id)
386 const waitSecond = env.executor.waitForTransactionCompletion(secondTx.id)
387 secondTx.mutate(() => {
388 env.collection.update(`shared`, (draft) => {
389 draft.value = `v2`
390 draft.updatedAt = new Date()
391 })
392 })
393 console.log(`[TEST] Committing second transaction`)
394 const commitSecond = secondTx.commit()
395​
396 await flushMicrotasks()
397 console.log(
398 `[TEST] After second flush, mutationCalls:`,
399 env.mutationCalls.length,
400 `resolvers:`,
401 pendingResolvers.length,
402 )
403 expect(env.mutationCalls.length).toBe(1)
404 expect(pendingResolvers.length).toBe(1)
405​
406 console.log(`[TEST] Resolving first transaction`)
407 pendingResolvers.shift()?.()
408 console.log(`[TEST] Awaiting commitFirst`)
409 await commitFirst
410 console.log(`[TEST] Awaiting waitFirst`)
411 await waitFirst
412 console.log(`[TEST] Waiting for second mutation call...`)
413 await waitUntil(() => env.mutationCalls.length >= 2)
414 console.log(`[TEST] Second mutation called!`)
415 expect(pendingResolvers.length).toBe(1)
416​
417 pendingResolvers.shift()?.()
418 await commitSecond
419 await waitSecond
420 await waitUntil(() => env.serverState.get(`shared`)?.value === `v2`)
421​
422 env.executor.dispose()
423 })
424​
425 it(`processes mutations sequentially regardless of keys`, async () => {
426 const pendingResolvers: Array<() => void> = []
427 // eslint-disable-next-line prefer-const
428 let env: ReturnType<typeof createTestOfflineEnvironment> | undefined
429​
430 const deferredMutation = async (
431 params: OfflineMutationFnParams & { attempt: number },
432 ) => {
433 const runtimeEnv = env
434 if (!runtimeEnv) {
435 throw new Error(`env not initialized`)
436 }
437​
438 const mutations = params.transaction.mutations as Array<
439 PendingMutation<TestItem>
440 >
441​
442 await new Promise<void>((resolve) => {
443 pendingResolvers.push(() => {
444 runtimeEnv.applyMutations(mutations)
445 resolve()
446 })
447 })
448​
449 return { ok: true, mutations }
450 }
451​
452 env = createTestOfflineEnvironment({
453 mutationFn: deferredMutation,
454 })
455​
456 const runtimeEnv = env
457​
458 await runtimeEnv.waitForLeader()
459​
460 const firstTx = runtimeEnv.executor.createOfflineTransaction({
461 mutationFnName: runtimeEnv.mutationFnName,
462 autoCommit: false,
463 })
464 const waitFirst = runtimeEnv.executor.waitForTransactionCompletion(
465 firstTx.id,
466 )
467 firstTx.mutate(() => {
468 runtimeEnv.collection.insert({
469 id: `first`,
470 value: `1`,
471 completed: false,
472 updatedAt: new Date(),
473 })
474 })
475 const commitFirst = firstTx.commit()
476​
477 const secondTx = runtimeEnv.executor.createOfflineTransaction({
478 mutationFnName: runtimeEnv.mutationFnName,
479 autoCommit: false,
480 })
481 const waitSecond = runtimeEnv.executor.waitForTransactionCompletion(
482 secondTx.id,
483 )
484 secondTx.mutate(() => {
485 runtimeEnv.collection.insert({
486 id: `second`,
487 value: `2`,
488 completed: false,
489 updatedAt: new Date(),
490 })
491 })
492 const commitSecond = secondTx.commit()
493​
494 await flushMicrotasks()
495 // With sequential processing, only one transaction executes at a time
496 expect(runtimeEnv.mutationCalls.length).toBe(1)
497 expect(pendingResolvers.length).toBe(1)
498​
499 // Resolve the first transaction
500 pendingResolvers.shift()?.()
501 // Wait for the second transaction to start
502 await waitUntil(() => runtimeEnv.mutationCalls.length >= 2)
503 expect(pendingResolvers.length).toBe(1)
504​
505 // Resolve the second transaction
506 pendingResolvers.shift()?.()
507 await Promise.all([commitFirst, commitSecond, waitFirst, waitSecond])
508​
509 expect(runtimeEnv.serverState.get(`first`)?.value).toBe(`1`)
510 expect(runtimeEnv.serverState.get(`second`)?.value).toBe(`2`)
511​
512 runtimeEnv.executor.dispose()
513 })
514​
515 it(`executes transactions online-only when not leader`, async () => {
516 const env = createTestOfflineEnvironment()
517​
518 // Set this tab to not be leader
519 env.leader.setLeader(false)
520​
521 // Give the executor a moment to react to leadership change
522 await flushMicrotasks()
523​
524 // Should not be offline enabled when not leader
525 expect(env.executor.isOfflineEnabled).toBe(false)
526​
527 const offlineTx = env.executor.createOfflineTransaction({
528 mutationFnName: env.mutationFnName,
529 autoCommit: false,
530 })
531​
532 const now = new Date()
533 offlineTx.mutate(() => {
534 env.collection.insert({
535 id: `non-leader-item`,
536 value: `online-only`,
537 completed: false,
538 updatedAt: now,
539 })
540 })
541​
542 // Should execute immediately online without persisting to outbox
543 await offlineTx.commit()
544​
545 // Should have called the mutation function
546 expect(env.mutationCalls.length).toBe(1)
547 const call = env.mutationCalls[0]!
548 expect(call.transaction.mutations).toHaveLength(1)
549 expect(call.transaction.mutations[0].key).toBe(`non-leader-item`)
550​
551 // Should have applied to both local and server state
552 expect(env.collection.get(`non-leader-item`)?.value).toBe(`online-only`)
553 expect(env.serverState.get(`non-leader-item`)?.value).toBe(`online-only`)
554​
555 // Should NOT have persisted to outbox
556 const outboxEntries = await env.executor.peekOutbox()
557 expect(outboxEntries).toEqual([])
558​
559 env.executor.dispose()
560 })
561​
562 it(`should restore optimistic state to collection on startup`, async () => {
563 // This test verifies that optimistic state IS restored to the collection
564 // when the page is refreshed while offline (e.g., with pending transactions).
565 //
566 // After page refresh, the collection should still show the optimistic data
567 // from pending transactions, providing a seamless offline UX.
568​
569 const storage = new FakeStorageAdapter()
570​
571 // Create a promise that never resolves - simulates offline/stuck mutation
572 const mutationPromise = () => new Promise<void>(() => {})
573​
574 // First environment: Create a transaction that gets stuck (simulating offline)
575 const firstEnv = createTestOfflineEnvironment({
576 storage,
577 mutationFn: async () => {
578 // This mutation will hang forever, simulating offline state
579 await mutationPromise()
580 throw new Error(`Should not reach here in first env`)
581 },
582 })
583​
584 await firstEnv.waitForLeader()
585​
586 const offlineTx = firstEnv.executor.createOfflineTransaction({
587 mutationFnName: firstEnv.mutationFnName,
588 autoCommit: false,
589 })
590​
591 // Apply optimistic update
592 offlineTx.mutate(() => {
593 firstEnv.collection.insert({
594 id: `optimistic-item`,
595 value: `should-persist`,
596 completed: false,
597 updatedAt: new Date(),
598 })
599 })
600​
601 // Verify the optimistic update is visible in the collection
602 expect(firstEnv.collection.get(`optimistic-item`)?.value).toBe(
603 `should-persist`,
604 )
605​
606 // Start commit - it will persist to outbox and start (but not complete) execution
607 offlineTx.commit()
608​
609 // Wait for the transaction to be persisted to outbox
610 await waitUntil(async () => {
611 const pendingEntries = await firstEnv.executor.peekOutbox()
612 return pendingEntries.length === 1
613 }, 5000)
614​
615 // Verify it's in the outbox
616 const outboxEntries = await firstEnv.executor.peekOutbox()
617 expect(outboxEntries.length).toBe(1)
618 expect(outboxEntries[0].id).toBe(offlineTx.id)
619​
620 // Verify the mutation data is properly serialized
621 expect(outboxEntries[0].mutations.length).toBe(1)
622 expect(outboxEntries[0].mutations[0].type).toBe(`insert`)
623​
624 // Dispose first environment (simulating page refresh)
625 firstEnv.executor.dispose()
626​
627 // Create a new environment with a deferred mutation to control timing
628 let secondEnvResolveMutation: (() => void) | null = null
629 const secondEnvMutationPromise = () =>
630 new Promise<void>((resolve) => {
631 secondEnvResolveMutation = resolve
632 })
633​
634 const secondEnv = createTestOfflineEnvironment({
635 storage,
636 mutationFn: async (params) => {
637 // Wait for explicit resolution
638 await secondEnvMutationPromise()
639 const mutations = params.transaction.mutations as Array<
640 PendingMutation<TestItem>
641 >
642 secondEnv.applyMutations(mutations)
643 return { ok: true, mutations }
644 },
645 })
646​
647 await secondEnv.waitForLeader()
648​
649 // At this point, the optimistic state should be restored to the collection
650 // The transaction is loaded from storage, and the optimistic mutations
651 // are applied to the collection immediately
652 const restoredItem = secondEnv.collection.get(`optimistic-item`)
653​
654 // The optimistic state should be restored from persisted transactions
655 expect(restoredItem?.value).toBe(`should-persist`)
656​
657 // Verify the transaction IS still in the outbox (data was persisted correctly)
658 const secondEnvOutbox = await secondEnv.executor.peekOutbox()
659 expect(secondEnvOutbox.length).toBe(1)
660 expect(secondEnvOutbox[0].mutations[0].type).toBe(`insert`)
661​
662 // Now complete the mutation to verify the data eventually syncs
663 secondEnvResolveMutation!()
664​
665 await waitUntil(async () => {
666 const entries = await secondEnv.executor.peekOutbox()
667 return entries.length === 0
668 })
669​
670 // After sync completes, the item appears (but this is too late for offline UX)
671 expect(secondEnv.serverState.get(`optimistic-item`)?.value).toBe(
672 `should-persist`,
673 )
674​
675 secondEnv.executor.dispose()
676 })
677​
678 it(`should rollback restored optimistic state on permanent failure after page refresh`, async () => {
679 // This test verifies that optimistic state restored from persisted transactions
680 // is properly rolled back when the transaction fails permanently (NonRetriableError).
681 //
682 // Scenario: User creates transaction offline, refreshes page, transaction fails permanently
683 // Expected: Optimistic state should be visible initially, then removed after failure
684​
685 const storage = new FakeStorageAdapter()
686​
687 // First environment: Create a transaction that gets stuck (simulating offline)
688 const mutationPromise = () => new Promise<void>(() => {})
689​
690 const firstEnv = createTestOfflineEnvironment({
691 storage,
692 mutationFn: async () => {
693 await mutationPromise()
694 throw new Error(`Should not reach here in first env`)
695 },
696 })
697​
698 await firstEnv.waitForLeader()
699​
700 const offlineTx = firstEnv.executor.createOfflineTransaction({
701 mutationFnName: firstEnv.mutationFnName,
702 autoCommit: false,
703 })
704​
705 // Apply optimistic update
706 offlineTx.mutate(() => {
707 firstEnv.collection.insert({
708 id: `ghost-item`,
709 value: `will-fail`,
710 completed: false,
711 updatedAt: new Date(),
712 })
713 })
714​
715 // Verify the optimistic update is visible
716 expect(firstEnv.collection.get(`ghost-item`)?.value).toBe(`will-fail`)
717​
718 // Start commit - it will persist to outbox
719 offlineTx.commit()
720​
721 // Wait for the transaction to be persisted
722 await waitUntil(async () => {
723 const pendingEntries = await firstEnv.executor.peekOutbox()
724 return pendingEntries.length === 1
725 }, 5000)
726​
727 // Dispose first environment (simulating page refresh)
728 firstEnv.executor.dispose()
729​
730 // Create a new environment where the mutation fails permanently
731 const secondEnv = createTestOfflineEnvironment({
732 storage,
733 mutationFn: () => {
734 throw new NonRetriableError(`Server rejected mutation permanently`)
735 },
736 })
737​
738 await secondEnv.waitForLeader()
739​
740 // Optimistic state should be restored immediately after initialization
741 expect(secondEnv.collection.get(`ghost-item`)?.value).toBe(`will-fail`)
742​
743 // Wait for the transaction to fail and be removed from outbox
744 await waitUntil(async () => {
745 const entries = await secondEnv.executor.peekOutbox()
746 return entries.length === 0
747 }, 5000)
748​
749 // After permanent failure, the optimistic state should be rolled back
750 // The item should no longer exist in the collection
751 expect(secondEnv.collection.get(`ghost-item`)).toBeUndefined()
752​
753 // And it should not exist on the server either
754 expect(secondEnv.serverState.get(`ghost-item`)).toBeUndefined()
755​
756 secondEnv.executor.dispose()
757 })
758})