From 18d1a6c1bc067b868784c572acafb4f828020cfa Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Wed, 26 Mar 2025 14:53:51 +0200 Subject: [PATCH] feat: show seats used only for full enterprise customers (#9618) --- .../users/UsersHeader/UsersHeader.test.tsx | 71 +++++++++++++++++++ .../admin/users/UsersHeader/UsersHeader.tsx | 8 ++- 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 frontend/src/component/admin/users/UsersHeader/UsersHeader.test.tsx diff --git a/frontend/src/component/admin/users/UsersHeader/UsersHeader.test.tsx b/frontend/src/component/admin/users/UsersHeader/UsersHeader.test.tsx new file mode 100644 index 0000000000..6be77f182a --- /dev/null +++ b/frontend/src/component/admin/users/UsersHeader/UsersHeader.test.tsx @@ -0,0 +1,71 @@ +import { screen } from '@testing-library/react'; +import { render } from 'utils/testRenderer'; +import { UsersHeader } from './UsersHeader'; +import { testServerRoute, testServerSetup } from 'utils/testServer'; + +describe('UsersHeader', () => { + const server = testServerSetup(); + + test('should show LicensedUsersBox for enterprise customers that are not PAYG', async () => { + testServerRoute(server, '/api/admin/ui-config', { + environment: 'enterprise', + versionInfo: { + current: { enterprise: '1.0.0' }, + }, + billing: 'enterprise', + }); + + render(); + + expect( + await screen.findByText('Seats used over the last 30 days'), + ).toBeInTheDocument(); + }); + + test('should not show LicensedUsersBox for enterprise customers with PAYG billing', async () => { + testServerRoute(server, '/api/admin/ui-config', { + environment: 'enterprise', + versionInfo: { + current: { enterprise: '1.0.0' }, + }, + billing: 'pay-as-you-go', + }); + + render(); + + expect( + screen.queryByText('Seats used over the last 30 days'), + ).not.toBeInTheDocument(); + }); + + test('should not show LicensedUsersBox for Pro customers', async () => { + testServerRoute(server, '/api/admin/ui-config', { + environment: 'pro', + versionInfo: { + current: {}, + }, + billing: 'pro', + }); + + render(); + + expect( + screen.queryByText('Seats used over the last 30 days'), + ).not.toBeInTheDocument(); + }); + + test('should not show LicensedUsersBox for OSS users', async () => { + testServerRoute(server, '/api/admin/ui-config', { + environment: 'OSS', + versionInfo: { + current: {}, + }, + }); + + render(); + + expect( + screen.queryByText('Seats used over the last 30 days'), + ).not.toBeInTheDocument(); + }); +}); diff --git a/frontend/src/component/admin/users/UsersHeader/UsersHeader.tsx b/frontend/src/component/admin/users/UsersHeader/UsersHeader.tsx index 61f984d09e..45cbdbfd09 100644 --- a/frontend/src/component/admin/users/UsersHeader/UsersHeader.tsx +++ b/frontend/src/component/admin/users/UsersHeader/UsersHeader.tsx @@ -23,8 +23,12 @@ const StyledElement = styled(Box)(({ theme }) => ({ })); export const UsersHeader = () => { - const { isOss } = useUiConfig(); - const licensedUsersEnabled = !isOss(); + const { + isEnterprise, + uiConfig: { billing }, + } = useUiConfig(); + + const licensedUsersEnabled = isEnterprise() && billing !== 'pay-as-you-go'; return (