Files
carmanagement/apps/api/src/lib/emailTranslations.test.ts
T
root 8aab968e09
Build & Deploy / Build & Push Docker Image (push) Successful in 1m2s
Test / Type Check (all packages) (push) Failing after 28s
Test / API Unit Tests (push) Has been skipped
Test / Homepage Unit Tests (push) Has been skipped
Test / Storefront Unit Tests (push) Has been skipped
Test / Admin Unit Tests (push) Has been skipped
Test / Dashboard Unit Tests (push) Has been skipped
Test / API Integration Tests (push) Has been skipped
Build & Deploy / Deploy to VPS (push) Successful in 3s
refactor: rename marketplace to storefront across the entire monorepo
Comprehensive rename of all marketplace references to storefront:
- API module: apps/api/src/modules/marketplace/ → storefront/
- Components: MarketplaceHeader → StorefrontHeader, MarketplaceShell →
  StorefrontShell, MarketplaceFooter → StorefrontFooter
- Types: marketplace-homepage.ts → storefront-homepage.ts
- Test files: employee-marketplace-* → employee-storefront-*
- All source code identifiers, imports, route paths, and strings
- Documentation (docs/), CI config (.gitlab-ci.yml), scripts
- Dashboard, admin, storefront workspace references
- Prisma field names preserved (isListedOnMarketplace, marketplaceRating,
  marketplaceFunnelEvent) as they map to database schema

Validation:
- API type-check: 0 errors
- Storefront type-check: 0 errors
- Dashboard type-check: 0 errors
- Full monorepo type-check: only pre-existing admin TS18046
2026-06-28 01:14:46 -04:00

71 lines
2.5 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
formatDate,
storefrontReservationEmail,
resetPasswordEmail,
signupEmail,
} from './emailTranslations'
describe('emailTranslations', () => {
const trialEnd = new Date('2026-07-15T12:00:00.000Z')
it('renders signup subjects in every supported locale', () => {
expect(signupEmail.subject('en')).toContain('workspace')
expect(signupEmail.subject('fr')).toContain('espace')
expect(signupEmail.subject('ar')).toContain('جاهزة')
})
it('renders localized signup text with billing and provider details', () => {
const text = signupEmail.text({
firstName: 'Aya',
companyName: 'Atlas Cars',
plan: 'PRO',
billingPeriod: 'ANNUAL',
currency: 'MAD',
paymentProvider: 'AmanPay',
trialEnd,
}, 'fr')
expect(text).toContain('Bonjour Aya')
expect(text).toContain('Atlas Cars')
expect(text).toContain('Forfait : PRO (annuel)')
expect(text).toContain('Fournisseur de paiement principal : AmanPay')
})
it('marks Arabic reset-password HTML as right-to-left and embeds the reset URL', () => {
const html = resetPasswordEmail.html('https://example.test/reset/token', 'Mina', 45, 'ar')
expect(html).toContain('dir="rtl"')
expect(html).toContain('https://example.test/reset/token')
expect(html).toContain('45')
})
it('includes optional contact phone in storefront reservation HTML when present', () => {
const html = storefrontReservationEmail.html({
firstName: 'Yassine',
vehicleYear: 2024,
vehicleMake: 'Dacia',
vehicleModel: 'Duster',
companyName: 'Atlas Cars',
startDate: new Date('2026-08-01T00:00:00.000Z'),
endDate: new Date('2026-08-05T00:00:00.000Z'),
totalDays: 4,
rateDisplay: '400.00',
totalDisplay: '1600.00',
email: 'yassine@example.test',
phone: '+212600000000',
}, 'en')
expect(html).toContain('2024 Dacia Duster')
expect(html).toContain('Atlas Cars')
expect(html).toContain('yassine@example.test or +212600000000')
})
it('formats dates with the locale-specific formatter', () => {
expect(formatDate(new Date('2026-02-03T00:00:00.000Z'), 'en')).toContain('2026')
expect(formatDate(new Date('2026-02-03T00:00:00.000Z'), 'fr')).toContain('2026')
expect(formatDate(new Date('2026-02-03T00:00:00.000Z'), 'ar')).toMatch(/2026|٢٠٢٦/)
expect(formatDate(new Date('2026-02-03T00:00:00.000Z'), 'ar')).toContain('فبراير')
})
})