From 907632a6f6fbeee7d2b128303fa8e3893f5e9c0d Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 31 Dec 2025 02:23:43 +0900 Subject: test(sync): add client-side sync tests for note-related entities MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add comprehensive tests for syncing NoteType, NoteFieldType, Note, and NoteFieldValue entities in push.test.ts and pull.test.ts. Tests cover: - Data format conversion between local and server representations - Applying pulled entities to local IndexedDB - Pushing pending changes to server - Updating existing entities during sync - Syncing all note-related entities together Also removes unused variable in sync repository. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/server/repositories/sync.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/server/repositories') diff --git a/src/server/repositories/sync.ts b/src/server/repositories/sync.ts index ac9b336..8c4fd25 100644 --- a/src/server/repositories/sync.ts +++ b/src/server/repositories/sync.ts @@ -5,8 +5,8 @@ import { decks, noteFieldTypes, noteFieldValues, - noteTypes, notes, + noteTypes, reviewLogs, } from "../db/schema.js"; import type { @@ -634,9 +634,7 @@ export const syncRepository: SyncRepository = { noteTypeId: noteData.noteTypeId, createdAt: new Date(noteData.createdAt), updatedAt: clientUpdatedAt, - deletedAt: noteData.deletedAt - ? new Date(noteData.deletedAt) - : null, + deletedAt: noteData.deletedAt ? new Date(noteData.deletedAt) : null, syncVersion: 1, }) .returning({ id: notes.id, syncVersion: notes.syncVersion }); @@ -860,10 +858,7 @@ export const syncRepository: SyncRepository = { pulledNotes = noteResults.filter((n) => deckIdList.includes(n.deckId)); } - // Get note IDs for filtering note field values - const noteIdList = pulledNotes.map((n) => n.id); - - // Also get all user's note IDs (not just recently synced ones) for field value filtering + // Get all user's note IDs (not just recently synced ones) for field value filtering let allUserNoteIds: string[] = []; if (deckIdList.length > 0) { const allNotes = await db -- cgit v1.2.3-70-g09d2