Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
import i18n from 'i18next'
import { beforeAll, describe, expect, it } from 'vitest'
import { typeLabel } from '../src/lib/type-labels'
import { defineDashboardPlugin } from '../src/plugin'
beforeAll(async () => {
await i18n.init({
lng: 'en',
resources: {
en: {
translation: {
admin: {
types: { promotion_rule: { item_total: { name: 'Item total' } } },
actions: { save: 'Save' },
},
},
},
},
})
})
describe('defineDashboardPlugin locales', () => {
it('lets a plugin name the types it registers, without dropping built-in keys', () => {
defineDashboardPlugin({
locales: {
en: {
admin: {
types: { promotion_rule: { wishlist_count: { name: 'On a wishlist' } } },
},
},
},
})
// The plugin's own type now reads as words rather than the API's fallback.
expect(typeLabel('promotion_rule', 'wishlist_count', 'Wishlist count')).toBe('On a wishlist')
// Merged, not replaced: sibling and unrelated keys survive.
expect(typeLabel('promotion_rule', 'item_total')).toBe('Item total')
expect(i18n.t('admin.actions.save')).toBe('Save')
})
it('registers each language it is given', () => {
defineDashboardPlugin({
locales: {
de: { admin: { types: { promotion_rule: { loyalty_tier: { name: 'Treuestufe' } } } } },
},
})
expect(
i18n.getResource('de', 'translation', 'admin.types.promotion_rule.loyalty_tier.name'),
).toBe('Treuestufe')
})
})