test(frontend-app-api): cover features deduplication
Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
committed by
Patrik Oldsberg
parent
ba0a665840
commit
f2cb14651e
@@ -23,7 +23,7 @@ import {
|
||||
createThemeExtension,
|
||||
} from '@backstage/frontend-plugin-api';
|
||||
import { createApp, createInstances } from './createApp';
|
||||
import { screen } from '@testing-library/react';
|
||||
import { screen, waitFor } from '@testing-library/react';
|
||||
import { MockConfigApi, renderWithEffects } from '@backstage/test-utils';
|
||||
import React from 'react';
|
||||
|
||||
@@ -244,4 +244,42 @@ describe('createApp', () => {
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it('should deduplicate features keeping the last received one', async () => {
|
||||
const duplicatedFeatureId = 'test';
|
||||
const app = createApp({
|
||||
configLoader: async () => new MockConfigApi({}),
|
||||
features: [
|
||||
createPlugin({
|
||||
id: duplicatedFeatureId,
|
||||
extensions: [
|
||||
createPageExtension({
|
||||
id: 'test.page.first',
|
||||
defaultPath: '/',
|
||||
loader: async () => <div>First Page</div>,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
createPlugin({
|
||||
id: duplicatedFeatureId,
|
||||
extensions: [
|
||||
createPageExtension({
|
||||
id: 'test.page.last',
|
||||
defaultPath: '/',
|
||||
loader: async () => <div>Last Page</div>,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
await renderWithEffects(app.createRoot());
|
||||
|
||||
await waitFor(() =>
|
||||
expect(screen.queryByText('First Page')).not.toBeInTheDocument(),
|
||||
);
|
||||
await waitFor(() =>
|
||||
expect(screen.getByText('Last Page')).toBeInTheDocument(),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user