Files
websitedev/proto/src/lib/products.test.ts
T
Do SikiandClaude Opus 5.5 1e0742a548
CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Canceled after 0s
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Canceled after 0s
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Canceled after 0s
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Canceled after 0s
feat(cms): hosting plans page with lifecycle gate and net + VAT prices (MITHOME-130)
- Products collection (interim mirror of the PLATFM-14 catalogue contract):
  lifecycle status, product type, required whole-forint net price, yearly
  billing, service definition, per-product English gate
- HostingPlans global: page copy, comparison labels, VAT rate (27%)
- Gate: production shows only active plans, staging all but retired; with no
  showable plan the page is 404 and left out of the menu and the sitemap
- /hu/tarhely-csomagok <-> /en/hosting-plans via PAGE_SLUGS (hreflang,
  language switcher, CTA page picker)
- Seed migration 20260929_hosting_plans: mIT Start (14 900 Ft/yr, 5 mailboxes)
  and mIT Mid (23 900 Ft/yr) as drafts, English AI draft; idempotent
- Production SEO suite expects at least 12 sitemap URLs; new SMOKE-10

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 19:36:44 +02:00

78 lines
3.4 KiB
TypeScript

import { formatHuf, grossAmount, hostingPlanViews, showableStatuses, type ProductDoc } from './products'
const product = (over: Partial<ProductDoc> = {}): ProductDoc => ({
id: 'p1',
slug: 'mit-start',
name: 'mIT Start',
productType: 'hosting',
status: 'draft',
sortOrder: 10,
enTranslationStatus: 'ai-draft',
public: { audience: 'Kinek', shortDescription: 'Leírás', features: [{ value: 'SSL' }], ctaText: 'Ezt választom' },
pricing: { netAmount: 14900, billingPeriod: 'yearly' },
serviceDefinition: { storageGb: 3, mailboxes: 5, ssl: true },
...over,
})
const normalizeSpaces = (text: string) => text.replace(/\s/g, ' ')
describe('hosting plans (MITHOME-130)', () => {
it('should show only active products in production and everything but retired on staging', () => {
expect(showableStatuses(undefined)).toEqual(['active'])
expect(showableStatuses('production')).toEqual(['active'])
expect(showableStatuses('staging')).toEqual(['draft', 'internal', 'publishable', 'active'])
})
it('should compute the gross price from the net price and the VAT rate', () => {
expect(grossAmount(14900)).toBe(18923)
expect(grossAmount(23900, 27)).toBe(30353)
expect(grossAmount(10001, 27)).toBe(12701)
expect(grossAmount(1000, 0)).toBe(1000)
})
it('should format forint amounts per locale', () => {
expect(normalizeSpaces(formatHuf(14900, 'hu'))).toBe('14 900 Ft')
expect(formatHuf(14900, 'en')).toBe('14,900 Ft')
})
it('should gate by status and type, and order by sortOrder', () => {
const docs = [
product({ id: 'mid', slug: 'mit-mid', sortOrder: 20 }),
product({ id: 'start', sortOrder: 10 }),
product({ id: 'old', slug: 'old', status: 'retired' }),
product({ id: 'webor', slug: 'webor', productType: 'managed-service' }),
product({ id: 'live', slug: 'live', status: 'active', sortOrder: 30 }),
]
expect(hostingPlanViews('hu', docs, [], showableStatuses('staging')).map((p) => p.id)).toEqual(['start', 'mid', 'live'])
expect(hostingPlanViews('hu', docs, [], showableStatuses('production')).map((p) => p.id)).toEqual(['live'])
})
it('should never show a plan without a price', () => {
const docs = [product({ pricing: { netAmount: null, billingPeriod: 'yearly' } })]
expect(hostingPlanViews('hu', docs, [], ['draft'])).toEqual([])
})
it('should apply the English gate per product', () => {
const en = [
product({ id: 'a', public: { audience: 'EN draft' }, enTranslationStatus: 'ai-draft' }),
product({ id: 'b', public: { audience: 'EN approved' }, enTranslationStatus: 'approved', sortOrder: 20 }),
]
const hu = [product({ id: 'a', public: { audience: 'HU a' } }), product({ id: 'b', public: { audience: 'HU b' }, sortOrder: 20 })]
expect(hostingPlanViews('en', en, hu, ['draft']).map((p) => p.audience)).toEqual(['HU a', 'EN approved'])
expect(hostingPlanViews('hu', hu, [], ['draft']).map((p) => p.audience)).toEqual(['HU a', 'HU b'])
})
it('should build the view model with unwrapped features and service figures', () => {
const [view] = hostingPlanViews('hu', [product({ highlighted: true })], [], ['draft'])
expect(view).toMatchObject({
slug: 'mit-start',
highlighted: true,
features: ['SSL'],
netAmount: 14900,
billingPeriod: 'yearly',
service: { storageGb: 3, mailboxes: 5, ssl: true, spamFilter: false },
})
expect(view.service.databases).toBeUndefined()
})
})