diff --git a/models/Notification.test.ts b/models/Notification.test.ts new file mode 100644 index 000000000..be4ec0b45 --- /dev/null +++ b/models/Notification.test.ts @@ -0,0 +1,83 @@ +import mongoose from 'mongoose'; +import { describe, it, expect } from 'vitest'; +import { Notification } from './Notification'; + +describe('Notification Model', () => { + it('is compiled properly and exposed', () => { + expect(Notification).toBeDefined(); + expect(Notification.modelName).toBe('Notification'); + }); + + it('enforces required, unique, and lowercase fields on username', () => { + const usernamePath = Notification.schema.path('username') as mongoose.SchemaType & { + options: Record; + }; + + expect(usernamePath).toBeDefined(); + expect(usernamePath.options.required).toBe(true); + expect(usernamePath.options.unique).toBe(true); + expect(usernamePath.options.lowercase).toBe(true); + expect(usernamePath.options.trim).toBe(true); + }); + + it('enforces required, lowercase, and trim fields on email', () => { + const emailPath = Notification.schema.path('email') as mongoose.SchemaType & { + options: Record; + }; + + expect(emailPath).toBeDefined(); + expect(emailPath.options.required).toBe(true); + expect(emailPath.options.lowercase).toBe(true); + expect(emailPath.options.trim).toBe(true); + }); + + it('validates frequency field and its defaults and enums', () => { + const frequencyPath = Notification.schema.path('frequency') as mongoose.SchemaType & { + options: Record; + enumValues: string[]; + }; + + expect(frequencyPath).toBeDefined(); + expect(frequencyPath.options.default).toBe('daily'); + expect(frequencyPath.enumValues).toContain('realtime'); + expect(frequencyPath.enumValues).toContain('daily'); + expect(frequencyPath.enumValues).toContain('weekly'); + }); + + it('checks boolean notification switches have default value as true', () => { + const notifyOnCommitPath = Notification.schema.path('notifyOnCommit') as mongoose.SchemaType & { + options: Record; + }; + const notifyOnStreakPath = Notification.schema.path('notifyOnStreak') as mongoose.SchemaType & { + options: Record; + }; + const notifyOnMilestonePath = Notification.schema.path( + 'notifyOnMilestone' + ) as mongoose.SchemaType & { + options: Record; + }; + + expect(notifyOnCommitPath.options.default).toBe(true); + expect(notifyOnStreakPath.options.default).toBe(true); + expect(notifyOnMilestonePath.options.default).toBe(true); + }); + + it('checks isActive default value is true', () => { + const isActivePath = Notification.schema.path('isActive') as mongoose.SchemaType & { + options: Record; + }; + expect(isActivePath.options.default).toBe(true); + }); + + it('checks createdAt and updatedAt have default values', () => { + const createdAtPath = Notification.schema.path('createdAt') as mongoose.SchemaType & { + options: Record; + }; + const updatedAtPath = Notification.schema.path('updatedAt') as mongoose.SchemaType & { + options: Record; + }; + + expect(createdAtPath.options.default).toBeDefined(); + expect(updatedAtPath.options.default).toBeDefined(); + }); +}); diff --git a/vercel.json b/vercel.json index 0fe65fc85..87597cf1c 100644 --- a/vercel.json +++ b/vercel.json @@ -1,3 +1,10 @@ { - "ignoreCommand": "bash vercel-ignore.sh" + "ignoreCommand": "bash vercel-ignore.sh", + "git": { + "deploymentEnabled": { + "main": true, + "fix/issue-*": false, + "test/*": false + } + } }