From 748638caee5e4b9252740e0d63663954b640cb1e Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Wed, 15 May 2024 14:33:49 -0400 Subject: [PATCH] Fix test and add test verifying behavior Signed-off-by: Derek Ho --- .../__snapshots__/app-router.test.tsx.snap | 94 ------------------- .../configuration/test/app-router.test.tsx | 75 ++++++++++++--- 2 files changed, 64 insertions(+), 105 deletions(-) diff --git a/public/apps/configuration/test/__snapshots__/app-router.test.tsx.snap b/public/apps/configuration/test/__snapshots__/app-router.test.tsx.snap index 4696ecc12..9a20d563f 100644 --- a/public/apps/configuration/test/__snapshots__/app-router.test.tsx.snap +++ b/public/apps/configuration/test/__snapshots__/app-router.test.tsx.snap @@ -57,10 +57,6 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab "href": "/auditLogging", "name": "Audit logs", }, - Object { - "href": "/tenantsConfigureTab", - "name": "", - }, ] } /> @@ -107,10 +103,6 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab "href": "/auditLogging", "name": "Audit logs", }, - Object { - "href": "/tenantsConfigureTab", - "name": "", - }, ] } /> @@ -157,10 +149,6 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab "href": "/auditLogging", "name": "Audit logs", }, - Object { - "href": "/tenantsConfigureTab", - "name": "", - }, ] } /> @@ -207,10 +195,6 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab "href": "/auditLogging", "name": "Audit logs", }, - Object { - "href": "/tenantsConfigureTab", - "name": "", - }, ] } /> @@ -257,10 +241,6 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab "href": "/auditLogging", "name": "Audit logs", }, - Object { - "href": "/tenantsConfigureTab", - "name": "", - }, ] } /> @@ -307,10 +287,6 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab "href": "/auditLogging", "name": "Audit logs", }, - Object { - "href": "/tenantsConfigureTab", - "name": "", - }, ] } /> @@ -357,10 +333,6 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab "href": "/auditLogging", "name": "Audit logs", }, - Object { - "href": "/tenantsConfigureTab", - "name": "", - }, ] } /> @@ -407,60 +379,6 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab "href": "/auditLogging", "name": "Audit logs", }, - Object { - "href": "/tenantsConfigureTab", - "name": "", - }, - ] - } - /> - - - - - @@ -507,10 +425,6 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab "href": "/auditLogging", "name": "Audit logs", }, - Object { - "href": "/tenantsConfigureTab", - "name": "", - }, ] } /> @@ -557,10 +471,6 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab "href": "/auditLogging", "name": "Audit logs", }, - Object { - "href": "/tenantsConfigureTab", - "name": "", - }, ] } /> @@ -620,10 +530,6 @@ exports[`SecurityPluginTopNavMenu renders DataSourceMenu when dataSource is enab path="/tenants" render={[Function]} /> - ({ getDataSourceFromUrl: jest.fn(), @@ -33,23 +34,28 @@ describe('SecurityPluginTopNavMenu', () => { }, }; - const dataSourceMenuMock = jest.fn(() =>
Mock DataSourceMenu
); + const securityPluginConfigMock = { + multitenancy: { + enabled: true, + }, + ui: {}, + }; - const dataSourceManagementMock = { - ui: { - DataSourceMenu: dataSourceMenuMock, + const securityPluginConfigMockMultitenancyDisabled = { + multitenancy: { + enabled: false, }, + ui: {}, }; it('renders DataSourceMenu when dataSource is enabled', () => { - const securityPluginStartDepsMock = { - dataSource: { - dataSourceEnabled: true, - }, - }; - const wrapper = shallow( - + ); expect(wrapper).toMatchSnapshot(); @@ -67,6 +73,7 @@ describe('SecurityPluginTopNavMenu', () => { coreStart={coreStartMock} depsStart={securityPluginStartDepsMock} params={{ appBasePath: '' }} + config={securityPluginConfigMock} /> ); @@ -85,9 +92,55 @@ describe('SecurityPluginTopNavMenu', () => { coreStart={coreStartMock} depsStart={securityPluginStartDepsMock} params={{ appBasePath: '' }} + config={securityPluginConfigMock} /> ); expect(getDataSourceFromUrl).toHaveBeenCalled(); }); + + it('Tenant tab does not show up when ', () => { + const securityPluginStartDepsMock = { + dataSource: { + dataSourceEnabled: true, + }, + }; + + shallow( + + ); + + expect(getDataSourceFromUrl).toHaveBeenCalled(); + }); + + it('renders Tenant tab when multitenancy enabled', () => { + const { container } = render( + + ); + + expect(container.querySelector('[title="Tenants"]')).not.toBeNull(); + }); + + it('does not render Tenant tab when multitenancy disabled', () => { + const { container } = render( + + ); + + expect(container.querySelector('[title="Tenants"]')).toBeNull(); + }); });