Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
48 lines
1.4 KiB
TypeScript
48 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { ArticleFormValidation } from '@/validation/blogArticles'
|
|
|
|
const baseValues = {
|
|
slug: 'scheduled-article',
|
|
title: 'عنوان مقاله زمانبندیشده',
|
|
excerpt: 'این خلاصه برای معرفی کامل مقاله نوشته شده است و طول کافی برای استفاده در نتایج جستجو را دارد.',
|
|
metaTitle: '',
|
|
metaDescription: '',
|
|
categorySlug: 'attendee-guide' as const,
|
|
categoryName: 'راهنمای شرکتکنندگان',
|
|
cityId: '',
|
|
eventCategoryId: '',
|
|
bodyHtml: '<p>متن مقاله</p>',
|
|
featuredImageUrl: '',
|
|
isFeatured: false,
|
|
isPublished: false,
|
|
scheduledDate: '',
|
|
scheduledTime: 0,
|
|
}
|
|
|
|
describe('ArticleFormValidation scheduling', () => {
|
|
it('accepts an unscheduled draft', () => {
|
|
expect(ArticleFormValidation.safeParse(baseValues).success).toBe(true)
|
|
})
|
|
|
|
it('accepts a future scheduled publication', () => {
|
|
expect(
|
|
ArticleFormValidation.safeParse({
|
|
...baseValues,
|
|
scheduledDate: '2099-01-01T00:00:00.000Z',
|
|
scheduledTime: 12 * 60,
|
|
}).success
|
|
).toBe(true)
|
|
})
|
|
|
|
it('rejects a scheduled publication in the past', () => {
|
|
const result = ArticleFormValidation.safeParse({
|
|
...baseValues,
|
|
scheduledDate: '2020-01-01T00:00:00.000Z',
|
|
scheduledTime: 12 * 60,
|
|
})
|
|
|
|
expect(result.success).toBe(false)
|
|
})
|
|
})
|