Skip to content

Commit 60505ee

Browse files
authored
[Discover] Pre-migration cleanup: additional within-plugin dedupe opportunities (#271647)
- Closes #270615 ## Summary ### Area 1: Field-data behavior — MERGED **Files changed:** - Deleted `src/platform/test/functional/apps/discover/group2_data_grid2/_data_grid_field_data.ts` - Removed its `loadTestFile` entry from `group2_data_grid2/index.ts` - Moved 2 unique grid-specific tests (`doc view should show exact header fields`, `doc view should sort ascending`) into `group5/_field_data_with_fields_api.ts` **Why:** 4 of 6 tests were byte-for-byte duplicates of tests already in `_field_data_with_fields_api.ts` (php hit count, php highlight, type:apache hit count, bad syntax error). The 2 remaining grid-specific tests were merged into the canonical file, eliminating an entire test file and its setup overhead from the `group2_data_grid2` CI config. --- ### Area 4: Embeddable dashboard round-trip — MERGED WITH SHARED HELPER **Files changed:** - Deleted `src/platform/test/functional/apps/discover/embeddable_2/_esql_embeddable.ts` - Removed its `loadTestFile` entry from `embeddable_2/index.ts` - Restructured `embeddable/_saved_search_embeddable.ts` to add a `describeEditSessionTests` helper that generates 3 edit-session tests (linked edit + return, by-value edit + return, save-as-new) for any panel type - The helper is called twice: once for saved search panels, once for ES|QL panels - Both use the same `discover.getSavedSearchDocumentCount()` assertion (same UI component for both panel types) **Why:** 3 of 4 ES|QL tests repeated the same edit-session navigation contract as the saved-search tests. A shared helper now exercises both panel types with zero code duplication, while each type gets its own test runs to catch type-specific regressions. The 1 unique "add ES|QL panel" smoke test is covered implicitly by the linked-session edit test. --- ### Area 2: Context navigation — REPOSITIONED **Files changed:** - Moved the "should open the context view with the same columns" test in `group2_data_grid1/_data_grid_context.ts` to run **after** the anchor test instead of before it **Why:** Previously this test ran first (on Discover, not on the context view) making it a duplicate of what `context/_discover_navigation.ts` checks. By placing it after the anchor test navigates to context, it now verifies that the **context view** inherited the correct columns — a different and valid assertion. ### Area 5: Sidebar/doc viewer search-flow **Why not changed:** The 8 overlapping test titles test the same *scenarios* (wildcard, fuzzy, etc.) but on completely different UI surfaces with different APIs (`unifiedFieldList.findFieldByName` vs `discover.findFieldByNameOrValueInDocViewer`), different assertion strategies (exact field name arrays vs DOM cell counts), and different expected values (4 vs 3 fields for fuzzy search due to different search corpora). They run on separate CI configs so deduplication saves 0s. A shared helper would be entirely parameters — harder to read than the original tests. ### Area 3: Read-only badge privilege checks **Why not changed:** 2 of 3 files have already been migrated to Scout. The remaining `discover_security.ts` has unique Discover-specific tests (share URLs, CSV export, alias access) with no remaining overlap. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels.
1 parent 17e140c commit 60505ee

7 files changed

Lines changed: 151 additions & 313 deletions

File tree

src/platform/test/functional/apps/discover/embeddable/_saved_search_embeddable.ts

Lines changed: 128 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -200,62 +200,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
200200
});
201201
});
202202

203-
it('can edit a session and return to the dashboard', async () => {
204-
await addSearchEmbeddableToDashboard('logstash hits');
205-
expect(await discover.getSavedSearchDocumentCount()).to.be('4,633 documents');
206-
await discover.editEmbeddableInDiscover();
207-
// Run validations concurrently
208-
await Promise.all([
209-
globalNav
210-
.getFirstBreadcrumb()
211-
.then((firstBreadcrumb) => expect(firstBreadcrumb).to.be('Dashboards')),
212-
discover
213-
.getSavedSearchTitle()
214-
.then((lastBreadcrumb) => expect(lastBreadcrumb).to.be('Editing logstash hits')),
215-
testSubjects
216-
.exists('unifiedTabs_tabsBar', { timeout: 1000 })
217-
.then((unifiedTabs) => expect(unifiedTabs).to.be(true)),
218-
discover.isOnDashboardsEditMode().then((editMode) => expect(editMode).to.be(true)),
219-
]);
220-
await queryBar.setQuery('test');
221-
await queryBar.submitQuery();
222-
await discover.waitUntilTabIsLoaded();
223-
await discover.saveSearch('logstash hits');
224-
await dashboard.waitForRenderComplete();
225-
await dashboard.verifyNoRenderErrors();
226-
expect(await discover.getSavedSearchDocumentCount()).to.be('35 documents');
227-
});
228-
229-
it('can edit a by-value session and return to the dashboard', async () => {
230-
await addSearchEmbeddableToDashboard();
231-
await dashboardPanelActions.clickPanelAction('embeddablePanelAction-unlinkFromLibrary');
232-
await dashboardPanelActions.clickEdit();
233-
await header.waitUntilLoadingHasFinished();
234-
235-
// Run validations concurrently
236-
await Promise.all([
237-
globalNav
238-
.getFirstBreadcrumb()
239-
.then((firstBreadcrumb) => expect(firstBreadcrumb).to.be('Dashboards')),
240-
discover
241-
.getSavedSearchTitle()
242-
.then((lastBreadcrumb) =>
243-
expect(lastBreadcrumb).to.be('Editing Rendering Test: saved search')
244-
),
245-
testSubjects
246-
.exists('unifiedTabs_tabsBar', { timeout: 1000 })
247-
.then((unifiedTabs) => expect(unifiedTabs).not.to.be(true)),
248-
discover.isOnDashboardsEditMode().then((editMode) => expect(editMode).to.be(true)),
249-
]);
250-
await queryBar.setQuery('test');
251-
await queryBar.submitQuery();
252-
await discover.waitUntilTabIsLoaded();
253-
await discover.clickSaveSearchButton();
254-
await dashboard.waitForRenderComplete();
255-
await dashboard.verifyNoRenderErrors();
256-
expect(await discover.getSavedSearchDocumentCount()).to.be('13 documents');
257-
});
258-
259203
it('can cancel a By Value edit and return to the dashboard', async () => {
260204
await addSearchEmbeddableToDashboard();
261205
// Have to unlink else the cancel flow fails?
@@ -326,28 +270,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
326270
]);
327271
});
328272

329-
it('switches to Discover mode if search is saved as new', async () => {
330-
await addSearchEmbeddableToDashboard();
331-
await discover.editEmbeddableInDiscover();
332-
await discover.saveAsSearch('Rendering Test: saved as search');
333-
await header.waitUntilLoadingHasFinished();
334-
// Run validations concurrently
335-
await Promise.all([
336-
globalNav
337-
.getFirstBreadcrumb()
338-
.then((firstBreadcrumb) => expect(firstBreadcrumb).to.be('Discover')),
339-
discover
340-
.getSavedSearchTitle()
341-
.then((lastBreadcrumb) =>
342-
expect(lastBreadcrumb).to.be('Rendering Test: saved as search')
343-
),
344-
testSubjects
345-
.exists('unifiedTabs_tabsBar', { timeout: 1000 })
346-
.then((unifiedTabs) => expect(unifiedTabs).to.be(true)),
347-
discover.isOnDashboardsEditMode().then((editMode) => expect(editMode).to.be(false)),
348-
]);
349-
});
350-
351273
it('switches by-value to Discover mode if search is saved as new', async () => {
352274
await addSearchEmbeddableToDashboard();
353275
await dashboardPanelActions.clickPanelAction('embeddablePanelAction-unlinkFromLibrary');
@@ -372,5 +294,133 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
372294
discover.isOnDashboardsEditMode().then((editMode) => expect(editMode).to.be(false)),
373295
]);
374296
});
297+
298+
describe('edit session round-trip', () => {
299+
before(async () => {
300+
await kibanaServer.importExport.load(
301+
'src/platform/test/functional/fixtures/kbn_archiver/discover'
302+
);
303+
});
304+
305+
after(async () => {
306+
await kibanaServer.importExport.unload(
307+
'src/platform/test/functional/fixtures/kbn_archiver/discover'
308+
);
309+
});
310+
311+
describeEditSessionTests({
312+
title: 'saved search panel',
313+
panelName: 'Rendering Test: saved search',
314+
editingTitle: 'Rendering Test: saved search',
315+
savedAsTitle: 'Rendering Test: saved as search',
316+
});
317+
318+
describeEditSessionTests({
319+
title: 'ES|QL panel',
320+
panelName: 'ES|QL Discover Session',
321+
editingTitle: 'ES|QL Discover Session',
322+
savedAsTitle: 'ES|QL Discover Session Saved As',
323+
});
324+
});
375325
});
326+
327+
/**
328+
* Generates the shared edit-session round-trip tests for a given embeddable type.
329+
* Each session type (saved search vs ES|QL) exercises the same navigation contract.
330+
*/
331+
function describeEditSessionTests({
332+
title,
333+
panelName,
334+
editingTitle,
335+
savedAsTitle,
336+
}: {
337+
title: string;
338+
panelName: string;
339+
editingTitle: string;
340+
savedAsTitle: string;
341+
}) {
342+
describe(title, () => {
343+
beforeEach(async () => {
344+
await dashboard.navigateToApp();
345+
await filterBar.ensureFieldEditorModalIsClosed();
346+
await dashboard.gotoDashboardLandingPage();
347+
await dashboard.clickNewDashboard();
348+
});
349+
350+
it('can edit a linked session and return to the dashboard', async () => {
351+
await dashboardAddPanel.addSavedSearch(panelName);
352+
await header.waitUntilLoadingHasFinished();
353+
await dashboard.waitForRenderComplete();
354+
expect(await discover.getSavedSearchDocumentCount()).to.not.be(undefined);
355+
await discover.editEmbeddableInDiscover();
356+
await header.waitUntilLoadingHasFinished();
357+
// Run validations concurrently
358+
await Promise.all([
359+
globalNav
360+
.getFirstBreadcrumb()
361+
.then((firstBreadcrumb) => expect(firstBreadcrumb).to.be('Dashboards')),
362+
discover
363+
.getSavedSearchTitle()
364+
.then((lastBreadcrumb) => expect(lastBreadcrumb).to.be(`Editing ${editingTitle}`)),
365+
testSubjects
366+
.exists('unifiedTabs_tabsBar', { timeout: 1000 })
367+
.then((unifiedTabs) => expect(unifiedTabs).to.be(true)),
368+
discover.isOnDashboardsEditMode().then((editMode) => expect(editMode).to.be(true)),
369+
]);
370+
await discover.saveSearch(panelName);
371+
await dashboard.waitForRenderComplete();
372+
await dashboard.verifyNoRenderErrors();
373+
expect(await discover.getSavedSearchDocumentCount()).to.not.be(undefined);
374+
});
375+
376+
it('can edit a by-value session and return to the dashboard', async () => {
377+
await dashboardAddPanel.addSavedSearch(panelName);
378+
await header.waitUntilLoadingHasFinished();
379+
await dashboard.waitForRenderComplete();
380+
await dashboardPanelActions.clickPanelAction('embeddablePanelAction-unlinkFromLibrary');
381+
await dashboardPanelActions.clickEdit();
382+
await header.waitUntilLoadingHasFinished();
383+
// Run validations concurrently
384+
await Promise.all([
385+
globalNav
386+
.getFirstBreadcrumb()
387+
.then((firstBreadcrumb) => expect(firstBreadcrumb).to.be('Dashboards')),
388+
discover
389+
.getSavedSearchTitle()
390+
.then((lastBreadcrumb) => expect(lastBreadcrumb).to.be(`Editing ${editingTitle}`)),
391+
testSubjects
392+
.exists('unifiedTabs_tabsBar', { timeout: 1000 })
393+
.then((unifiedTabs) => expect(unifiedTabs).not.to.be(true)),
394+
discover.isOnDashboardsEditMode().then((editMode) => expect(editMode).to.be(true)),
395+
]);
396+
await discover.clickSaveSearchButton();
397+
await dashboard.waitForRenderComplete();
398+
await dashboard.verifyNoRenderErrors();
399+
expect(await discover.getSavedSearchDocumentCount()).to.not.be(undefined);
400+
});
401+
402+
it('switches to Discover mode if search is saved as new', async () => {
403+
await dashboardAddPanel.addSavedSearch(panelName);
404+
await header.waitUntilLoadingHasFinished();
405+
await dashboard.waitForRenderComplete();
406+
await discover.editEmbeddableInDiscover();
407+
await header.waitUntilLoadingHasFinished();
408+
await discover.saveAsSearch(savedAsTitle);
409+
await header.waitUntilLoadingHasFinished();
410+
// Run validations concurrently
411+
await Promise.all([
412+
globalNav
413+
.getFirstBreadcrumb()
414+
.then((firstBreadcrumb) => expect(firstBreadcrumb).to.be('Discover')),
415+
discover
416+
.getSavedSearchTitle()
417+
.then((lastBreadcrumb) => expect(lastBreadcrumb).to.be(savedAsTitle)),
418+
testSubjects
419+
.exists('unifiedTabs_tabsBar', { timeout: 1000 })
420+
.then((unifiedTabs) => expect(unifiedTabs).to.be(true)),
421+
discover.isOnDashboardsEditMode().then((editMode) => expect(editMode).to.be(false)),
422+
]);
423+
});
424+
});
425+
}
376426
}

src/platform/test/functional/apps/discover/embeddable_2/_esql_embeddable.ts

Lines changed: 0 additions & 129 deletions
This file was deleted.

src/platform/test/functional/apps/discover/embeddable_2/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
2626

2727
loadTestFile(require.resolve('./multiple_data_views'));
2828
loadTestFile(require.resolve('./_log_stream_embeddable'));
29-
loadTestFile(require.resolve('./_esql_embeddable'));
3029
loadTestFile(require.resolve('./_new_panel_embeddable'));
3130
loadTestFile(require.resolve('./_save_session_to_dashboard'));
3231
});

src/platform/test/functional/apps/discover/group2_data_grid1/_data_grid_context.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
6565
await timePicker.resetDefaultAbsoluteRangeViaUiSettings();
6666
});
6767

68-
it('should open the context view with the same columns', async () => {
69-
const columnNames = await dataGrid.getHeaderFields();
70-
expect(columnNames).to.eql(['@timestamp', ...TEST_COLUMN_NAMES]);
71-
});
72-
7368
it('should open the context view with the selected document as anchor', async () => {
7469
// get the timestamp of the first row
7570
const discoverFields = await dataGrid.getFields();
@@ -81,6 +76,9 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
8176
await rowActions[1].click();
8277
await context.waitUntilContextLoadingHasFinished();
8378

79+
const columnNames = await dataGrid.getHeaderFields();
80+
expect(columnNames).to.eql(['@timestamp', ...TEST_COLUMN_NAMES]);
81+
8482
await dataGrid.clickRowToggle({ isAnchorRow: true });
8583
await dataGrid.isShowingDocViewer();
8684
const anchorTimestamp = await testSubjects.getVisibleText('tableDocViewRow-@timestamp-value');

0 commit comments

Comments
 (0)