Skip to content

Commit

Permalink
change to navigateToUrl in both places
Browse files Browse the repository at this point in the history
  • Loading branch information
saarikabhasi committed Oct 23, 2024
1 parent 3de0c5f commit b71d3d2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*/
import { EuiSearchBoxProps } from '@elastic/eui/src/components/search_bar/search_box';

import { applicationServiceMock } from '@kbn/core/public/mocks';
jest.mock('@elastic/eui/lib/components/search_bar/search_box', () => {
return {
EuiSearchBox: (props: EuiSearchBoxProps) => (
Expand Down Expand Up @@ -136,15 +137,21 @@ describe('<IndexManagementHome />', () => {
createNonDataStreamIndex(indexName)
);

const application = applicationServiceMock.createStartContract();
testBed = await setup(httpSetup, {
history: createMemoryHistory(),
core: {
application,
},
});
const { component, actions } = testBed;

component.update();

await actions.clickIndexNameAt(0);
expect(testBed.actions.findIndexDetailsPageTitle()).toContain('testIndex');
expect(application.navigateToUrl).toHaveBeenCalledWith(
'/app/management/data/index_management/indices/index_details?indexName=testIndex&includeHiddenIndices=true'
);
});

it('index page works with % character in index name', async () => {
Expand All @@ -155,13 +162,21 @@ describe('<IndexManagementHome />', () => {
createNonDataStreamIndex(indexName)
);

testBed = await setup(httpSetup);
const application = applicationServiceMock.createStartContract();
testBed = await setup(httpSetup, {
history: createMemoryHistory(),
core: {
application,
},
});
const { component, actions } = testBed;

component.update();

await actions.clickIndexNameAt(0);
expect(testBed.actions.findIndexDetailsPageTitle()).toContain(indexName);
expect(application.navigateToUrl).toHaveBeenCalledWith(
'/app/management/data/index_management/indices/index_details?indexName=test%25&includeHiddenIndices=true'
);
});

describe('empty list component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ describe('routing', () => {
indexDetailsPageRoute: null,
} as ExtensionsService;
navigateToIndexDetailsPage('testIndex', '', extensionService, application, http, history);
expect(history.push).toHaveBeenCalledTimes(1);
expect(application.navigateToUrl).not.toHaveBeenCalled();
expect(application.navigateToUrl).toHaveBeenCalled();
});

it('renders route from extensionService indexDetailsPageRoute with tab id', () => {
Expand All @@ -59,7 +58,7 @@ describe('routing', () => {
history,
IndexDetailsSection.Settings
);
expect(application.navigateToUrl).toHaveBeenCalledTimes(1);
expect(application.navigateToUrl).toHaveBeenCalled();
expect(application.navigateToUrl).toHaveBeenCalledWith('test_url/settings');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ export const navigateToIndexDetailsPage = (
tabId?: IndexDetailsSection
) => {
if (!extensionsService.indexDetailsPageRoute) {
history.push(getIndexDetailsLink(indexName, indicesListURLParams, tabId));
application.navigateToUrl(http.basePath.prepend(
`/app/management/data/index_management${getIndexDetailsLink(
indexName,
indicesListURLParams,
tabId
)}`
));
} else {
const route = extensionsService.indexDetailsPageRoute.renderRoute(indexName, tabId);
application.navigateToUrl(http.basePath.prepend(route));
Expand Down

0 comments on commit b71d3d2

Please sign in to comment.