mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-28 17:55:15 +02:00
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. 
48 lines
1.4 KiB
TypeScript
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();
|
|
});
|
|
});
|