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
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
121 lines
4.5 KiB
TypeScript
121 lines
4.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import type { TFunction } from 'i18next';
|
|
|
|
import { getRecurringAuthoringPreview } from '../src/components/billing-dashboard/contracts/recurringAuthoringPreview';
|
|
|
|
// Fake t that returns `defaultValue` interpolated with params, mirroring i18next's
|
|
// English fallback path. Lets the English copy assertions below exercise the helper
|
|
// without spinning up an i18next instance.
|
|
const mockT: TFunction = ((key: string, options?: Record<string, unknown>) => {
|
|
const fallback = (options?.defaultValue as string | undefined) ?? key;
|
|
if (!options) return fallback;
|
|
return fallback.replace(/\{\{(\w+)\}\}/g, (_, name: string) =>
|
|
options[name] != null ? String(options[name]) : `{{${name}}}`,
|
|
);
|
|
}) as unknown as TFunction;
|
|
|
|
describe('recurring authoring preview copy', () => {
|
|
it('T238: authoring previews explain first invoice behavior correctly for client-cadence recurring lines', () => {
|
|
expect(
|
|
getRecurringAuthoringPreview({
|
|
cadenceOwner: 'client',
|
|
billingTiming: 'arrears',
|
|
enableProration: true,
|
|
}, mockT),
|
|
).toMatchObject({
|
|
cadenceOwnerLabel: 'Client billing schedule',
|
|
firstInvoiceSummary:
|
|
'First invoice: bill on the next client billing schedule window after the first covered service period closes.',
|
|
partialPeriodSummary:
|
|
'Partial periods adjust the recurring fee to the covered portion of the service period.',
|
|
});
|
|
|
|
expect(
|
|
getRecurringAuthoringPreview({
|
|
cadenceOwner: 'client',
|
|
billingTiming: 'advance',
|
|
enableProration: false,
|
|
}, mockT),
|
|
).toMatchObject({
|
|
firstInvoiceSummary:
|
|
'First invoice: bill on the first client billing schedule window covering the service period.',
|
|
partialPeriodSummary:
|
|
'Partial periods keep the full recurring fee even when contract dates land inside a service period.',
|
|
});
|
|
});
|
|
|
|
it('T239: authoring previews explain first invoice behavior correctly for contract-cadence recurring lines', () => {
|
|
expect(
|
|
getRecurringAuthoringPreview({
|
|
cadenceOwner: 'contract',
|
|
billingTiming: 'advance',
|
|
enableProration: true,
|
|
}, mockT),
|
|
).toMatchObject({
|
|
cadenceOwnerLabel: 'Contract anniversary',
|
|
firstInvoiceSummary:
|
|
'First invoice: bill on the contract anniversary window that opens the first covered service period.',
|
|
});
|
|
|
|
expect(
|
|
getRecurringAuthoringPreview({
|
|
cadenceOwner: 'contract',
|
|
billingTiming: 'arrears',
|
|
enableProration: false,
|
|
}, mockT),
|
|
).toMatchObject({
|
|
firstInvoiceSummary:
|
|
'First invoice: bill on the next contract anniversary window after the first covered service period closes.',
|
|
partialPeriodSummary:
|
|
'Partial periods keep the full recurring fee even when contract dates land inside a service period.',
|
|
});
|
|
});
|
|
|
|
it('T308: schedule previews and explainers show illustrative future materialized service periods before a contract line is saved', () => {
|
|
expect(
|
|
getRecurringAuthoringPreview({
|
|
cadenceOwner: 'client',
|
|
billingTiming: 'advance',
|
|
billingFrequency: 'monthly',
|
|
enableProration: true,
|
|
}, mockT),
|
|
).toMatchObject({
|
|
materializedPeriodsHeading: 'Illustrative future materialized periods',
|
|
materializedPeriodsSummary:
|
|
'If you save this recurring line, future periods would materialize on the client billing schedule preview before invoice generation.',
|
|
materializedPeriods: expect.arrayContaining([
|
|
{
|
|
servicePeriodLabel: '2025-04-01 to 2025-05-01',
|
|
invoiceWindowLabel: '2025-04-01 to 2025-05-01',
|
|
},
|
|
{
|
|
servicePeriodLabel: '2025-05-01 to 2025-06-01',
|
|
invoiceWindowLabel: '2025-05-01 to 2025-06-01',
|
|
},
|
|
]),
|
|
});
|
|
|
|
expect(
|
|
getRecurringAuthoringPreview({
|
|
cadenceOwner: 'contract',
|
|
billingTiming: 'arrears',
|
|
billingFrequency: 'monthly',
|
|
enableProration: false,
|
|
}, mockT),
|
|
).toMatchObject({
|
|
materializedPeriodsSummary:
|
|
'If you save this recurring line, future periods would materialize on an anniversary-style preview anchored to the 8th before invoice generation.',
|
|
materializedPeriods: expect.arrayContaining([
|
|
{
|
|
servicePeriodLabel: '2025-04-08 to 2025-05-08',
|
|
invoiceWindowLabel: '2025-05-08 to 2025-06-08',
|
|
},
|
|
{
|
|
servicePeriodLabel: '2025-05-08 to 2025-06-08',
|
|
invoiceWindowLabel: '2025-06-08 to 2025-07-08',
|
|
},
|
|
]),
|
|
});
|
|
});
|
|
});
|