1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-26 13:48:33 +02:00

feat: show seats used only for full enterprise customers (#9618)

This commit is contained in:
Jaanus Sellin 2025-03-26 14:53:51 +02:00 committed by GitHub
parent 832b651f5b
commit 18d1a6c1bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 77 additions and 2 deletions

View File

@ -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(<UsersHeader />);
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(<UsersHeader />);
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(<UsersHeader />);
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(<UsersHeader />);
expect(
screen.queryByText('Seats used over the last 30 days'),
).not.toBeInTheDocument();
});
});

View File

@ -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 (
<StyledContainer>