MCPcopy Create free account
hub / github.com/TanStack/db / runTestsForSyncMode

Function runTestsForSyncMode

packages/db-collection-e2e/src/suites/moves.suite.ts:140–749  ·  view source on GitHub ↗
(syncMode: SyncMode)

Source from the content-addressed store, hash-verified

138
139 // Helper function to run all tests for a given sync mode
140 function runTestsForSyncMode(syncMode: SyncMode) {
141 describe(`${syncMode} mode`, () => {
142 it(`Initial snapshot contains only posts from active users`, async () => {
143 // Create collection on posts with WHERE clause: userId IN (SELECT id FROM users WHERE isActive = true)
144 const collection = createPostsByActiveUsersCollection(syncMode)
145
146 if (!config.mutations) {
147 throw new Error(`Mutations not configured`)
148 }
149
150 // Insert 2 active users and 1 inactive user
151 const userId1 = randomUUID()
152 const userId2 = randomUUID()
153 const userId3 = randomUUID()
154
155 await config.mutations.insertUser({
156 id: userId1,
157 name: `Active User 1`,
158 email: `user1@test.com`,
159 age: 25,
160 isActive: true,
161 createdAt: new Date(),
162 metadata: null,
163 deletedAt: null,
164 })
165
166 await config.mutations.insertUser({
167 id: userId2,
168 name: `Active User 2`,
169 email: `user2@test.com`,
170 age: 30,
171 isActive: true,
172 createdAt: new Date(),
173 metadata: null,
174 deletedAt: null,
175 })
176
177 await config.mutations.insertUser({
178 id: userId3,
179 name: `Inactive User`,
180 email: `user3@test.com`,
181 age: 42,
182 isActive: false,
183 createdAt: new Date(),
184 metadata: null,
185 deletedAt: null,
186 })
187
188 // Wait for all 3 users to be synced to Electric before inserting posts
189 // This ensures the subquery in the WHERE clause can properly evaluate
190 await waitForUsersSynced([userId1, userId2, userId3])
191
192 // Insert posts for these users
193 const postId1 = randomUUID()
194 const postId2 = randomUUID()
195 const postId3 = randomUUID()
196
197 await config.mutations.insertPost({

Callers 1

createMovesTestSuiteFunction · 0.85

Calls 11

expectFunction · 0.90
waitForUsersSyncedFunction · 0.85
waitForReadyFunction · 0.85
waitForItemFunction · 0.85
waitForItemRemovedFunction · 0.85
randomUUIDFunction · 0.50
hasMethod · 0.45
queryMethod · 0.45
cleanupMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected