Skip to content

Commit

Permalink
fix bug when redirecting to SO management with a tag having whitespac…
Browse files Browse the repository at this point in the history
…es in its name
  • Loading branch information
pgayvallet committed Dec 1, 2020
1 parent e32e0fd commit 385bab9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ describe('getTagConnectionsUrl', () => {
it('appends the basePath to the generated url', () => {
const tag = createTag('myTag');
expect(getTagConnectionsUrl(tag, httpMock.basePath)).toMatchInlineSnapshot(
`"/my-base-path/app/management/kibana/objects?initialQuery=tag%3A(myTag)"`
`"/my-base-path/app/management/kibana/objects?initialQuery=tag%3A(%22myTag%22)"`
);
});

it('escapes the query', () => {
const tag = createTag('tag with spaces');
expect(getTagConnectionsUrl(tag, httpMock.basePath)).toMatchInlineSnapshot(
`"/my-base-path/app/management/kibana/objects?initialQuery=tag%3A(tag%20with%20spaces)"`
`"/my-base-path/app/management/kibana/objects?initialQuery=tag%3A(%22tag%20with%20spaces%22)"`
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ import { TagWithRelations } from '../../../common/types';
* already selected in the query/filter bar.
*/
export const getTagConnectionsUrl = (tag: TagWithRelations, basePath: IBasePath) => {
const query = encodeURIComponent(`tag:(${tag.name})`);
const query = encodeURIComponent(`tag:("${tag.name}")`);
return basePath.prepend(`/app/management/kibana/objects?initialQuery=${query}`);
};
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await PageObjects.common.waitUntilUrlIncludes('/app/management/kibana/objects');
await PageObjects.savedObjects.waitTableIsLoaded();

expect(await PageObjects.savedObjects.getCurrentSearchValue()).to.eql('tag:(tag-1)');
expect(await PageObjects.savedObjects.getCurrentSearchValue()).to.eql('tag:("tag-1")');
expect(await PageObjects.savedObjects.getRowTitles()).to.eql([
'Visualization 1 (tag-1)',
'Visualization 3 (tag-1 + tag-3)',
Expand Down

0 comments on commit 385bab9

Please sign in to comment.