PSA/packages/billing/tests/InvoicingLocaleSmoke.i18n.test.ts
Hermes 284313f908
Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Initial import of AlgaPSA codebase from PSA server
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz

Source: /opt/alga-psa on psa.joliet.tech
2026-06-22 16:12:17 -05:00

128 lines
3.7 KiB
TypeScript

// @vitest-environment node
import fs from 'node:fs';
import path from 'node:path';
import { describe, expect, it } from 'vitest';
function readJson<T>(relativePath: string): T {
return JSON.parse(
fs.readFileSync(path.resolve(__dirname, relativePath), 'utf8'),
) as T;
}
function getLeaf(record: Record<string, unknown>, dottedPath: string): unknown {
return dottedPath.split('.').reduce<unknown>((value, key) => {
if (!value || typeof value !== 'object' || Array.isArray(value)) {
return undefined;
}
return (value as Record<string, unknown>)[key];
}, record);
}
describe('Invoicing locale smoke', () => {
it('T002: English invoicing namespace exposes the expected top-level groups', () => {
const en = readJson<Record<string, unknown>>(
'../../../server/public/locales/en/msp/invoicing.json',
);
expect(Object.keys(en)).toEqual([
'automaticInvoices',
'manualInvoices',
'draftsTab',
'finalizedTab',
'recurringServicePeriods',
'billingCycles',
'invoicePreview',
'templateEditor',
'templates',
'externalTax',
'sendEmail',
'generateTab',
'prepayment',
'contractItems',
'hub',
'templateManager',
'taxBadge',
'annotations',
'purchaseOrder',
'common',
'designer',
]);
});
it('T048: xx pseudo-locale covers representative invoicing hub/generate/drafts/finalized chrome with fill markers instead of English', () => {
const xx = readJson<Record<string, unknown>>(
'../../../server/public/locales/xx/msp/invoicing.json',
);
const pseudoKeys = [
'hub.title',
'hub.tabs.generate',
'hub.tabs.drafts',
'hub.tabs.finalized',
'generateTab.fields.invoiceType',
'generateTab.types.automatic',
'draftsTab.empty.title',
'draftsTab.empty.description',
'finalizedTab.empty.title',
'finalizedTab.empty.viewDrafts',
];
for (const key of pseudoKeys) {
expect(getLeaf(xx, key)).toBe('11111');
}
});
it('T049: xx pseudo-locale covers representative template list/editor/manager chrome with fill markers instead of English', () => {
const xx = readJson<Record<string, unknown>>(
'../../../server/public/locales/xx/msp/invoicing.json',
);
const pseudoKeys = [
'templates.title',
'templates.actions.create',
'templateEditor.titles.create',
'templateEditor.tabs.visual',
'templateEditor.actions.save',
'templateManager.title',
'templateManager.templatePreview',
];
for (const key of pseudoKeys) {
expect(getLeaf(xx, key)).toBe('11111');
}
});
it('T050: de locale exposes translated billing cycles chrome, anchor labels, and month names', () => {
const en = readJson<Record<string, unknown>>(
'../../../server/public/locales/en/msp/invoicing.json',
);
const de = readJson<Record<string, unknown>>(
'../../../server/public/locales/de/msp/invoicing.json',
);
const translatedKeys = [
'billingCycles.title',
'billingCycles.columns.client',
'billingCycles.columns.contract',
'billingCycles.columns.anchor',
'billingCycles.actions.viewClientBilling',
'billingCycles.months.january',
'billingCycles.months.february',
'billingCycles.values.weekday',
'billingCycles.values.rolling',
'billingCycles.values.starts',
];
for (const key of translatedKeys) {
const english = getLeaf(en, key);
const german = getLeaf(de, key);
expect(german).toBeDefined();
expect(german).not.toBe(english);
}
expect(getLeaf(de, 'billingCycles.values.monthDay')).toBe('{{month}} {{day}}');
});
});