Skip to content

Commit

Permalink
[Infra UI] Fix redirection to Node Details page from Inventory UI (#1…
Browse files Browse the repository at this point in the history
…66821)

fixes #166818
fixes #164164

## Summary

This PR fixes the redirection to Node Details page from the Inventory UI



https://github.com/elastic/kibana/assets/2767137/38fcc79c-12e4-42ed-8230-712227815731

flaky test runner:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3202

### How to test
- Setup a local Kibana instance, pointing to a oblt cluster
- Navigate to `Infrastructure`
- Change the node type to `Kubernetes Pods`
- Click on a pod and from the context menu, click on `Kubernetes Pod
metrics`
  • Loading branch information
crespocarlos authored Sep 22, 2023
1 parent d52c5a1 commit 7eb34b2
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const NodeContextMenu: React.FC<Props & { theme?: EuiTheme }> = withTheme

const nodeDetailMenuItemLinkProps = useLinkProps({
...getNodeDetailUrl({
assetType: node.type,
assetType: nodeType,
assetId: node.id,
search: {
from: nodeDetailFrom,
Expand Down Expand Up @@ -171,7 +171,10 @@ export const NodeContextMenu: React.FC<Props & { theme?: EuiTheme }> = withTheme
)}
<SectionLinks>
<SectionLink data-test-subj="viewLogsContextMenuItem" {...nodeLogsMenuItem} />
<SectionLink {...nodeDetailMenuItem} />
<SectionLink
data-test-subj="viewAssetDetailsContextMenuItem"
{...nodeDetailMenuItem}
/>
<SectionLink data-test-subj="viewApmTracesContextMenuItem" {...apmTracesMenuItem} />
<SectionLink {...uptimeMenuItem} color={'primary'} />
</SectionLinks>
Expand Down
4 changes: 4 additions & 0 deletions x-pack/test/functional/apps/infra/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ export const DATES = {
kubernetesSectionStartDate: '2023-09-19T07:20:00.000Z',
kubernetesSectionEndDate: '2023-09-19T07:21:00.000Z',
},
pods: {
withData: '01/20/2022 5:10:00 PM',
},
stream: {
startWithData: '2018-10-17T19:42:22.000Z',
endWithData: '2018-10-17T19:57:21.000Z',
Expand All @@ -47,6 +50,7 @@ export const ML_JOB_IDS = [

export const HOSTS_LINK_LOCAL_STORAGE_KEY = 'inventoryUI:hostsLinkClicked';

export const INVENTORY_PATH = 'metrics/inventory';
export const NODE_DETAILS_PATH = 'detail/host';
export const HOSTS_VIEW_PATH = 'metrics/hosts';

Expand Down
56 changes: 50 additions & 6 deletions x-pack/test/functional/apps/infra/home_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import expect from '@kbn/expect';
import { KUBERNETES_TOUR_STORAGE_KEY } from '@kbn/infra-plugin/public/pages/metrics/inventory_view/components/kubernetes_tour';
import { FtrProviderContext } from '../../ftr_provider_context';
import { DATES } from './constants';
import { DATES, INVENTORY_PATH } from './constants';

const DATE_WITH_DATA = DATES.metricsAndLogs.hosts.withData;
const DATE_WITHOUT_DATA = DATES.metricsAndLogs.hosts.withoutData;
const DATE_WITH_POD_WITH_DATA = DATES.metricsAndLogs.pods.withData;

export default ({ getPageObjects, getService }: FtrProviderContext) => {
const esArchiver = getService('esArchiver');
Expand All @@ -21,8 +22,15 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');

// Failing: See https://github.com/elastic/kibana/issues/164164
describe.skip('Home page', function () {
const returnTo = async (path: string, timeout = 2000) =>
retry.waitForWithTimeout('returned to inventory', timeout, async () => {
await browser.goBack();
await pageObjects.header.waitUntilLoadingHasFinished();
const currentUrl = await browser.getCurrentUrl();
return !!currentUrl.match(path);
});

describe('Home page', function () {
this.tags('includeFirefox');
before(async () => {
await kibanaServer.savedObjects.cleanStandardList();
Expand Down Expand Up @@ -51,20 +59,19 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
);
await pageObjects.infraHome.waitForLoading();
await pageObjects.header.waitUntilLoadingHasFinished();

const documentTitle = await browser.getTitle();
expect(documentTitle).to.contain('Uh oh - Observability - Elastic');
});
});

describe('with metrics present', () => {
before(async () => {
await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs');
await esArchiver.load('x-pack/test/functional/es_archives/infra/8.0.0/pods_only');
await pageObjects.common.navigateToApp('infraOps');
await pageObjects.infraHome.waitForLoading();
});
after(async () => {
await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs');
await esArchiver.unload('x-pack/test/functional/es_archives/infra/8.0.0/pods_only');
await browser.removeLocalStorageItem(KUBERNETES_TOUR_STORAGE_KEY);
});

Expand Down Expand Up @@ -203,6 +210,43 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
it('toggles the inventory switcher', async () => {
await pageObjects.infraHome.toggleInventorySwitcher();
});

describe('Redirect to Node Details page', () => {
before(async () => {
await pageObjects.common.navigateToApp('infraOps');
await pageObjects.infraHome.waitForLoading();
});

it('Should redirect to Host Details page', async () => {
await pageObjects.infraHome.goToTime(DATE_WITH_DATA);
await pageObjects.infraHome.goToHost();
await pageObjects.infraHome.clickOnFirstNode();
await pageObjects.infraHome.clickOnNodeDetailsFlyoutOpenAsPage();

await retry.tryForTime(3 * 1000, async () => {
const documentTitle = await browser.getTitle();
expect(documentTitle).to.contain(
'demo-stack-redis-01 - Infrastructure - Observability - Elastic'
);
});

await returnTo(INVENTORY_PATH);
});

it('Should redirect to Node Details page', async () => {
await pageObjects.infraHome.goToTime(DATE_WITH_POD_WITH_DATA);
await pageObjects.infraHome.goToPods();
await pageObjects.infraHome.clickOnFirstNode();
await pageObjects.infraHome.clickOnGoToNodeDetails();

await retry.tryForTime(3 * 1000, async () => {
const documentTitle = await browser.getTitle();
expect(documentTitle).to.contain('pod-0 - Infrastructure - Observability - Elastic');
});

await returnTo(INVENTORY_PATH);
});
});
});

describe('alerts flyouts', () => {
Expand Down
26 changes: 23 additions & 3 deletions x-pack/test/functional/page_objects/infra_home_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ export function InfraHomePageProvider({ getService, getPageObjects }: FtrProvide
return Promise.all(promises);
},

async getFirstNode() {
const nodes = await testSubjects.findAll('nodeContainer');
return nodes[0];
},

async clickOnFirstNode() {
const firstNode = await this.getFirstNode();
firstNode.click();
},

async clickOnGoToNodeDetails() {
await retry.try(async () => {
await testSubjects.click('viewAssetDetailsContextMenuItem');
});
},

async clickOnNodeDetailsFlyoutOpenAsPage() {
await retry.try(async () => {
await testSubjects.click('infraNodeContextPopoverOpenAsPageButton');
});
},

async sortNodesBy(sort: string) {
await testSubjects.click('waffleSortByDropdown');
if (sort === 'value') {
Expand Down Expand Up @@ -175,9 +197,7 @@ export function InfraHomePageProvider({ getService, getPageObjects }: FtrProvide
await testSubjects.click('openInventorySwitcher');
await testSubjects.find('goToHost');
await testSubjects.click('openInventorySwitcher');
return retry.tryForTime(2 * 1000, async () => {
return testSubjects.missingOrFail('goToHost');
});
await testSubjects.missingOrFail('goToHost', { timeout: 10 * 1000 });
},

async goToHost() {
Expand Down

0 comments on commit 7eb34b2

Please sign in to comment.