Fix navigating from discover single document view back to discover (#92463) (#92637)

This commit is contained in:
Anton Dosov 2021-02-24 18:20:12 +01:00 committed by GitHub
parent 3a40c92458
commit 9ef5f01872
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 2 deletions

View file

@ -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

View file

@ -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 () => {
@ -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();
});
});
}