Expand package limit and feature details
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-06 13:20:19 +01:00
parent 4fe589f0e2
commit 10fbee4e6e
6 changed files with 263 additions and 7 deletions

View File

@@ -1,11 +1,20 @@
import { describe, expect, it } from 'vitest';
import { formatPackageLimit, getPackageFeatureLabel } from './packageSummary';
import {
collectPackageFeatures,
formatEventUsage,
formatPackageLimit,
getPackageFeatureLabel,
getPackageLimitEntries,
} from './packageSummary';
const t = (key: string, options?: Record<string, unknown> | string) => {
if (typeof options === 'string') {
return options;
}
return (options?.defaultValue as string | undefined) ?? key;
const template = (options?.defaultValue as string | undefined) ?? key;
return template
.replace('{{used}}', String(options?.used ?? '{{used}}'))
.replace('{{limit}}', String(options?.limit ?? '{{limit}}'));
};
describe('packageSummary helpers', () => {
@@ -24,4 +33,28 @@ describe('packageSummary helpers', () => {
it('formats numeric package limits', () => {
expect(formatPackageLimit(12, t)).toBe('12');
});
it('collects features from package and limit payloads', () => {
const result = collectPackageFeatures({
features: ['custom_branding'],
package_limits: { features: ['reseller_dashboard'] },
branding_allowed: true,
watermark_allowed: false,
} as any);
expect(result).toEqual(expect.arrayContaining(['custom_branding', 'reseller_dashboard', 'branding_allowed']));
});
it('returns labeled limit entries', () => {
const result = getPackageLimitEntries({ max_photos: 120 }, t);
expect(result[0].label).toBe('Photos');
expect(result[0].value).toBe('120');
});
it('formats event usage copy', () => {
const result = formatEventUsage(3, 10, t);
expect(result).toBe('3 of 10 events created');
});
});