From f4184540be6c606f74ff5ccf973b0e0da69e2c74 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Mon, 3 Oct 2022 15:00:40 +0200 Subject: [PATCH 001/152] [Observability] Fix flaky test (#142210) --- .../series_editor/columns/series_actions.tsx | 1 + .../apps/observability/exploratory_view.ts | 28 +++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/series_actions.tsx b/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/series_actions.tsx index 129fdf1cf25e3..aab83cc511d9c 100644 --- a/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/series_actions.tsx +++ b/x-pack/plugins/observability/public/components/shared/exploratory_view/series_editor/columns/series_actions.tsx @@ -89,6 +89,7 @@ export function SeriesActions({ seriesId, series, seriesConfig, onEditClick }: P aria-label={EDIT_SERIES_LABEL} size="s" onClick={onEditClick} + data-test-subj={`editSeries${seriesId}`} /> diff --git a/x-pack/test/observability_functional/apps/observability/exploratory_view.ts b/x-pack/test/observability_functional/apps/observability/exploratory_view.ts index 8f27f20ce30e6..b3adaa556dac3 100644 --- a/x-pack/test/observability_functional/apps/observability/exploratory_view.ts +++ b/x-pack/test/observability_functional/apps/observability/exploratory_view.ts @@ -19,8 +19,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const rangeFrom = '2021-01-17T16%3A46%3A15.338Z'; const rangeTo = '2021-01-19T17%3A01%3A32.309Z'; - // Failing: See https://github.com/elastic/kibana/issues/106934 - describe.skip('ExploratoryView', () => { + describe('ExploratoryView', () => { before(async () => { await esArchiver.loadIfNeeded( Path.join('x-pack/test/apm_api_integration/common/fixtures/es_archiver', '8.0.0') @@ -33,11 +32,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await esArchiver.loadIfNeeded( Path.join('x-pack/test/apm_api_integration/common/fixtures/es_archiver', 'rum_test_data') ); - - await PageObjects.common.navigateToApp('ux', { - search: `?rangeFrom=${rangeFrom}&rangeTo=${rangeTo}`, - }); - await PageObjects.header.waitUntilLoadingHasFinished(); }); after(async () => { @@ -48,16 +42,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await esArchiver.unload( Path.join('x-pack/test/apm_api_integration/common/fixtures/es_archiver', 'rum_8.0.0') ); + await esArchiver.unload( + Path.join('x-pack/test/apm_api_integration/common/fixtures/es_archiver', 'rum_test_data') + ); + }); + + it('should go to ux app', async function () { + await PageObjects.common.navigateToApp('ux', { + search: `?rangeFrom=${rangeFrom}&rangeTo=${rangeTo}`, + }); + + await PageObjects.header.waitUntilLoadingHasFinished(); }); it('should able to open exploratory view from ux app', async () => { await testSubjects.exists('uxAnalyzeBtn'); await testSubjects.click('uxAnalyzeBtn'); - expect(await find.existsByCssSelector('.euiBasicTable')).to.eql(true); + + await PageObjects.header.waitUntilLoadingHasFinished(); }); it('renders lens visualization', async () => { - expect(await testSubjects.exists('lnsVisualizationContainer')).to.eql(true); + expect(await testSubjects.exists('xyVisChart')).to.eql(true); expect( await find.existsByCssSelector('div[data-title="Prefilled from exploratory view app"]') @@ -67,12 +73,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('can do a breakdown per series', async () => { + await testSubjects.click('editSeries0'); + await testSubjects.click('seriesBreakdown'); expect(await find.existsByCssSelector('[id="user_agent.name"]')).to.eql(true); await find.clickByCssSelector('[id="user_agent.name"]'); + await testSubjects.click('seriesChangesApplyButton'); + await PageObjects.header.waitUntilLoadingHasFinished(); expect(await find.existsByCssSelector('[title="Chrome Mobile iOS"]')).to.eql(true); From a8d54b3e3e9193fb7d2c12a872eaee7adbac651d Mon Sep 17 00:00:00 2001 From: Alexey Antonov Date: Mon, 3 Oct 2022 16:19:06 +0300 Subject: [PATCH 002/152] [TSVB] [Annotations] Update label for Time field (#142452) * [TSVB] [Annotations] Update label for Time field Closes: #142226 * Update src/plugins/vis_types/timeseries/public/application/components/aggs/field_select/field_select.tsx Co-authored-by: Marco Liberati * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' Co-authored-by: Marco Liberati Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .../components/aggs/field_select/field_select.tsx | 11 ++++++++--- .../public/application/components/annotation_row.tsx | 6 +++++- x-pack/plugins/translations/translations/fr-FR.json | 1 - x-pack/plugins/translations/translations/ja-JP.json | 1 - x-pack/plugins/translations/translations/zh-CN.json | 1 - 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/plugins/vis_types/timeseries/public/application/components/aggs/field_select/field_select.tsx b/src/plugins/vis_types/timeseries/public/application/components/aggs/field_select/field_select.tsx index 27f4d96381fda..df4d683d11ea9 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/aggs/field_select/field_select.tsx +++ b/src/plugins/vis_types/timeseries/public/application/components/aggs/field_select/field_select.tsx @@ -47,10 +47,15 @@ interface FieldSelectProps { fullWidth?: boolean; } -const getPreselectedFields = ( +const getPlaceholderValue = ( placeholder?: string, options?: Array> -) => placeholder && findInGroupedOptions(options, placeholder)?.label; +) => { + if (!placeholder) { + return; + } + return findInGroupedOptions(options, placeholder)?.label || placeholder; +}; export function FieldSelect({ label, @@ -138,7 +143,7 @@ export function FieldSelect({ onNewItemAdd={onNewItemAdd.bind(undefined, props.index)} onDeleteItem={onDeleteItem.bind(undefined, props.index)} onChange={onFieldSelectItemChange.bind(undefined, props.index)} - placeholder={getPreselectedFields(placeholder, groupedOptions)} + placeholder={getPlaceholderValue(placeholder, groupedOptions)} disableAdd={!allowMultiSelect || selectedIds?.length >= MAX_MULTI_FIELDS_ITEMS} disableDelete={!allowMultiSelect || selectedIds?.length <= 1} /> diff --git a/src/plugins/vis_types/timeseries/public/application/components/annotation_row.tsx b/src/plugins/vis_types/timeseries/public/application/components/annotation_row.tsx index 49ae7ea348f5a..9d44ba5f95745 100644 --- a/src/plugins/vis_types/timeseries/public/application/components/annotation_row.tsx +++ b/src/plugins/vis_types/timeseries/public/application/components/annotation_row.tsx @@ -154,7 +154,7 @@ export const AnnotationRow = ({ label={ } restrict={RESTRICT_FIELDS} @@ -165,6 +165,10 @@ export const AnnotationRow = ({ }) } indexPattern={model.index_pattern} + placeholder={ + fetchedIndex?.indexPattern?.timeFieldName ?? + fetchedIndex?.defaultIndex?.timeFieldName + } fields={fields} /> diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 151159fa0980b..da2072ab3d605 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -5487,7 +5487,6 @@ "visTypeTimeseries.annotationsEditor.ignorePanelFiltersLabel": "Ignorer les filtres de panneau ?", "visTypeTimeseries.annotationsEditor.queryStringLabel": "Chaîne de requête", "visTypeTimeseries.annotationsEditor.rowTemplateLabel": "Modèle de ligne (requis)", - "visTypeTimeseries.annotationsEditor.timeFieldLabel": "Champ temporel (requis)", "visTypeTimeseries.calculateLabel.bucketScriptsLabel": "Script de compartiment", "visTypeTimeseries.calculateLabel.countLabel": "Décompte", "visTypeTimeseries.calculateLabel.filterRatioLabel": "Rapport de filtre", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 5465a9a7be7f5..0238b9e9add28 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -5481,7 +5481,6 @@ "visTypeTimeseries.annotationsEditor.ignorePanelFiltersLabel": "パネルフィルターを無視しますか?", "visTypeTimeseries.annotationsEditor.queryStringLabel": "クエリ文字列", "visTypeTimeseries.annotationsEditor.rowTemplateLabel": "行テンプレート(必須)", - "visTypeTimeseries.annotationsEditor.timeFieldLabel": "時間フィールド(必須)", "visTypeTimeseries.calculateLabel.bucketScriptsLabel": "バケットスクリプト", "visTypeTimeseries.calculateLabel.countLabel": "カウント", "visTypeTimeseries.calculateLabel.filterRatioLabel": "フィルターレート", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index e2de967852a88..d555235d7ad76 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -5488,7 +5488,6 @@ "visTypeTimeseries.annotationsEditor.ignorePanelFiltersLabel": "忽略面板筛选?", "visTypeTimeseries.annotationsEditor.queryStringLabel": "查询字符串", "visTypeTimeseries.annotationsEditor.rowTemplateLabel": "行模板(必需)", - "visTypeTimeseries.annotationsEditor.timeFieldLabel": "时间字段(必需)", "visTypeTimeseries.calculateLabel.bucketScriptsLabel": "存储桶脚本", "visTypeTimeseries.calculateLabel.countLabel": "计数", "visTypeTimeseries.calculateLabel.filterRatioLabel": "筛选比", From 6abf71a2efeef041d503fd5ff3cafa537a3583cc Mon Sep 17 00:00:00 2001 From: Paul Tavares <56442535+paul-tavares@users.noreply.github.com> Date: Mon, 3 Oct 2022 10:20:40 -0400 Subject: [PATCH 003/152] [Security Solution][Endpoint] Move artifact list page and host isolation exception skipped tests to jest integration (#142275) * Moved ArtifactListPage failing tests to integration_tests * Fix failing test in artifact list page * un-skip tests * move host isolation exceptions list test to jest integration tests * Un-skip tests from host isolation exceptions form test * move tests from host isolation exceptions form to integration_tests --- .../artifact_delete_modal.test.ts | 16 +++---- .../artifact_list_page.test.tsx | 44 +++++++++++-------- .../{ => integration_tests}/form.test.tsx | 28 +++++------- .../host_isolation_exceptions_list.test.tsx | 30 ++++++------- 4 files changed, 58 insertions(+), 60 deletions(-) rename x-pack/plugins/security_solution/public/management/components/artifact_list_page/components/{ => integration_tests}/artifact_delete_modal.test.ts (88%) rename x-pack/plugins/security_solution/public/management/components/artifact_list_page/{ => integration_tests}/artifact_list_page.test.tsx (87%) rename x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/{ => integration_tests}/form.test.tsx (90%) rename x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/{ => integration_tests}/host_isolation_exceptions_list.test.tsx (74%) diff --git a/x-pack/plugins/security_solution/public/management/components/artifact_list_page/components/artifact_delete_modal.test.ts b/x-pack/plugins/security_solution/public/management/components/artifact_list_page/components/integration_tests/artifact_delete_modal.test.ts similarity index 88% rename from x-pack/plugins/security_solution/public/management/components/artifact_list_page/components/artifact_delete_modal.test.ts rename to x-pack/plugins/security_solution/public/management/components/artifact_list_page/components/integration_tests/artifact_delete_modal.test.ts index 57ea165f0b85f..94e2f5c78d912 100644 --- a/x-pack/plugins/security_solution/public/management/components/artifact_list_page/components/artifact_delete_modal.test.ts +++ b/x-pack/plugins/security_solution/public/management/components/artifact_list_page/components/integration_tests/artifact_delete_modal.test.ts @@ -5,13 +5,13 @@ * 2.0. */ -import type { AppContextTestRender } from '../../../../common/mock/endpoint'; -import type { trustedAppsAllHttpMocks } from '../../../mocks'; -import type { ArtifactListPageRenderingSetup } from '../mocks'; -import { getArtifactListPageRenderingSetup } from '../mocks'; +import type { AppContextTestRender } from '../../../../../common/mock/endpoint'; +import type { trustedAppsAllHttpMocks } from '../../../../mocks'; +import type { ArtifactListPageRenderingSetup } from '../../mocks'; +import { getArtifactListPageRenderingSetup } from '../../mocks'; import { act, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { getDeferred } from '../../../mocks/utils'; +import { getDeferred } from '../../../../mocks/utils'; describe('When displaying the Delete artifact modal in the Artifact List Page', () => { let renderResult: ReturnType; @@ -77,14 +77,12 @@ describe('When displaying the Delete artifact modal in the Artifact List Page', 10000 ); - // FLAKY: https://github.com/elastic/kibana/issues/139527 - it.skip('should show Cancel and Delete buttons enabled', async () => { + it('should show Cancel and Delete buttons enabled', async () => { expect(cancelButton).toBeEnabled(); expect(submitButton).toBeEnabled(); }); - // FLAKY: https://github.com/elastic/kibana/issues/139528 - it.skip('should close modal if Cancel/Close buttons are clicked', async () => { + it('should close modal if Cancel/Close buttons are clicked', async () => { userEvent.click(cancelButton); expect(renderResult.queryByTestId('testPage-deleteModal')).toBeNull(); diff --git a/x-pack/plugins/security_solution/public/management/components/artifact_list_page/artifact_list_page.test.tsx b/x-pack/plugins/security_solution/public/management/components/artifact_list_page/integration_tests/artifact_list_page.test.tsx similarity index 87% rename from x-pack/plugins/security_solution/public/management/components/artifact_list_page/artifact_list_page.test.tsx rename to x-pack/plugins/security_solution/public/management/components/artifact_list_page/integration_tests/artifact_list_page.test.tsx index 6780335312251..0a8eb19513a81 100644 --- a/x-pack/plugins/security_solution/public/management/components/artifact_list_page/artifact_list_page.test.tsx +++ b/x-pack/plugins/security_solution/public/management/components/artifact_list_page/integration_tests/artifact_list_page.test.tsx @@ -5,19 +5,18 @@ * 2.0. */ -import type { AppContextTestRender } from '../../../common/mock/endpoint'; -import type { trustedAppsAllHttpMocks } from '../../mocks'; -import type { ArtifactListPageProps } from './artifact_list_page'; +import type { AppContextTestRender } from '../../../../common/mock/endpoint'; +import type { trustedAppsAllHttpMocks } from '../../../mocks'; +import type { ArtifactListPageProps } from '../artifact_list_page'; import { act, fireEvent, waitFor, waitForElementToBeRemoved } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import type { ArtifactListPageRenderingSetup } from './mocks'; -import { getArtifactListPageRenderingSetup } from './mocks'; -import { getDeferred } from '../../mocks/utils'; +import type { ArtifactListPageRenderingSetup } from '../mocks'; +import { getArtifactListPageRenderingSetup } from '../mocks'; +import { getDeferred } from '../../../mocks/utils'; -jest.mock('../../../common/components/user_privileges'); +jest.mock('../../../../common/components/user_privileges'); -// FLAKY: https://github.com/elastic/kibana/issues/140620 -describe.skip('When using the ArtifactListPage component', () => { +describe('When using the ArtifactListPage component', () => { let render: ( props?: Partial ) => ReturnType; @@ -64,6 +63,7 @@ describe.skip('When using the ArtifactListPage component', () => { await act(async () => { await waitFor(() => { expect(renderResult.getByTestId('testPage-list')).toBeTruthy(); + expect(mockedApi.responseProvider.trustedAppsList).toHaveBeenCalled(); }); }); @@ -121,11 +121,12 @@ describe.skip('When using the ArtifactListPage component', () => { }); await act(async () => { await waitFor(() => { - expect(getByTestId('tablePagination-20-rows')); + expect(getByTestId('tablePagination-20-rows')).toBeEnabled(); }); }); - act(() => { - userEvent.click(getByTestId('tablePagination-20-rows')); + + userEvent.click(getByTestId('tablePagination-20-rows'), undefined, { + skipPointerEventsCheck: true, }); await waitFor(() => { @@ -139,11 +140,17 @@ describe.skip('When using the ArtifactListPage component', () => { act(() => { switch (action) { case 'delete': - userEvent.click(renderResult.getByTestId('testPage-card-cardDeleteAction')); + userEvent.click( + renderResult.getByTestId('testPage-card-cardDeleteAction'), + undefined, + { skipPointerEventsCheck: true } + ); break; case 'edit': - userEvent.click(renderResult.getByTestId('testPage-card-cardEditAction')); + userEvent.click(renderResult.getByTestId('testPage-card-cardEditAction'), undefined, { + skipPointerEventsCheck: true, + }); break; } }); @@ -156,8 +163,7 @@ describe.skip('When using the ArtifactListPage component', () => { expect(getByTestId('testPage-flyout')).toBeTruthy(); }); - // FLAKY: https://github.com/elastic/kibana/issues/129837 - it.skip('should display the Delete modal when delete action is clicked', async () => { + it('should display the Delete modal when delete action is clicked', async () => { const { getByTestId } = await renderWithListData(); await clickCardAction('delete'); @@ -228,8 +234,7 @@ describe.skip('When using the ArtifactListPage component', () => { }); }); - // FLAKY: https://github.com/elastic/kibana/issues/129837 - it.skip('should persist policy filter to the URL params', async () => { + it('should persist policy filter to the URL params', async () => { const policyId = mockedApi.responseProvider.endpointPackagePolicyList().items[0].id; const firstPolicyTestId = `policiesSelector-popover-items-${policyId}`; @@ -247,9 +252,10 @@ describe.skip('When using the ArtifactListPage component', () => { await waitFor(() => { expect(renderResult.getByTestId(firstPolicyTestId)).toBeTruthy(); }); - userEvent.click(renderResult.getByTestId(firstPolicyTestId)); }); + userEvent.click(renderResult.getByTestId(firstPolicyTestId)); + await waitFor(() => { expect(history.location.search).toMatch(new RegExp(`includedPolicies=${policyId}`)); }); diff --git a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form.test.tsx b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/integration_tests/form.test.tsx similarity index 90% rename from x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form.test.tsx rename to x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/integration_tests/form.test.tsx index 4c7ac15a504a7..ec661c9185f4d 100644 --- a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/form.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/components/integration_tests/form.test.tsx @@ -11,26 +11,25 @@ import type { } from '@kbn/securitysolution-io-ts-list-types'; import userEvent from '@testing-library/user-event'; import React from 'react'; -import type { AppContextTestRender } from '../../../../../common/mock/endpoint'; -import { createAppRootMockRenderer } from '../../../../../common/mock/endpoint'; -import { HostIsolationExceptionsList } from '../host_isolation_exceptions_list'; +import type { AppContextTestRender } from '../../../../../../common/mock/endpoint'; +import { createAppRootMockRenderer } from '../../../../../../common/mock/endpoint'; +import { HostIsolationExceptionsList } from '../../host_isolation_exceptions_list'; import { act, waitFor } from '@testing-library/react'; -import { HOST_ISOLATION_EXCEPTIONS_PATH } from '../../../../../../common/constants'; +import { HOST_ISOLATION_EXCEPTIONS_PATH } from '../../../../../../../common/constants'; import { exceptionsListAllHttpMocks, fleetGetEndpointPackagePolicyListHttpMock, -} from '../../../../mocks'; +} from '../../../../../mocks'; import { clickOnEffectedPolicy, isEffectedPolicySelected, -} from '../../../../components/effected_policy_select/test_utils'; -import { BY_POLICY_ARTIFACT_TAG_PREFIX } from '../../../../../../common/endpoint/service/artifacts'; +} from '../../../../../components/effected_policy_select/test_utils'; +import { BY_POLICY_ARTIFACT_TAG_PREFIX } from '../../../../../../../common/endpoint/service/artifacts'; import type { HttpFetchOptionsWithPath } from '@kbn/core/public'; -jest.mock('../../../../../common/components/user_privileges'); +jest.mock('../../../../../../common/components/user_privileges'); -// FLAKY: https://github.com/elastic/kibana/issues/140907 -describe.skip('When on the host isolation exceptions entry form', () => { +describe('When on the host isolation exceptions entry form', () => { let render: () => Promise>; let renderResult: ReturnType; let history: AppContextTestRender['history']; @@ -86,8 +85,7 @@ describe.skip('When on the host isolation exceptions entry form', () => { await render(); }); - // FLAKY: https://github.com/elastic/kibana/issues/140140 - it.skip('should render the form with empty inputs', () => { + it('should render the form with empty inputs', () => { expect(renderResult.getByTestId('hostIsolationExceptions-form-name-input')).toHaveValue(''); expect(renderResult.getByTestId('hostIsolationExceptions-form-ip-input')).toHaveValue(''); expect( @@ -146,16 +144,14 @@ describe.skip('When on the host isolation exceptions entry form', () => { ).toBe(true); }); - // FLAKY: https://github.com/elastic/kibana/issues/139776 - it.skip('should show policy as selected when user clicks on it', async () => { + it('should show policy as selected when user clicks on it', async () => { userEvent.click(renderResult.getByTestId('perPolicy')); await clickOnEffectedPolicy(renderResult); await expect(isEffectedPolicySelected(renderResult)).resolves.toBe(true); }); - // FLAKY: https://github.com/elastic/kibana/issues/139899 - it.skip('should retain the previous policy selection when switching from per-policy to global', async () => { + it('should retain the previous policy selection when switching from per-policy to global', async () => { // move to per-policy and select the first userEvent.click(renderResult.getByTestId('perPolicy')); await clickOnEffectedPolicy(renderResult); diff --git a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/host_isolation_exceptions_list.test.tsx b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/integration_tests/host_isolation_exceptions_list.test.tsx similarity index 74% rename from x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/host_isolation_exceptions_list.test.tsx rename to x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/integration_tests/host_isolation_exceptions_list.test.tsx index 2f0fc55979090..435178f2a0252 100644 --- a/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/host_isolation_exceptions_list.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/host_isolation_exceptions/view/integration_tests/host_isolation_exceptions_list.test.tsx @@ -8,22 +8,21 @@ import { act, fireEvent, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; -import { HOST_ISOLATION_EXCEPTIONS_PATH } from '../../../../../common/constants'; -import type { AppContextTestRender } from '../../../../common/mock/endpoint'; -import { createAppRootMockRenderer } from '../../../../common/mock/endpoint'; -import { HostIsolationExceptionsList } from './host_isolation_exceptions_list'; -import { exceptionsListAllHttpMocks } from '../../../mocks/exceptions_list_http_mocks'; -import { SEARCHABLE_FIELDS } from '../constants'; -import { parseQueryFilterToKQL } from '../../../common/utils'; -import { useUserPrivileges as _useUserPrivileges } from '../../../../common/components/user_privileges'; -import { getUserPrivilegesMockDefaultValue } from '../../../../common/components/user_privileges/__mocks__'; -import { getFirstCard } from '../../../components/artifact_list_page/mocks'; - -jest.mock('../../../../common/components/user_privileges'); +import { HOST_ISOLATION_EXCEPTIONS_PATH } from '../../../../../../common/constants'; +import type { AppContextTestRender } from '../../../../../common/mock/endpoint'; +import { createAppRootMockRenderer } from '../../../../../common/mock/endpoint'; +import { HostIsolationExceptionsList } from '../host_isolation_exceptions_list'; +import { exceptionsListAllHttpMocks } from '../../../../mocks/exceptions_list_http_mocks'; +import { SEARCHABLE_FIELDS } from '../../constants'; +import { parseQueryFilterToKQL } from '../../../../common/utils'; +import { useUserPrivileges as _useUserPrivileges } from '../../../../../common/components/user_privileges'; +import { getUserPrivilegesMockDefaultValue } from '../../../../../common/components/user_privileges/__mocks__'; +import { getFirstCard } from '../../../../components/artifact_list_page/mocks'; + +jest.mock('../../../../../common/components/user_privileges'); const useUserPrivilegesMock = _useUserPrivileges as jest.Mock; -// FLAKY: https://github.com/elastic/kibana/issues/140888 -describe.skip('When on the host isolation exceptions page', () => { +describe('When on the host isolation exceptions page', () => { let render: () => ReturnType; let renderResult: ReturnType; let history: AppContextTestRender['history']; @@ -78,8 +77,7 @@ describe.skip('When on the host isolation exceptions page', () => { ); }); - // FLAKY: https://github.com/elastic/kibana/issues/135587 - it.skip('should hide the Create and Edit actions when host isolation authz is not allowed', async () => { + it('should hide the Create and Edit actions when host isolation authz is not allowed', async () => { // Use case: license downgrade scenario, where user still has entries defined, but no longer // able to create or edit them (only Delete them) const existingPrivileges = useUserPrivilegesMock(); From 40b397d0e195453df84d92e8c70b629fb9774729 Mon Sep 17 00:00:00 2001 From: Sandra G Date: Mon, 3 Oct 2022 10:24:25 -0400 Subject: [PATCH 004/152] add rx and tx to lens table (#142137) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../metrics/hosts/components/hosts_table.tsx | 270 ++++++++++++++++-- 1 file changed, 245 insertions(+), 25 deletions(-) diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/components/hosts_table.tsx b/x-pack/plugins/infra/public/pages/metrics/hosts/components/hosts_table.tsx index 57b3ab0e683ac..74f2468eb4c45 100644 --- a/x-pack/plugins/infra/public/pages/metrics/hosts/components/hosts_table.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/hosts/components/hosts_table.tsx @@ -93,16 +93,24 @@ const getLensHostsTable = ( }, customLabel: true, }, - '0a9bd0fa-9966-489b-8c95-70997a7aad4cX0': { - label: 'Part of Memory Total (avg)', + '3eca2307-228e-4842-a023-57e15c8c364d': { + label: 'Disk latency (avg.)', dataType: 'number', - operationType: 'average', - sourceField: 'system.memory.total', + operationType: 'formula', isBucketed: false, scale: 'ratio', params: { - emptyAsNull: false, + formula: 'average(system.diskio.io.time) / 1000', + isFormulaBroken: false, + format: { + id: 'number', + params: { + decimals: 0, + suffix: 'ms', + }, + }, }, + references: ['3eca2307-228e-4842-a023-57e15c8c364dX1'], customLabel: true, }, '0a9bd0fa-9966-489b-8c95-70997a7aad4c': { @@ -124,18 +132,6 @@ const getLensHostsTable = ( references: ['0a9bd0fa-9966-489b-8c95-70997a7aad4cX0'], customLabel: true, }, - 'fe5a4d7d-6f48-45ab-974c-96bc864ac36fX0': { - label: 'Part of Memory Usage (avg)', - dataType: 'number', - operationType: 'average', - sourceField: 'system.memory.used.pct', - isBucketed: false, - scale: 'ratio', - params: { - emptyAsNull: false, - }, - customLabel: true, - }, 'fe5a4d7d-6f48-45ab-974c-96bc864ac36f': { label: 'Memory usage (avg.)', dataType: 'number', @@ -155,6 +151,30 @@ const getLensHostsTable = ( references: ['fe5a4d7d-6f48-45ab-974c-96bc864ac36fX0'], customLabel: true, }, + '0a9bd0fa-9966-489b-8c95-70997a7aad4cX0': { + label: 'Part of Memory Total (avg)', + dataType: 'number', + operationType: 'average', + sourceField: 'system.memory.total', + isBucketed: false, + scale: 'ratio', + params: { + emptyAsNull: false, + }, + customLabel: true, + }, + 'fe5a4d7d-6f48-45ab-974c-96bc864ac36fX0': { + label: 'Part of Memory Usage (avg)', + dataType: 'number', + operationType: 'average', + sourceField: 'system.memory.used.pct', + isBucketed: false, + scale: 'ratio', + params: { + emptyAsNull: false, + }, + customLabel: true, + }, '3eca2307-228e-4842-a023-57e15c8c364dX0': { label: 'Part of Disk Latency (avg ms)', dataType: 'number', @@ -188,24 +208,208 @@ const getLensHostsTable = ( references: ['3eca2307-228e-4842-a023-57e15c8c364dX0'], customLabel: true, }, - '3eca2307-228e-4842-a023-57e15c8c364d': { - label: 'Disk latency (avg.)', + '02e9d54c-bbe0-42dc-839c-55080a29838dX0': { + label: 'Part of RX (avg)', + dataType: 'number', + operationType: 'average', + sourceField: 'host.network.ingress.bytes', + isBucketed: false, + scale: 'ratio', + filter: { + query: 'host.network.ingress.bytes: *', + language: 'kuery', + }, + params: { + emptyAsNull: false, + }, + customLabel: true, + }, + '02e9d54c-bbe0-42dc-839c-55080a29838dX1': { + label: 'Part of RX (avg)', + dataType: 'number', + operationType: 'max', + sourceField: 'metricset.period', + isBucketed: false, + scale: 'ratio', + filter: { + query: 'host.network.ingress.bytes: *', + language: 'kuery', + }, + params: { + emptyAsNull: false, + }, + customLabel: true, + }, + '02e9d54c-bbe0-42dc-839c-55080a29838dX2': { + label: 'Part of RX (avg)', + dataType: 'number', + operationType: 'math', + isBucketed: false, + scale: 'ratio', + params: { + tinymathAst: { + type: 'function', + name: 'divide', + args: [ + { + type: 'function', + name: 'multiply', + args: ['02e9d54c-bbe0-42dc-839c-55080a29838dX0', 8], + location: { + min: 1, + max: 40, + }, + text: 'average(host.network.ingress.bytes) * 8', + }, + { + type: 'function', + name: 'divide', + args: ['02e9d54c-bbe0-42dc-839c-55080a29838dX1', 1000], + location: { + min: 45, + max: 73, + }, + text: 'max(metricset.period) / 1000', + }, + ], + location: { + min: 0, + max: 75, + }, + text: '(average(host.network.ingress.bytes) * 8) / (max(metricset.period) / 1000)\n', + }, + }, + references: [ + '02e9d54c-bbe0-42dc-839c-55080a29838dX0', + '02e9d54c-bbe0-42dc-839c-55080a29838dX1', + ], + customLabel: true, + }, + '02e9d54c-bbe0-42dc-839c-55080a29838d': { + label: 'RX (avg.)', dataType: 'number', operationType: 'formula', isBucketed: false, scale: 'ratio', params: { - formula: 'average(system.diskio.io.time) / 1000', + formula: + '(average(host.network.ingress.bytes) * 8) / (max(metricset.period) / 1000)\n', isFormulaBroken: false, format: { - id: 'number', + id: 'bits', params: { decimals: 0, - suffix: 'ms', + suffix: '/s', }, }, }, - references: ['3eca2307-228e-4842-a023-57e15c8c364dX1'], + references: ['02e9d54c-bbe0-42dc-839c-55080a29838dX2'], + filter: { + query: 'host.network.ingress.bytes: *', + language: 'kuery', + }, + customLabel: true, + }, + '7802ef93-622c-44df-94fa-03eec01bb7b6X0': { + label: 'Part of TX', + dataType: 'number', + operationType: 'average', + sourceField: 'host.network.egress.bytes', + isBucketed: false, + scale: 'ratio', + filter: { + query: 'host.network.egress.bytes: *', + language: 'kuery', + }, + params: { + emptyAsNull: false, + }, + customLabel: true, + }, + '7802ef93-622c-44df-94fa-03eec01bb7b6X1': { + label: 'Part of TX', + dataType: 'number', + operationType: 'max', + sourceField: 'metricset.period', + isBucketed: false, + scale: 'ratio', + filter: { + query: 'host.network.egress.bytes: *', + language: 'kuery', + }, + params: { + emptyAsNull: false, + }, + customLabel: true, + }, + '7802ef93-622c-44df-94fa-03eec01bb7b6X2': { + label: 'Part of TX', + dataType: 'number', + operationType: 'math', + isBucketed: false, + scale: 'ratio', + params: { + tinymathAst: { + type: 'function', + name: 'divide', + args: [ + { + type: 'function', + name: 'multiply', + args: ['7802ef93-622c-44df-94fa-03eec01bb7b6X0', 8], + location: { + min: 1, + max: 39, + }, + text: 'average(host.network.egress.bytes) * 8', + }, + { + type: 'function', + name: 'divide', + args: ['7802ef93-622c-44df-94fa-03eec01bb7b6X1', 1000], + location: { + min: 44, + max: 72, + }, + text: 'max(metricset.period) / 1000', + }, + ], + location: { + min: 0, + max: 74, + }, + text: '(average(host.network.egress.bytes) * 8) / (max(metricset.period) / 1000)\n', + }, + }, + references: [ + '7802ef93-622c-44df-94fa-03eec01bb7b6X0', + '7802ef93-622c-44df-94fa-03eec01bb7b6X1', + ], + customLabel: true, + }, + '7802ef93-622c-44df-94fa-03eec01bb7b6': { + label: 'TX (avg.)', + dataType: 'number', + operationType: 'formula', + isBucketed: false, + scale: 'ratio', + params: { + formula: + '(average(host.network.egress.bytes) * 8) / (max(metricset.period) / 1000)\n', + isFormulaBroken: false, + format: { + id: 'bits', + params: { + decimals: 0, + suffix: '/s', + }, + }, + }, + references: ['7802ef93-622c-44df-94fa-03eec01bb7b6X2'], + filter: { + query: 'host.network.egress.bytes: *', + language: 'kuery', + }, customLabel: true, }, }, @@ -214,12 +418,20 @@ const getLensHostsTable = ( '155fc728-d010-498e-8126-0bc46cad2be2', '467de550-9186-4e18-8cfa-bce07087801a', '3eca2307-228e-4842-a023-57e15c8c364d', + '02e9d54c-bbe0-42dc-839c-55080a29838d', + '7802ef93-622c-44df-94fa-03eec01bb7b6', '0a9bd0fa-9966-489b-8c95-70997a7aad4c', 'fe5a4d7d-6f48-45ab-974c-96bc864ac36f', '0a9bd0fa-9966-489b-8c95-70997a7aad4cX0', 'fe5a4d7d-6f48-45ab-974c-96bc864ac36fX0', '3eca2307-228e-4842-a023-57e15c8c364dX0', '3eca2307-228e-4842-a023-57e15c8c364dX1', + '02e9d54c-bbe0-42dc-839c-55080a29838dX0', + '02e9d54c-bbe0-42dc-839c-55080a29838dX1', + '02e9d54c-bbe0-42dc-839c-55080a29838dX2', + '7802ef93-622c-44df-94fa-03eec01bb7b6X0', + '7802ef93-622c-44df-94fa-03eec01bb7b6X1', + '7802ef93-622c-44df-94fa-03eec01bb7b6X2', ], incompleteColumns: {}, indexPatternId: '305688db-9e02-4046-acc1-5d0d8dd73ef6', @@ -234,6 +446,7 @@ const getLensHostsTable = ( { columnId: '8d17458d-31af-41d1-a23c-5180fd960bee', width: 296.16666666666663, + isTransposed: false, }, { columnId: '155fc728-d010-498e-8126-0bc46cad2be2', @@ -245,6 +458,10 @@ const getLensHostsTable = ( isTransposed: false, width: 121.11666666666667, }, + { + columnId: '3eca2307-228e-4842-a023-57e15c8c364d', + isTransposed: false, + }, { columnId: '0a9bd0fa-9966-489b-8c95-70997a7aad4c', isTransposed: false, @@ -254,8 +471,12 @@ const getLensHostsTable = ( isTransposed: false, }, { - columnId: '3eca2307-228e-4842-a023-57e15c8c364d', isTransposed: false, + columnId: '02e9d54c-bbe0-42dc-839c-55080a29838d', + }, + { + isTransposed: false, + columnId: '7802ef93-622c-44df-94fa-03eec01bb7b6', }, ], paging: { @@ -288,7 +509,6 @@ export const HostsTable: React.FunctionComponent = ({ services: { lens }, } = useKibana(); const LensComponent = lens?.EmbeddableComponent; - return ( Date: Mon, 3 Oct 2022 15:30:04 +0100 Subject: [PATCH 005/152] Added user avatar tooltip (#142162) * Added user avatar tooltip * Updated js docs --- .../public/panel_with_code_block.tsx | 1 - .../user_profile_examples/public/plugin.tsx | 23 +++-- .../public/tooltip_demo.tsx | 62 +++++++++++++ packages/kbn-user-profile-components/index.ts | 3 + .../src/user_avatar_tip.test.tsx | 73 +++++++++++++++ .../src/user_avatar_tip.tsx | 29 ++++++ .../src/user_profiles_selectable.tsx | 2 +- .../src/user_tooltip.test.tsx | 91 +++++++++++++++++++ .../src/user_tooltip.tsx | 60 ++++++++++++ 9 files changed, 334 insertions(+), 10 deletions(-) create mode 100644 examples/user_profile_examples/public/tooltip_demo.tsx create mode 100644 packages/kbn-user-profile-components/src/user_avatar_tip.test.tsx create mode 100644 packages/kbn-user-profile-components/src/user_avatar_tip.tsx create mode 100644 packages/kbn-user-profile-components/src/user_tooltip.test.tsx create mode 100644 packages/kbn-user-profile-components/src/user_tooltip.tsx diff --git a/examples/user_profile_examples/public/panel_with_code_block.tsx b/examples/user_profile_examples/public/panel_with_code_block.tsx index 3b86b343eda7d..17854fb3ad36d 100644 --- a/examples/user_profile_examples/public/panel_with_code_block.tsx +++ b/examples/user_profile_examples/public/panel_with_code_block.tsx @@ -31,6 +31,5 @@ export const PanelWithCodeBlock: React.FunctionComponent - ); diff --git a/examples/user_profile_examples/public/plugin.tsx b/examples/user_profile_examples/public/plugin.tsx index e821ebebcd7d9..1b6dd5db267c6 100755 --- a/examples/user_profile_examples/public/plugin.tsx +++ b/examples/user_profile_examples/public/plugin.tsx @@ -14,6 +14,7 @@ import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template'; import { AvatarDemo } from './avatar_demo'; import { PopoverDemo } from './popover_demo'; import { SelectableDemo } from './selectable_demo'; +import { ToolTipDemo } from './tooltip_demo'; interface SetupDeps { developerExamples: DeveloperExamplesSetup; @@ -38,14 +39,20 @@ export class UserProfilesPlugin implements Plugin - - - + + + + + + + + + + + + + + , element ); diff --git a/examples/user_profile_examples/public/tooltip_demo.tsx b/examples/user_profile_examples/public/tooltip_demo.tsx new file mode 100644 index 0000000000000..beed3401c0451 --- /dev/null +++ b/examples/user_profile_examples/public/tooltip_demo.tsx @@ -0,0 +1,62 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ +import React, { FunctionComponent } from 'react'; +import { UserAvatarTip, UserToolTip } from '@kbn/user-profile-components'; +import type { UserProfile, UserProfileAvatarData } from '@kbn/user-profile-components'; +import { EuiCommentList, EuiComment } from '@elastic/eui'; +import { PanelWithCodeBlock } from './panel_with_code_block'; + +export const ToolTipDemo: FunctionComponent = () => { + const userProfile: UserProfile<{ avatar: UserProfileAvatarData }> = { + uid: 'u_9xDEQqUqoYCnFnPPLq5mIRHKL8gBTo_NiKgOnd5gGk0_0', + enabled: true, + user: { + username: 'wet_dingo', + email: 'wet_dingo@elastic.co', + full_name: 'Wet Dingo', + }, + data: { + avatar: { + color: '#09e8ca', + initials: 'WD', + imageUrl: 'https://source.unsplash.com/64x64/?dingo', + }, + }, + }; + + return ( + + + + } + username={ + + {userProfile.user.full_name} + + } + event="pushed incident X0Z235 on Jan 3, 2020" + /> + + + ); +}; + +const code = `import { UserToolTip, UserAvatarTip } from '@kbn/user-profile-components'; + + + + + +`; diff --git a/packages/kbn-user-profile-components/index.ts b/packages/kbn-user-profile-components/index.ts index 8489a9eb3b35a..5f8d1db6fcf62 100644 --- a/packages/kbn-user-profile-components/index.ts +++ b/packages/kbn-user-profile-components/index.ts @@ -7,9 +7,12 @@ */ export type { UserAvatarProps, UserProfileWithAvatar } from './src/user_avatar'; +export type { UserToolTipProps } from './src/user_tooltip'; export type { UserProfilesSelectableProps } from './src/user_profiles_selectable'; export type { UserProfilesPopoverProps } from './src/user_profiles_popover'; export { UserAvatar } from './src/user_avatar'; +export { UserAvatarTip } from './src/user_avatar_tip'; +export { UserToolTip } from './src/user_tooltip'; export { UserProfilesSelectable } from './src/user_profiles_selectable'; export { UserProfilesPopover } from './src/user_profiles_popover'; export { getUserDisplayName } from './src/user_profile'; diff --git a/packages/kbn-user-profile-components/src/user_avatar_tip.test.tsx b/packages/kbn-user-profile-components/src/user_avatar_tip.test.tsx new file mode 100644 index 0000000000000..108015c3bae60 --- /dev/null +++ b/packages/kbn-user-profile-components/src/user_avatar_tip.test.tsx @@ -0,0 +1,73 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { shallow } from 'enzyme'; +import React from 'react'; + +import { UserAvatarTip } from './user_avatar_tip'; + +describe('UserAvatarTip', () => { + it('should render `UserToolTip` correctly with `UserAvatar`', () => { + const wrapper = shallow( + + ); + expect(wrapper).toMatchInlineSnapshot(` + + + + `); + }); + + it('should not render `UserToolTip` when user is not set', () => { + const wrapper = shallow(); + expect(wrapper).toMatchInlineSnapshot(``); + }); +}); diff --git a/packages/kbn-user-profile-components/src/user_avatar_tip.tsx b/packages/kbn-user-profile-components/src/user_avatar_tip.tsx new file mode 100644 index 0000000000000..6bb3d342aa38f --- /dev/null +++ b/packages/kbn-user-profile-components/src/user_avatar_tip.tsx @@ -0,0 +1,29 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { FunctionComponent } from 'react'; +import React from 'react'; + +import type { UserAvatarProps } from './user_avatar'; +import { UserAvatar } from './user_avatar'; +import { UserToolTip } from './user_tooltip'; + +/** + * Renders a user avatar with tooltip + */ +export const UserAvatarTip: FunctionComponent = ({ user, avatar, ...rest }) => { + if (!user) { + return ; + } + + return ( + + + + ); +}; diff --git a/packages/kbn-user-profile-components/src/user_profiles_selectable.tsx b/packages/kbn-user-profile-components/src/user_profiles_selectable.tsx index 76b9b9ea6d556..904e5ac2896c1 100644 --- a/packages/kbn-user-profile-components/src/user_profiles_selectable.tsx +++ b/packages/kbn-user-profile-components/src/user_profiles_selectable.tsx @@ -301,7 +301,7 @@ export const UserProfilesSelectable =