Skip to content

Commit a7a5fa1

Browse files
Danny-Devsclaude
andcommitted
test(vue-db): add regression test for startSync override prevention
Verifies that passing `startSync: false` in a config object does not prevent sync — `startSync: true` is always forced after the user spread. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ccc3255 commit a7a5fa1

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

packages/vue-db/tests/useLiveQuery-bestpractices.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,32 @@ describe(`Vue best-practice fixes`, () => {
337337
expect((returnedCollection.value as any).config.gcTime).toBe(60000)
338338
})
339339

340+
it(`should force startSync even if user config passes startSync: false`, async () => {
341+
const collection = createCollection(
342+
mockSyncCollectionOptions<Person>({
343+
id: `startsync-forced-test`,
344+
getKey: (person: Person) => person.id,
345+
initialData: initialPersons,
346+
}),
347+
)
348+
349+
const { data } = useLiveQuery({
350+
query: (q) =>
351+
q
352+
.from({ persons: collection })
353+
.select(({ persons }) => ({
354+
id: persons.id,
355+
name: persons.name,
356+
})),
357+
startSync: false, // User tries to disable sync — should be overridden
358+
})
359+
360+
await waitForVueUpdate()
361+
362+
// startSync is forced to true, so data should still load
363+
expect(data.value.length).toBe(3)
364+
})
365+
340366
it(`should not override gcTime on pre-created collections`, async () => {
341367
const collection = createCollection(
342368
mockSyncCollectionOptions<Person>({

0 commit comments

Comments
 (0)