Skip to content

Commit

Permalink
Merge pull request elastic#31 from TattdCodeMonkey/rnorris/serverless…
Browse files Browse the repository at this point in the history
…/poc/navigation
  • Loading branch information
clintandrewhall authored Mar 9, 2023
2 parents da5e079 + 57963b3 commit 32be212
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const mockKibanaValues = {
guidedOnboarding: {},
history: mockHistory,
isCloud: false,
isSidebarEnabled: true,
navigateToUrl: jest.fn(),
productAccess: {
hasAppSearchAccess: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('renderApp', () => {
licensing: licensingMock.createStart(),
security: securityMock.createStart(),
},
isSidebarEnabled: true,
} as any;
const pluginData = {
config: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('useEnterpriseSearchContentNav', () => {
mockKibanaValues.uiSettings.get.mockReturnValue(false);

const esNav = useEnterpriseSearchNav();
const searchNav = esNav.find((item) => item.id === 'search');
const searchNav = esNav?.find((item) => item.id === 'search');
expect(searchNav).not.toBeUndefined();
expect(searchNav).toEqual({
id: 'search',
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('useEnterpriseSearchContentNav', () => {
setMockValues({ productAccess: workplaceSearchProductAccess });

const esNav = useEnterpriseSearchNav();
const searchNav = esNav.find((item) => item.id === 'search');
const searchNav = esNav?.find((item) => item.id === 'search');
expect(searchNav).not.toBeUndefined();
expect(searchNav).toEqual({
id: 'search',
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('useEnterpriseSearchContentNav', () => {
setMockValues({ productAccess: appSearchProductAccess });

const esNav = useEnterpriseSearchNav();
const searchNav = esNav.find((item) => item.id === 'search');
const searchNav = esNav?.find((item) => item.id === 'search');
expect(searchNav).not.toBeUndefined();
expect(searchNav).toEqual({
id: 'search',
Expand Down Expand Up @@ -204,7 +204,7 @@ describe('useEnterpriseSearchContentNav', () => {
setMockValues({ productAccess: fullProductAccess });

const esNav = useEnterpriseSearchNav();
expect(esNav.find((item) => item.id === 'enginesSearch')).toBeUndefined();
expect(esNav?.find((item) => item.id === 'enginesSearch')).toBeUndefined();
});
});

Expand Down Expand Up @@ -304,7 +304,7 @@ describe('useEnterpriseSearchContentNav Engines feature flag', () => {
setMockValues({ productAccess: fullProductAccess });

const esNav = useEnterpriseSearchNav();
expect(esNav.find((item) => item.id === 'standaloneExperiences')).toBeUndefined();
expect(esNav?.find((item) => item.id === 'standaloneExperiences')).toBeUndefined();
});
it('excludes App Search when the user has no access to it', () => {
const fullProductAccess: ProductAccess = {
Expand All @@ -315,7 +315,7 @@ describe('useEnterpriseSearchContentNav Engines feature flag', () => {
setMockValues({ productAccess: fullProductAccess });

const esNav = useEnterpriseSearchNav();
const standAloneNav = esNav.find((item) => item.id === 'standaloneExperiences');
const standAloneNav = esNav?.find((item) => item.id === 'standaloneExperiences');
expect(standAloneNav).not.toBeUndefined();
expect(standAloneNav).toEqual({
id: 'standaloneExperiences',
Expand All @@ -338,7 +338,7 @@ describe('useEnterpriseSearchContentNav Engines feature flag', () => {
setMockValues({ productAccess: fullProductAccess });

const esNav = useEnterpriseSearchNav();
const standAloneNav = esNav.find((item) => item.id === 'standaloneExperiences');
const standAloneNav = esNav?.find((item) => item.id === 'standaloneExperiences');
expect(standAloneNav).not.toBeUndefined();
expect(standAloneNav).toEqual({
id: 'standaloneExperiences',
Expand Down Expand Up @@ -444,14 +444,14 @@ describe('useEnterpriseSearchEngineNav', () => {
it('returns selected engine sub nav items', () => {
const engineName = 'my-test-engine';
const navItems = useEnterpriseSearchEngineNav(engineName);
expect(navItems.map((ni) => ni.name)).toEqual([
expect(navItems?.map((ni) => ni.name)).toEqual([
'Overview',
'Content',
'Search',
'Behavioral Analytics',
'Standalone Experiences',
]);
const searchItem = navItems.find((ni) => ni.id === 'enginesSearch');
const searchItem = navItems?.find((ni) => ni.id === 'enginesSearch');
expect(searchItem).not.toBeUndefined();
expect(searchItem!.items).not.toBeUndefined();
// @ts-ignore
Expand Down Expand Up @@ -501,14 +501,14 @@ describe('useEnterpriseSearchEngineNav', () => {
it('returns selected engine without tabs when isEmpty', () => {
const engineName = 'my-test-engine';
const navItems = useEnterpriseSearchEngineNav(engineName, true);
expect(navItems.map((ni) => ni.name)).toEqual([
expect(navItems?.map((ni) => ni.name)).toEqual([
'Overview',
'Content',
'Search',
'Behavioral Analytics',
'Standalone Experiences',
]);
const searchItem = navItems.find((ni) => ni.id === 'enginesSearch');
const searchItem = navItems?.find((ni) => ni.id === 'enginesSearch');
expect(searchItem).not.toBeUndefined();
expect(searchItem!.items).not.toBeUndefined();
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { rolesManagementApp } from './roles';
import { usersManagementApp } from './users';

const mockSection = createManagementSectionMock();
const mockSetIsSidebarEnabled = (enabled: boolean) => {};

describe('ManagementService', () => {
describe('setup()', () => {
Expand All @@ -41,6 +42,7 @@ describe('ManagementService', () => {
} as DefinedSections,
},
locator: {} as any,
setIsSidebarEnabled: mockSetIsSidebarEnabled,
};

const service = new ManagementService();
Expand Down Expand Up @@ -103,6 +105,7 @@ describe('ManagementService', () => {
} as DefinedSections,
},
locator: {} as any,
setIsSidebarEnabled: mockSetIsSidebarEnabled,
};

service.setup({
Expand Down

0 comments on commit 32be212

Please sign in to comment.