Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions static/gsAdmin/components/customers/customerOverview.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -692,4 +692,42 @@ describe('CustomerOverview', () => {
expect(screen.getByText('null')).toBeInTheDocument();
expect(screen.queryByText('36925')).not.toBeInTheDocument();
});

it('renders org retention', () => {
const organization = OrganizationFixture({});
const subscription = SubscriptionFixture({
organization,
plan: 'am3_f',
orgRetention: {standard: 1234567, downsampled: null},
});

render(
<CustomerOverview
customer={subscription}
onAction={jest.fn()}
organization={organization}
/>
);

expect(screen.getByText('1234567d')).toBeInTheDocument();
});

it('renders org retention default', () => {
const organization = OrganizationFixture({});
const subscription = SubscriptionFixture({
organization,
plan: 'am3_f',
orgRetention: {standard: null, downsampled: null},
});

render(
<CustomerOverview
customer={subscription}
onAction={jest.fn()}
organization={organization}
/>
);

expect(screen.getByText('90d')).toBeInTheDocument();
});
});
4 changes: 3 additions & 1 deletion static/gsAdmin/components/customers/customerOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,9 @@ function CustomerOverview({customer, onAction, organization}: Props) {
<DetailLabel title="Internal ID">{customer.id}</DetailLabel>
<DetailLabel title="Data Storage Location">{region}</DetailLabel>
<DetailLabel title="Data Retention">
{customer.dataRetention || '90d'}
{customer.orgRetention?.standard
? `${customer.orgRetention?.standard}d`
: '90d'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Conditional Logic Misinterprets Zero

The conditional checks if customer.orgRetention?.standard is truthy, which fails when standard is 0 (a valid retention value). This causes 0 to incorrectly fall back to '90d' instead of displaying '0d'. Use customer.orgRetention?.standard != null or defined() to properly handle zero values.

Fix in Cursor Fix in Web

</DetailLabel>
<DetailLabel title="Joined">
{moment(customer.dateJoined).fromNow()}
Expand Down
Loading