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

[Discover] Fix expanding document when using saved search data grid #92999

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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 @@ -6,19 +6,27 @@
* Side Public License, v 1.
*/

import * as React from 'react';
import React, { useState } from 'react';
import { I18nProvider } from '@kbn/i18n/react';
import { DiscoverGrid, DiscoverGridProps } from './discover_grid/discover_grid';
import { getServices } from '../../kibana_services';
import { ElasticSearchHit } from '../doc_views/doc_views_types';

export const DataGridMemoized = React.memo((props: DiscoverGridProps) => (
<DiscoverGrid {...props} />
));

export function DiscoverGridEmbeddable(props: DiscoverGridProps) {
const [expandedDoc, setExpandedDoc] = useState<ElasticSearchHit | undefined>(undefined);

return (
<I18nProvider>
<DataGridMemoized {...props} services={getServices()} />
<DataGridMemoized
{...props}
setExpandedDoc={setExpandedDoc}
expandedDoc={expandedDoc}
services={getServices()}
/>
</I18nProvider>
);
}
Expand Down
36 changes: 23 additions & 13 deletions test/functional/apps/dashboard/embeddable_data_grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const find = getService('find');
const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'timePicker', 'discover']);
const retry = getService('retry');
const dataGrid = getService('dataGrid');

describe('dashboard embeddable data grid', () => {
before(async () => {
Expand All @@ -31,22 +33,30 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.dashboard.gotoDashboardLandingPage();
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.timePicker.setDefaultDataRange();
await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search');
});

describe('saved search filters', function () {
it('are added when a cell filter is clicked', async function () {
await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search');
await find.clickByCssSelector(`[role="gridcell"]:nth-child(3)`);
// needs a short delay between becoming visible & being clickable
await PageObjects.common.sleep(250);
await find.clickByCssSelector(`[data-test-subj="filterOutButton"]`);
await PageObjects.header.waitUntilLoadingHasFinished();
await find.clickByCssSelector(`[role="gridcell"]:nth-child(3)`);
await PageObjects.common.sleep(250);
await find.clickByCssSelector(`[data-test-subj="filterForButton"]`);
const filterCount = await filterBar.getFilterCount();
expect(filterCount).to.equal(2);
it('should expand the detail row when the toggle arrow is clicked', async function () {
await retry.try(async function () {
await dataGrid.clickRowToggle({ isAnchorRow: false, rowIndex: 0 });
const detailsEl = await dataGrid.getDetailsRows();
const defaultMessageEl = await detailsEl[0].findByTestSubject('docTableRowDetailsTitle');
expect(defaultMessageEl).to.be.ok();
await dataGrid.closeFlyout();
});
});

it('are added when a cell filter is clicked', async function () {
await find.clickByCssSelector(`[role="gridcell"]:nth-child(3)`);
// needs a short delay between becoming visible & being clickable
await PageObjects.common.sleep(250);
await find.clickByCssSelector(`[data-test-subj="filterOutButton"]`);
await PageObjects.header.waitUntilLoadingHasFinished();
await find.clickByCssSelector(`[role="gridcell"]:nth-child(3)`);
await PageObjects.common.sleep(250);
await find.clickByCssSelector(`[data-test-subj="filterForButton"]`);
const filterCount = await filterBar.getFilterCount();
expect(filterCount).to.equal(2);
});
});
}