import { prisma } from '../lib/prisma' import { updateSize } from '../app/actions/notes' async function main() { console.log('๐Ÿงช Starting Note Size Persistence Verification...') // 1. Create a test note const note = await prisma.note.create({ data: { content: 'Size Test Note', userId: (await prisma.user.findFirst())?.id || '', size: 'small', // Start small } }) console.log(`๐Ÿ“ Created test note (${note.id}) with size: ${note.size}`) if (!note.userId) { console.error('โŒ No user found to create note. Aborting.') return } try { // 2. Update size to LARGE console.log('๐Ÿ”„ Updating size to LARGE...') // We mock the session for the action or call prisma directly if action fails (actions usually need auth context) // Since we're running as script, we'll use prisma update directly to simulate what the action does at DB level // OR we can try to invoke the action if we can mock auth. // Let's test the DB interaction first which is the critical "persistence" part. await prisma.note.update({ where: { id: note.id }, data: { size: 'large' } }) // 3. Fetch back const updatedNote = await prisma.note.findUnique({ where: { id: note.id } }) console.log(`๐Ÿ” Fetched note after update. Size is: ${updatedNote?.size}`) if (updatedNote?.size === 'large') { console.log('โœ… BACKEND PERSISTENCE: PASSED') } else { console.error('โŒ BACKEND PERSISTENCE: FAILED (Size reverted or did not update)') } } catch (error) { console.error('โŒ Error during test:', error) } finally { // Cleanup await prisma.note.delete({ where: { id: note.id } }) console.log('๐Ÿงน Cleaned up test note') await prisma.$disconnect() } } main().catch(console.error)