Skip to content

The open alternative to Salesforce, designed for AI.

Truncate application registration credits display (#28452)

martmull08ef1c23a614
diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationInstallStats.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationInstallStats.tsx
index fd98bde5a53..b6da74273d2 100644
--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationInstallStats.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationInstallStats.tsx
@@ -107,7 +107,10 @@ export const SettingsApplicationRegistrationInstallStats = ({
const formatCredits = (credits: number | null | undefined) =>
isDefined(credits)
- ? i18n.number(credits, { maximumFractionDigits: 6 })
+ ? i18n.number(credits, {
+ maximumFractionDigits: credits >= 10 ? 0 : 2,
+ roundingMode: 'trunc',
+ })
: '—';
const creditsUsedItems = [
diff --git a/packages/twenty-front/src/pages/settings/applications/components/__tests__/SettingsApplicationRegistrationInstallStats.test.tsx b/packages/twenty-front/src/pages/settings/applications/components/__tests__/SettingsApplicationRegistrationInstallStats.test.tsx
index fee497c4b0a..3ffd62c18f2 100644
--- a/packages/twenty-front/src/pages/settings/applications/components/__tests__/SettingsApplicationRegistrationInstallStats.test.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/components/__tests__/SettingsApplicationRegistrationInstallStats.test.tsx
@@ -24,14 +24,14 @@ const STATS: ApplicationRegistrationStats = {
autoUpdateEnabled: 2,
mostInstalledVersion: '1.2.3',
versionDistribution: [{ version: '1.2.3', count: 4 }],
- totalCreditsUsed: 3.000001,
+ totalCreditsUsed: 1172.966302,
creditsUsedBreakdown: [
{
label: null,
operation: UsageOperationType.CODE_EXECUTION,
- creditsUsed: 3,
+ creditsUsed: 1171.704,
},
- { label: 'HISTORICAL_OPERATION', operation: null, creditsUsed: 0.000001 },
+ { label: 'HISTORICAL_OPERATION', operation: null, creditsUsed: 1.262302 },
],
};
@@ -81,10 +81,11 @@ describe('Application registration statistics', () => {
async (isAdminView) => {
renderStats(STATS, isAdminView);
- expect(await screen.findByText('3.000001')).toBeVisible();
+ expect(await screen.findByText('1,172')).toBeVisible();
expect(screen.getByText('Code Execution')).toBeVisible();
+ expect(screen.getByText('1,171')).toBeVisible();
expect(screen.getByText('HISTORICAL_OPERATION')).toBeVisible();
- expect(screen.getByText('0.000001')).toBeVisible();
+ expect(screen.getByText('1.26')).toBeVisible();
expect(
screen.queryByText('On suspended workspaces'),
).not.toBeInTheDocument();
@@ -94,7 +95,7 @@ describe('Application registration statistics', () => {
it('requests the selected credit period', async () => {
const user = userEvent.setup();
renderStats();
- expect(await screen.findByText('3.000001')).toBeVisible();
+ expect(await screen.findByText('1,172')).toBeVisible();
await user.click(screen.getByText('Last 30 days'));
await user.click(await screen.findByText('Last 7 days'));
expect(await screen.findByText('7')).toBeVisible();