Skip to content

Commit

Permalink
[ObsUX] Enable Hosts advanced setting on serverless (#170035)
Browse files Browse the repository at this point in the history
Closes #169198

## Summary

* Adds Hosts advanced setting to the observability settings allowlist
* Adds tests for Hosts sidenav item visibility


https://github.com/elastic/kibana/assets/793851/3c9252c8-a4cb-4da8-aa60-23a8aeb60d4c

# How to test

* Run locally in serverless mode
* Make sure "Observability Hosts view" toggle is visible on the Advanced
Settings screen
* Toggle the setting on and off, make sure sidenav properly reacts to
the changes
* Go to Infra settings screen
* Toggle the same setting on and off, and also make sure sidenav
properly reacts to the changes
  • Loading branch information
mykolaharmash authored Oct 30, 2023
1 parent b9f347b commit e804ef2
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ export const OBSERVABILITY_PROJECT_SETTINGS = [
settings.OBSERVABILITY_APM_TRACE_EXPLORER_TAB_ID,
settings.OBSERVABILITY_ENABLE_AWS_LAMBDA_METRICS_ID,
settings.OBSERVABILITY_APM_ENABLE_CRITICAL_PATH_ID,
settings.OBSERVABILITY_ENABLE_INFRASTRUCTURE_HOSTS_VIEW_ID,
];
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ export function SvlCommonNavigationProvider(ctx: FtrProviderContext) {
expect(await getByVisibleText('~nav-item', by.text)).not.be(null);
}
},
async expectLinkMissing(
by: { deepLinkId: AppDeepLinkId } | { navId: string } | { text: string }
) {
if ('deepLinkId' in by) {
await testSubjects.missingOrFail(`~nav-item-deepLinkId-${by.deepLinkId}`);
} else if ('navId' in by) {
await testSubjects.missingOrFail(`~nav-item-id-${by.navId}`);
} else {
expect(await getByVisibleText('~nav-item', by.text)).be(null);
}
},
async expectLinkActive(
by: { deepLinkId: AppDeepLinkId } | { navId: string } | { text: string }
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FtrProviderContext } from '../../../ftr_provider_context';
export default function ({ loadTestFile }: FtrProviderContext) {
describe('Observability Infra', function () {
loadTestFile(require.resolve('./header_menu'));
loadTestFile(require.resolve('./navigation'));
loadTestFile(require.resolve('./node_details'));
loadTestFile(require.resolve('./hosts_page'));
loadTestFile(require.resolve('./infra'));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { enableInfrastructureHostsView } from '@kbn/observability-plugin/common';
import { FtrProviderContext } from '../../../ftr_provider_context';

export default ({ getPageObjects, getService }: FtrProviderContext) => {
const kibanaServer = getService('kibanaServer');
const svlObltNavigation = getService('svlObltNavigation');
const browser = getService('browser');
const pageObjects = getPageObjects(['svlCommonPage', 'svlCommonNavigation', 'header']);

const setHostsSetting = async (value: boolean) => {
await kibanaServer.uiSettings.update({ [enableInfrastructureHostsView]: value });
await browser.refresh();
await pageObjects.svlCommonNavigation.expectExists();
};

const openInfraSection = async () => {
await pageObjects.svlCommonNavigation.sidenav.openSection('observability_project_nav.metrics');
};

describe('Infra Side Navigation', () => {
before(async () => {
await pageObjects.svlCommonPage.login();
await svlObltNavigation.navigateToLandingPage();
});

after(async () => {
await pageObjects.svlCommonPage.forceLogout();
});

describe('when Hosts settings is on', () => {
before(async () => {
await setHostsSetting(true);
await openInfraSection();
});

it("shows the 'Hosts' nav item", async () => {
await pageObjects.svlCommonNavigation.sidenav.expectLinkExists({
deepLinkId: 'metrics:hosts',
});
});
});

describe('when Hosts settings is off', () => {
before(async () => {
await setHostsSetting(false);
await openInfraSection();
});

it("hides the 'Hosts' nav item", async () => {
await pageObjects.svlCommonNavigation.sidenav.expectLinkMissing({
deepLinkId: 'metrics:hosts',
});
});
});
});
};

0 comments on commit e804ef2

Please sign in to comment.