1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-28 17:55:15 +02:00
unleash.unleash/frontend/src/component/banners/OutdatedSdksBanner/OutdatedSdksBanner.test.tsx
Jaanus Sellin 17e340ab40
feat: project level outdated sdks, project level banner (#7083)
At first, I was creating a new component, Project Banner, which was 90%
of the old banner and 10% new code, but it did not feel right. The
current banner is actually smart enough to be used in any container. So
now, I have moved the outdated SDK banner to the project level.

I like the simplicity of the change.


![image](https://github.com/Unleash/unleash/assets/964450/e57c1ace-e8f9-4866-a063-6f9ae561c6c0)
2024-05-20 14:15:39 +03:00

48 lines
1.4 KiB
TypeScript

import { screen, waitFor } from '@testing-library/react';
import { render } from 'utils/testRenderer';
import { testServerRoute, testServerSetup } from 'utils/testServer';
import type { OutdatedSdksSchema } from 'openapi';
import { OutdatedSdksBanner } from './OutdatedSdksBanner';
const server = testServerSetup();
const setupApi = (outdatedSdks: OutdatedSdksSchema) => {
testServerRoute(
server,
'/api/admin/projects/default/sdks/outdated',
outdatedSdks,
);
testServerRoute(server, '/api/admin/ui-config', {
flags: {
outdatedSdksBanner: true,
},
});
};
test('Show outdated SDKs and apps using them', async () => {
setupApi({
sdks: [
{
sdkVersion: 'unleash-node-client:3.2.1',
applications: ['application1', 'application2'],
},
],
});
render(<OutdatedSdksBanner project={'default'} />);
const link = await screen.findByText('Please update those versions');
link.click();
await screen.findByText('Outdated SDKs');
await screen.findByText('unleash-node-client:3.2.1');
const application = await screen.findByText('application1');
await screen.findByText('application2');
application.click(); // clicking on an application link should close the modal
await waitFor(() => {
expect(screen.queryByText('Outdated SDKs')).not.toBeInTheDocument();
});
});