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 context view for document ids containing special characters #122737

Merged
merged 5 commits into from
Jan 14, 2022
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 @@ -152,7 +152,7 @@ export const ContextApp = ({ indexPattern, anchorId }: ContextAppProps) => {
<EuiPage className={classNames({ dscDocsPage: !isLegacy })}>
<EuiPageContent paddingSize="s" className="dscDocsContent">
<EuiSpacer size="s" />
<EuiText>
<EuiText data-test-subj="contextDocumentSurroundingHeader">
<strong>
<FormattedMessage
id="discover.context.contextOfTitle"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function ContextAppRoute(props: DiscoverRouteProps) {
const { chrome } = services;

const { indexPatternId, id } = useParams<ContextUrlParams>();
const anchorId = decodeURIComponent(id);
const breadcrumb = useMainRouteBreadcrumb();

useEffect(() => {
Expand Down Expand Up @@ -68,5 +69,5 @@ export function ContextAppRoute(props: DiscoverRouteProps) {
return <LoadingIndicator />;
}

return <ContextApp anchorId={id} indexPattern={indexPattern} />;
return <ContextApp anchorId={anchorId} indexPattern={indexPattern} />;
}
55 changes: 55 additions & 0 deletions test/functional/apps/discover/_context_encoded_url_param.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const dataGrid = getService('dataGrid');
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['common', 'discover', 'timePicker', 'settings', 'header']);
const testSubjects = getService('testSubjects');
const es = getService('es');

describe('context encoded id param', () => {
before(async function () {
await PageObjects.common.navigateToApp('settings');
await es.transport.request({
path: '/includes-plus-symbol-doc-id/_doc/1+1=2',
method: 'PUT',
body: {
username: 'matt',
'@timestamp': '2015-09-21T09:30:23',
},
});
await PageObjects.settings.createIndexPattern('includes-plus-symbol-doc-id');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't have this way to create testdata on the radar, TIL. only disadvantage is, that it might be slower, more UI interaction needed to create the required testing data but, fine with that.
only nit: username should be Dmitry, the matt you are mentioning here just added comments here, else he was lazy as usual 😄.


await kibanaServer.uiSettings.update({ 'doc_table:legacy': false });
await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings();
await PageObjects.common.navigateToApp('discover');
});

it('should navigate to context page correctly', async () => {
await PageObjects.discover.selectIndexPattern('includes-plus-symbol-doc-id');
await PageObjects.header.waitUntilLoadingHasFinished();

// navigate to the context view
await dataGrid.clickRowToggle({ rowIndex: 0 });
const [, surroundingActionEl] = await dataGrid.getRowActions({
isAnchorRow: false,
rowIndex: 0,
});
await surroundingActionEl.click();
await PageObjects.header.waitUntilLoadingHasFinished();

const headerElement = await testSubjects.find('contextDocumentSurroundingHeader');

expect(await headerElement.getVisibleText()).to.be('Documents surrounding #1+1=2');
});
});
}
1 change: 1 addition & 0 deletions test/functional/apps/discover/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,6 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./_date_nested'));
loadTestFile(require.resolve('./_search_on_page_load'));
loadTestFile(require.resolve('./_chart_hidden'));
loadTestFile(require.resolve('./_context_encoded_url_param'));
});
}