Skip to content

Commit 3bdb5ab

Browse files
committed
test: make array txid test more realistic with staggered arrivals
Update the test to send txids on different ticks (50ms and 100ms apart) rather than in a single batch. This better simulates real-world conditions where multiple txids rarely arrive together.
1 parent 00227a1 commit 3bdb5ab

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

packages/electric-db-collection/tests/electric.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,8 @@ describe(`Electric Integration`, () => {
683683
const onInsert = vi.fn(async (params: MutationFnParams<Row>) => {
684684
const txids = await fakeBackend.persist(params.transaction.mutations)
685685

686-
// Simulate server sending sync messages after a delay
686+
// Simulate server sending sync messages on different ticks
687+
// In the real world, multiple txids rarely arrive together
687688
setTimeout(() => {
688689
subscriber([
689690
{
@@ -694,6 +695,12 @@ describe(`Electric Integration`, () => {
694695
txids: [txids[0]],
695696
},
696697
},
698+
{ headers: { control: `up-to-date` } },
699+
])
700+
}, 50)
701+
702+
setTimeout(() => {
703+
subscriber([
697704
{
698705
key: `2`,
699706
value: { id: 2, name: `Item 2` },
@@ -704,7 +711,7 @@ describe(`Electric Integration`, () => {
704711
},
705712
{ headers: { control: `up-to-date` } },
706713
])
707-
}, 50)
714+
}, 100)
708715

709716
// Return array of txids - this is the pattern that's failing
710717
return { txid: txids }

0 commit comments

Comments
 (0)