Skip to content

Commit

Permalink
Fix navigating from discover single document view back to discover (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosant authored Feb 24, 2021
1 parent 0571764 commit e3eaa97
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/plugins/discover/public/kibana_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,17 @@ export const [getUrlTracker, setUrlTracker] = createGetterSetter<{
export const [getDocViewsRegistry, setDocViewsRegistry] = createGetterSetter<DocViewsRegistry>(
'DocViewsRegistry'
);

/**
* Makes sure discover and context are using one instance of history.
*/
export const getHistory = _.once(() => createHashHistory());
export const getHistory = _.once(() => {
const history = createHashHistory();
history.listen(() => {
// keep at least one listener so that `history.location` always in sync
});
return history;
});

/**
* Discover currently uses two `history` instances: one from Kibana Platform and
Expand Down
27 changes: 26 additions & 1 deletion test/functional/apps/context/_discover_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export default function ({ getService, getPageObjects }) {
const retry = getService('retry');
const docTable = getService('docTable');
const filterBar = getService('filterBar');
const PageObjects = getPageObjects(['common', 'discover', 'timePicker']);
const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'context']);
const testSubjects = getService('testSubjects');

describe('context link in discover', () => {
before(async () => {
Expand Down Expand Up @@ -69,5 +70,29 @@ export default function ({ getService, getPageObjects }) {
}
expect(disabledFilterCounter).to.be(TEST_FILTER_COLUMN_NAMES.length);
});

// bugfix: https://github.com/elastic/kibana/issues/92099
it('should navigate to the first document and then back to discover', async () => {
await PageObjects.context.waitUntilContextLoadingHasFinished();

// navigate to the doc view
await docTable.clickRowToggle({ rowIndex: 0 });

// click the open action
await retry.try(async () => {
const rowActions = await docTable.getRowActions({ rowIndex: 0 });
if (!rowActions.length) {
throw new Error('row actions empty, trying again');
}
await rowActions[1].click();
});

const hasDocHit = await testSubjects.exists('doc-hit');
expect(hasDocHit).to.be(true);

await testSubjects.click('breadcrumb first');
await PageObjects.discover.waitForDiscoverAppOnScreen();
await PageObjects.discover.waitForDocTableLoadingComplete();
});
});
}

0 comments on commit e3eaa97

Please sign in to comment.