- postgresAdapter (uuid ids, no push, prodMigrations), DATABASE_URI - src/payload.shared.ts: the config without the db adapter, shared with the one-off MongoDB content transfer - baseline migration 20260929_200306_initial (86 tables; applied twice on a disposable PostgreSQL 16: second run is a no-op) - seed copy (references, hosting plans) moved to src/content/seeds/ - MongoDB data migrations, their helpers/tests and the dead lib/mongodb.ts removed (kept in git history) - npm scripts for the Payload CLI (works now that the package is ESM) Branch only: staging has no PostgreSQL yet (tasks 3.x). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
67 lines
3.5 KiB
TypeScript
67 lines
3.5 KiB
TypeScript
import { render, screen, within } from '@testing-library/react'
|
|
import '@testing-library/jest-dom'
|
|
import HostingPlansView from './HostingPlansView'
|
|
import { HOSTING_PLANS_PAGE_COPY, pickLanguage } from '@/content/seeds/hosting-plans'
|
|
import type { HostingPlanView } from '@/lib/products'
|
|
|
|
type Content = Parameters<typeof HostingPlansView>[0]['content']
|
|
|
|
const content = (lang: 'hu' | 'en') =>
|
|
({ ...pickLanguage(HOSTING_PLANS_PAGE_COPY as never, lang), vatRatePercent: 27 }) as unknown as Content
|
|
|
|
const plan = (over: Partial<HostingPlanView>): HostingPlanView => ({
|
|
id: 'start',
|
|
slug: 'mit-start',
|
|
name: 'mIT Start',
|
|
highlighted: false,
|
|
audience: 'Egyéni vállalkozóknak',
|
|
shortDescription: 'Tárhely egy weboldalhoz.',
|
|
features: ['Spamszűrés'],
|
|
ctaText: 'Ezt választom',
|
|
netAmount: 14900,
|
|
billingPeriod: 'yearly',
|
|
service: { storageGb: 3, mailStorageGb: 1, domains: 1, domainAliases: 0, databases: 1, mailboxes: 5, backup: 'Napi', ssl: true, spamFilter: true },
|
|
...over,
|
|
})
|
|
|
|
const PLANS = [plan({}), plan({ id: 'mid', slug: 'mit-mid', name: 'mIT Mid', highlighted: true, netAmount: 23900, service: { storageGb: 8, mailboxes: 10, ssl: true, spamFilter: true } })]
|
|
|
|
const text = (el: HTMLElement) => (el.textContent ?? '').replace(/\s/g, ' ')
|
|
|
|
describe('HostingPlansView (MITHOME-130)', () => {
|
|
it('should show both plans as cards with their comparison rows', () => {
|
|
render(<HostingPlansView content={content('hu')} plans={PLANS} locale="hu" />)
|
|
expect(screen.getByRole('heading', { level: 1, name: 'Tárhelycsomagok' })).toBeInTheDocument()
|
|
const start = screen.getByTestId('plan-mit-start')
|
|
expect(within(start).getByRole('heading', { name: 'mIT Start' })).toBeInTheDocument()
|
|
expect(text(start)).toContain('Tárhely összesen3 GB')
|
|
expect(text(start)).toContain('E-mail-fiók (legfeljebb)5')
|
|
expect(text(screen.getByTestId('plan-mit-mid'))).toContain('Tárhely összesen8 GB')
|
|
})
|
|
|
|
it('should show the net price with VAT and the gross price per year', () => {
|
|
render(<HostingPlansView content={content('hu')} plans={PLANS} locale="hu" />)
|
|
const start = text(screen.getByTestId('plan-mit-start'))
|
|
expect(start).toContain('14 900 Ft + ÁFA / év')
|
|
expect(start).toContain('bruttó 18 923 Ft / év')
|
|
expect(text(screen.getByTestId('plan-mit-mid'))).toContain('bruttó 30 353 Ft / év')
|
|
})
|
|
|
|
it('should format the English page and mark only the highlighted plan', () => {
|
|
render(<HostingPlansView content={content('en')} plans={PLANS} locale="en" />)
|
|
expect(text(screen.getByTestId('plan-mit-start'))).toContain('14,900 Ft + VAT / year')
|
|
expect(within(screen.getByTestId('plan-mit-mid')).getByText('Recommended')).toBeInTheDocument()
|
|
expect(within(screen.getByTestId('plan-mit-start')).queryByText('Recommended')).not.toBeInTheDocument()
|
|
})
|
|
|
|
it('should offer a custom quote only for larger needs, linking to the contact page', () => {
|
|
render(<HostingPlansView content={content('hu')} plans={PLANS} locale="hu" />)
|
|
expect(screen.getAllByText(/ajánlat/i)).toHaveLength(2) // larger-needs text + button, never a card
|
|
expect(screen.getByRole('link', { name: 'Kérjen egyedi ajánlatot' })).toHaveAttribute('href', '/hu/kapcsolat')
|
|
for (const card of [screen.getByTestId('plan-mit-start'), screen.getByTestId('plan-mit-mid')]) {
|
|
expect(within(card).queryByText(/ajánlat/i)).not.toBeInTheDocument()
|
|
expect(within(card).getByRole('link', { name: 'Ezt választom' })).toHaveAttribute('href', '/hu/kapcsolat')
|
|
}
|
|
})
|
|
})
|