mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-31 00:16:47 +01:00
refactor: application overview dom improvements and tests (#6325)
This commit is contained in:
parent
0de0313563
commit
42f6843029
@ -0,0 +1,72 @@
|
|||||||
|
import { screen } from '@testing-library/react';
|
||||||
|
import { render } from 'utils/testRenderer';
|
||||||
|
import { testServerRoute, testServerSetup } from 'utils/testServer';
|
||||||
|
import { Route, Routes } from 'react-router-dom';
|
||||||
|
import { ApplicationOverviewSchema } from '../../openapi';
|
||||||
|
import ApplicationOverview from './ApplicationOverview';
|
||||||
|
|
||||||
|
const server = testServerSetup();
|
||||||
|
|
||||||
|
const setupApi = (application: ApplicationOverviewSchema) => {
|
||||||
|
testServerRoute(
|
||||||
|
server,
|
||||||
|
'/api/admin/metrics/applications/my-app/overview',
|
||||||
|
application,
|
||||||
|
);
|
||||||
|
testServerRoute(server, '/api/admin/ui-config', {});
|
||||||
|
};
|
||||||
|
|
||||||
|
test('Display application overview with environments', async () => {
|
||||||
|
setupApi({
|
||||||
|
environments: [
|
||||||
|
{
|
||||||
|
name: 'development',
|
||||||
|
instanceCount: 999,
|
||||||
|
lastSeen: '2024-02-22T20:20:24.740',
|
||||||
|
sdks: ['unleash-client-node:5.5.0-beta.0'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
featureCount: 1,
|
||||||
|
projects: ['default'],
|
||||||
|
});
|
||||||
|
render(
|
||||||
|
<Routes>
|
||||||
|
<Route
|
||||||
|
path={'/applications/:name'}
|
||||||
|
element={<ApplicationOverview />}
|
||||||
|
/>
|
||||||
|
</Routes>,
|
||||||
|
{
|
||||||
|
route: '/applications/my-app',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await screen.findByText('my-app');
|
||||||
|
await screen.findByText('Everything looks good!');
|
||||||
|
await screen.findByText('development environment');
|
||||||
|
await screen.findByText('999');
|
||||||
|
await screen.findByText('unleash-client-node:5.5.0-beta.0');
|
||||||
|
await screen.findByText('2024-02-22T20:20:24.740');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Display application overview without environments', async () => {
|
||||||
|
setupApi({
|
||||||
|
environments: [],
|
||||||
|
featureCount: 0,
|
||||||
|
projects: ['default'],
|
||||||
|
});
|
||||||
|
render(
|
||||||
|
<Routes>
|
||||||
|
<Route
|
||||||
|
path={'/applications/:name'}
|
||||||
|
element={<ApplicationOverview />}
|
||||||
|
/>
|
||||||
|
</Routes>,
|
||||||
|
{
|
||||||
|
route: '/applications/my-app',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await screen.findByText('my-app');
|
||||||
|
await screen.findByText('No data available.');
|
||||||
|
});
|
@ -202,7 +202,10 @@ export const ApplicationOverview = () => {
|
|||||||
|
|
||||||
<StyledEnvironmentsContainer ref={elementRef}>
|
<StyledEnvironmentsContainer ref={elementRef}>
|
||||||
{data.environments.map((environment) => (
|
{data.environments.map((environment) => (
|
||||||
<ArcherElement id={environment.name}>
|
<ArcherElement
|
||||||
|
id={environment.name}
|
||||||
|
key={environment.name}
|
||||||
|
>
|
||||||
<StyledEnvironmentBox
|
<StyledEnvironmentBox
|
||||||
mode={mode}
|
mode={mode}
|
||||||
key={environment.name}
|
key={environment.name}
|
||||||
@ -212,20 +215,27 @@ export const ApplicationOverview = () => {
|
|||||||
</EnvironmentHeader>
|
</EnvironmentHeader>
|
||||||
|
|
||||||
<StyledTable>
|
<StyledTable>
|
||||||
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<StyledCell>
|
<StyledCell>
|
||||||
Instances:
|
Instances:
|
||||||
</StyledCell>
|
</StyledCell>
|
||||||
<StyledCell>
|
<StyledCell>
|
||||||
{environment.instanceCount}
|
{
|
||||||
|
environment.instanceCount
|
||||||
|
}
|
||||||
</StyledCell>
|
</StyledCell>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<StyledCell>SDK:</StyledCell>
|
<StyledCell>
|
||||||
|
SDK:
|
||||||
|
</StyledCell>
|
||||||
<StyledCell>
|
<StyledCell>
|
||||||
{environment.sdks.map(
|
{environment.sdks.map(
|
||||||
(sdk) => (
|
(sdk) => (
|
||||||
<div>{sdk}</div>
|
<div key={sdk}>
|
||||||
|
{sdk}
|
||||||
|
</div>
|
||||||
),
|
),
|
||||||
)}
|
)}
|
||||||
</StyledCell>
|
</StyledCell>
|
||||||
@ -238,6 +248,7 @@ export const ApplicationOverview = () => {
|
|||||||
{environment.lastSeen}
|
{environment.lastSeen}
|
||||||
</StyledCell>
|
</StyledCell>
|
||||||
</tr>
|
</tr>
|
||||||
|
</tbody>
|
||||||
</StyledTable>
|
</StyledTable>
|
||||||
</StyledEnvironmentBox>
|
</StyledEnvironmentBox>
|
||||||
</ArcherElement>
|
</ArcherElement>
|
||||||
|
Loading…
Reference in New Issue
Block a user