Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Logs Explorer] Add test suite for Dataset Selector #163079

Merged
merged 30 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3d4dd8e
test(discover-log-explorer): setup dataset selector mock data
Aug 3, 2023
4468506
test(discover-log-explorer): add customization test for controls
Aug 3, 2023
d1c194b
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Aug 3, 2023
c4a99db
test(discover-log-explorer): remove unused files
Aug 4, 2023
721ab00
Merge branch '160627-log-explorer-testing' of github.com:tonyghiani/k…
Aug 4, 2023
5c6446e
test(discover-log-explorer): wip on tests
Aug 4, 2023
a54c79b
test(discover-log-explorer): add load more test
Aug 7, 2023
e85f41a
Merge branch 'main' into 160627-log-explorer-testing
tonyghiani Aug 7, 2023
0652fc1
test(discover-log-explorer): update tests
Aug 7, 2023
fd98666
test(discover-log-explorer): update tests load more
Aug 8, 2023
9c609c9
test(discover-log-explorer): implement network utilities
Aug 8, 2023
852f4f4
test(discover-log-explorer): implement Network profiles
Aug 9, 2023
1af0923
Merge branch 'main' into 160627-log-explorer-testing
tonyghiani Aug 9, 2023
bcabdab
test(discover-log-explorer): copy customization tests to serverless
Aug 9, 2023
5b29f5d
test(discover-log-explorer): add test for dataset selection
Aug 9, 2023
5fbe953
test(discover-log-explorer): remove only
Aug 9, 2023
4fc6616
test(discover-log-explorer): add uncategorized test
Aug 9, 2023
90714eb
test(discover-log-explorer): add columns tests
Aug 9, 2023
23e4462
test(discover-log-explorer): update test
Aug 9, 2023
d2ddc90
Merge branch 'main' into 160627-log-explorer-testing
tonyghiani Aug 9, 2023
88579b0
test(discover-log-explorer): update test descriptions
Aug 9, 2023
f824e40
test(discover-log-explorer): remove unnecessary imports
Aug 10, 2023
9d2be78
fix(discover-log-explorer): fix popover alignment
Aug 10, 2023
62929b8
Merge branch 'main' into 160627-log-explorer-testing
tonyghiani Aug 10, 2023
1a8bfff
fix(discover-log-explorer): update tests
Aug 10, 2023
e83756a
fix(discover-log-explorer): remove only
Aug 10, 2023
17f0918
fix(discover-log-explorer): update tests for serverless and create se…
Aug 10, 2023
bfa674e
Merge branch 'main' into 160627-log-explorer-testing
tonyghiani Aug 10, 2023
45f8fe4
test(discover-log-explorer): final changes
Aug 10, 2023
1bdba72
Merge branch 'main' into 160627-log-explorer-testing
tonyghiani Aug 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export function DatasetSelector({
onPanelChange={changePanel}
className="eui-yScroll"
css={contextMenuStyles}
data-test-subj="datasetSelectorContextMenu"
size="s"
/>
</DatasetsPopover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const DatasetsList = ({
if (hasError) {
return (
<EuiEmptyPrompt
data-test-subj="datasetErrorPrompt"
iconType="warning"
iconColor="danger"
paddingSize="m"
Expand All @@ -70,6 +71,7 @@ export const DatasetsList = ({
if (isEmpty) {
return (
<EuiEmptyPrompt
data-test-subj="emptyDatasetPrompt"
iconType="search"
paddingSize="m"
title={<h2>{noDatasetsLabel}</h2>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ export const DatasetsPopover = ({
return (
<EuiPopover
id={POPOVER_ID}
data-test-subj={POPOVER_ID}
data-test-subj="datasetSelectorPopover"
anchorPosition={isMobile ? 'downCenter' : 'downLeft'}
button={
<EuiButton
css={buttonStyles}
iconType="arrowDown"
iconSide="right"
onClick={onClick}
fullWidth={isMobile}
data-test-subj={`${POPOVER_ID}-button`}
data-test-subj="datasetSelectorPopoverButton"
>
{iconType ? (
<EuiIcon type={iconType} />
Expand All @@ -74,7 +75,12 @@ export const DatasetsPopover = ({
{...(isMobile && { display: 'block' })}
{...props}
>
<EuiPanel paddingSize="none" hasShadow={false} css={panelStyle}>
<EuiPanel
paddingSize="none"
hasShadow={false}
css={panelStyle}
data-test-subj="datasetSelectorContent"
>
<Title size="xxs">
<span>{selectDatasetLabel}</span>
</Title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { EuiPanel, EuiSkeletonText } from '@elastic/eui';
import { uncategorizedLabel } from '../constants';

export const DatasetSkeleton = () => (
<EuiPanel>
<EuiPanel data-test-subj="datasetSelectorSkeleton">
<EuiSkeletonText lines={7} isLoading contentAriaLabel={uncategorizedLabel} />
</EuiPanel>
);
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const IntegrationsListStatus = ({
if (hasError) {
return (
<EuiEmptyPrompt
data-test-subj="integrationsErrorPrompt"
iconType="warning"
iconColor="danger"
paddingSize="m"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ export const SearchControls = ({ search, onSearch, onSort, isLoading }: SearchCo
};

return (
<EuiPanel paddingSize="s" hasShadow={false} css={{ width: DATA_VIEW_POPOVER_CONTENT_WIDTH }}>
<EuiPanel
paddingSize="s"
hasShadow={false}
css={{ width: DATA_VIEW_POPOVER_CONTENT_WIDTH }}
data-test-subj="datasetSelectorSearchControls"
>
<EuiFlexGroup gutterSize="xs" responsive={false}>
<EuiFlexItem>
<EuiFieldSearch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const buildIntegrationsTree = ({
integrationsTree.items.push({
name: title,
icon: <PackageIcon packageName={name} version={version} size="m" icons={icons} tryApi />,
'data-test-subj': integration.id,
panel: integration.id,
...(isLastIntegration && { buttonRef: spyRef }),
});
Expand All @@ -85,6 +86,7 @@ export const createAllLogDatasetsItem = ({ onClick }: { onClick(): void }) => {
const allLogDataset = Dataset.createAllLogsDataset();
return {
name: allLogDataset.title,
'data-test-subj': 'allLogDatasets',
icon: allLogDataset.iconType && <EuiIcon type={allLogDataset.iconType} />,
onClick,
};
Expand All @@ -93,6 +95,7 @@ export const createAllLogDatasetsItem = ({ onClick }: { onClick(): void }) => {
export const createUnmanagedDatasetsItem = ({ onClick }: { onClick: LoadDatasets }) => {
return {
name: uncategorizedLabel,
'data-test-subj': 'unmanagedDatasets',
icon: <EuiIcon type="documents" />,
onClick,
panel: UNMANAGED_STREAMS_PANEL_ID,
Expand All @@ -103,5 +106,6 @@ export const createIntegrationStatusItem = (props: IntegrationsListStatusProps)
return {
disabled: true,
name: <IntegrationsListStatus {...props} />,
'data-test-subj': 'integrationStatusItem',
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { DataPublicPluginStart } from '@kbn/data-plugin/public';
import { useControlPanels } from '../hooks/use_control_panels';
import { LogExplorerProfileStateService } from '../state_machines/log_explorer_profile';

const DATASET_FILTERS_CUSTOMIZATION_ID = 'datasetFiltersCustomization';

interface CustomDatasetFiltersProps {
logExplorerProfileStateService: LogExplorerProfileStateService;
data: DataPublicPluginStart;
Expand All @@ -27,7 +29,7 @@ const CustomDatasetFilters = ({
);

return (
<ControlGroupContainer>
<ControlGroupContainer data-test-subj={DATASET_FILTERS_CUSTOMIZATION_ID}>
<ControlGroupRenderer
ref={setControlGroupAPI}
getCreationOptions={getInitialInput}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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 expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

const defaultLogColumns = ['@timestamp', 'message'];

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const retry = getService('retry');
const PageObjects = getPageObjects(['common', 'discover']);

describe('Columns selection initialization and update', () => {
before(async () => {
await esArchiver.load(
'x-pack/test/functional/es_archives/discover_log_explorer/data_streams'
);
});

after(async () => {
await esArchiver.unload(
'x-pack/test/functional/es_archives/discover_log_explorer/data_streams'
);
});

describe('when the log explorer profile loads', () => {
it("should initialize the table columns to logs' default selection", async () => {
await PageObjects.common.navigateToApp('discover', { hash: '/p/log-explorer' });

await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage();

await retry.try(async () => {
expect(await PageObjects.discover.getColumnHeaders()).to.eql(defaultLogColumns);
});
});

it('should restore the table columns from the URL state if exists', async () => {
await PageObjects.common.navigateToApp('discover', {
hash: '/p/log-explorer?_a=(columns:!(message,data_stream.namespace))',
});

await PageObjects.discover.expandTimeRangeAsSuggestedInNoResultsMessage();

await retry.try(async () => {
expect(await PageObjects.discover.getColumnHeaders()).to.eql([
...defaultLogColumns,
'data_stream.namespace',
]);
});
});
});
});
}
16 changes: 13 additions & 3 deletions x-pack/test/functional/apps/discover_log_explorer/customization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
it('DatasetSelector should replace the DataViewPicker', async () => {
// Assert does not render on discover app
await PageObjects.common.navigateToApp('discover');
await testSubjects.missingOrFail('dataset-selector-popover');
await testSubjects.missingOrFail('datasetSelectorPopover');

// Assert it renders on log-explorer profile
await PageObjects.common.navigateToApp('discover', { hash: '/p/log-explorer' });
await testSubjects.existOrFail('dataset-selector-popover');
await testSubjects.existOrFail('datasetSelectorPopover');
});

it('the TopNav bar should hide New, Open and Save options', async () => {
it('the TopNav bar should hide then New, Open and Save options', async () => {
// Assert does not render on discover app
await PageObjects.common.navigateToApp('discover');
await testSubjects.existOrFail('discoverNewButton');
Expand All @@ -59,6 +59,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const results = await PageObjects.navigationalSearch.getDisplayedResults();
expect(results[0].label).to.eql('Discover / Logs Explorer');
});

it('should render a filter controls section as part of the unified search bar', async () => {
// Assert does not render on discover app
await PageObjects.common.navigateToApp('discover');
await testSubjects.missingOrFail('datasetFiltersCustomization');

// Assert it renders on log-explorer profile
await PageObjects.common.navigateToApp('discover', { hash: '/p/log-explorer' });
await testSubjects.existOrFail('datasetFiltersCustomization', { allowHidden: true });
});
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
});
});

describe('when the "index" query param exist', () => {
describe('when the "index" query param exists', () => {
it('should decode and restore the selection from a valid encoded index', async () => {
const azureActivitylogsIndex =
'BQZwpgNmDGAuCWB7AdgLmAEwIay+W6yWAtmKgOQSIDmIAtFgF4CuATmAHRZzwBu8sAJ5VadAFTkANAlhRU3BPyEiQASklFS8lu2kC55AII6wAAgAyNEFN5hWIJGnIBGDgFYOAJgDM5deCgeFAAVQQAHMgdkaihVIA===';
Expand All @@ -37,7 +37,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
expect(datasetSelectionTitle).to.be('[Azure Logs] activitylogs');
});

it('should fallback to "All log datasets" selection and notify the user for an invalid encoded index', async () => {
it('should fallback to the "All log datasets" selection and notify the user of an invalid encoded index', async () => {
const invalidEncodedIndex = 'invalid-encoded-index';
await PageObjects.common.navigateToApp('discover', {
hash: `/p/log-explorer?_a=(index:${encodeURIComponent(invalidEncodedIndex)})`,
Expand Down
Loading