diff --git a/x-pack/plugins/apm/public/components/app/Main/__test__/Breadcrumbs.test.js b/x-pack/plugins/apm/public/components/app/Main/__test__/UpdateBreadcrumbs.test.js similarity index 76% rename from x-pack/plugins/apm/public/components/app/Main/__test__/Breadcrumbs.test.js rename to x-pack/plugins/apm/public/components/app/Main/__test__/UpdateBreadcrumbs.test.js index be57500928f4b9a..28337f771255d4b 100644 --- a/x-pack/plugins/apm/public/components/app/Main/__test__/Breadcrumbs.test.js +++ b/x-pack/plugins/apm/public/components/app/Main/__test__/UpdateBreadcrumbs.test.js @@ -7,15 +7,14 @@ import React from 'react'; import { mount } from 'enzyme'; import { MemoryRouter } from 'react-router-dom'; - -import Breadcrumbs from '../Breadcrumbs'; -import { toJson } from '../../../../utils/testHelpers'; +import { UpdateBreadcrumbs } from '../UpdateBreadcrumbs'; +import chrome from 'ui/chrome'; jest.mock( 'ui/chrome', () => ({ breadcrumbs: { - set: () => {} + set: jest.fn() }, getBasePath: () => `/some/base/path`, getUiSettingsClient: () => { @@ -37,17 +36,20 @@ jest.mock( ); function expectBreadcrumbToMatchSnapshot(route) { - const wrapper = mount( + mount( - + ); - expect( - toJson(wrapper.find('.kuiLocalBreadcrumb').children()) - ).toMatchSnapshot(); + expect(chrome.breadcrumbs.set).toHaveBeenCalledTimes(1); + expect(chrome.breadcrumbs.set.mock.calls[0][0]).toMatchSnapshot(); } describe('Breadcrumbs', () => { + beforeEach(() => { + chrome.breadcrumbs.set.mockReset(); + }); + it('Homepage', () => { expectBreadcrumbToMatchSnapshot('/'); }); @@ -77,13 +79,4 @@ describe('Breadcrumbs', () => { '/:serviceName/transactions/request/my-transaction-name' ); }); - - it('does not render breadcrumbs when showPluginBreadcrumbs = false', () => { - const wrapper = mount( - - - - ); - expect(wrapper.find('.kuiLocalBreadcrumbs').exists()).toEqual(false); - }); }); diff --git a/x-pack/plugins/apm/public/components/app/Main/__test__/__snapshots__/Breadcrumbs.test.js.snap b/x-pack/plugins/apm/public/components/app/Main/__test__/__snapshots__/Breadcrumbs.test.js.snap deleted file mode 100644 index 73aded84664bbcb..000000000000000 --- a/x-pack/plugins/apm/public/components/app/Main/__test__/__snapshots__/Breadcrumbs.test.js.snap +++ /dev/null @@ -1,120 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Breadcrumbs /:serviceName 1`] = ` -Array [ - - APM - , - - opbeans-node - , -] -`; - -exports[`Breadcrumbs /:serviceName/errors 1`] = ` -Array [ - - APM - , - - opbeans-node - , - - Errors - , -] -`; - -exports[`Breadcrumbs /:serviceName/errors/:groupId 1`] = ` -Array [ - - APM - , - - opbeans-node - , - - Errors - , - - myGroupId - , -] -`; - -exports[`Breadcrumbs /:serviceName/transactions 1`] = ` -Array [ - - APM - , - - opbeans-node - , - - Transactions - , -] -`; - -exports[`Breadcrumbs /:serviceName/transactions/:transactionType 1`] = ` -Array [ - - APM - , - - opbeans-node - , - - Transactions - , -] -`; - -exports[`Breadcrumbs /:serviceName/transactions/:transactionType/:transactionName 1`] = ` -Array [ - - APM - , - - :serviceName - , - - Transactions - , - - my-transaction-name - , -] -`; - -exports[`Breadcrumbs Homepage 1`] = ` - - APM - -`; diff --git a/x-pack/plugins/apm/public/components/app/Main/__test__/__snapshots__/UpdateBreadcrumbs.test.js.snap b/x-pack/plugins/apm/public/components/app/Main/__test__/__snapshots__/UpdateBreadcrumbs.test.js.snap new file mode 100644 index 000000000000000..681c20d1424df91 --- /dev/null +++ b/x-pack/plugins/apm/public/components/app/Main/__test__/__snapshots__/UpdateBreadcrumbs.test.js.snap @@ -0,0 +1,207 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Breadcrumbs /:serviceName 1`] = ` +Array [ + Object { + "href": "#/?_g=myG&kuery=myKuery", + "text": "APM", + }, + Object { + "href": "#/opbeans-node?_g=myG&kuery=myKuery", + "text": , + }, +] +`; + +exports[`Breadcrumbs /:serviceName/errors 1`] = ` +Array [ + Object { + "href": "#/?_g=myG&kuery=myKuery", + "text": "APM", + }, + Object { + "href": "#/opbeans-node?_g=myG&kuery=myKuery", + "text": , + }, + Object { + "href": "#/opbeans-node/errors?_g=myG&kuery=myKuery", + "text": "Errors", + }, +] +`; + +exports[`Breadcrumbs /:serviceName/errors/:groupId 1`] = ` +Array [ + Object { + "href": "#/?_g=myG&kuery=myKuery", + "text": "APM", + }, + Object { + "href": "#/opbeans-node?_g=myG&kuery=myKuery", + "text": , + }, + Object { + "href": "#/opbeans-node/errors?_g=myG&kuery=myKuery", + "text": "Errors", + }, + Object { + "href": "#/opbeans-node/errors/myGroupId?_g=myG&kuery=myKuery", + "text": , + }, +] +`; + +exports[`Breadcrumbs /:serviceName/transactions 1`] = ` +Array [ + Object { + "href": "#/?_g=myG&kuery=myKuery", + "text": "APM", + }, + Object { + "href": "#/opbeans-node?_g=myG&kuery=myKuery", + "text": , + }, + Object { + "href": "#/opbeans-node/transactions?_g=myG&kuery=myKuery", + "text": "Transactions", + }, +] +`; + +exports[`Breadcrumbs /:serviceName/transactions/:transactionType 1`] = ` +Array [ + Object { + "href": "#/?_g=myG&kuery=myKuery", + "text": "APM", + }, + Object { + "href": "#/opbeans-node?_g=myG&kuery=myKuery", + "text": , + }, + Object { + "href": "#/opbeans-node/transactions?_g=myG&kuery=myKuery", + "text": "Transactions", + }, +] +`; + +exports[`Breadcrumbs /:serviceName/transactions/:transactionType/:transactionName 1`] = ` +Array [ + Object { + "href": "#/?_g=myG&kuery=myKuery", + "text": "APM", + }, + Object { + "href": "#/:serviceName?_g=myG&kuery=myKuery", + "text": , + }, + Object { + "href": "#/:serviceName/transactions?_g=myG&kuery=myKuery", + "text": "Transactions", + }, + Object { + "href": "#/:serviceName/transactions/request/my-transaction-name?_g=myG&kuery=myKuery", + "text": , + }, +] +`; + +exports[`Breadcrumbs Homepage 1`] = ` +Array [ + Object { + "href": "#/?_g=myG&kuery=myKuery", + "text": "APM", + }, +] +`;