[8.11] [UnifiedSearch] Reduce length for filter badge id (#170439) (#170627)

# Backport

This will backport the following commits from `main` to `8.11`:
- [[UnifiedSearch] Reduce length for filter badge id
(#170439)](https://github.com/elastic/kibana/pull/170439)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Marco
Liberati","email":"dej611@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-11-06T10:59:55Z","message":"[UnifiedSearch]
Reduce length for filter badge id (#170439)\n\n## Summary\r\n\r\nThis PR
aims to reduce the possible long length of filter badge test
id.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4053f711b1bd0308bbacb32dad4762b1791cdec5","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Visualizations","release_note:skip","Feature:Unified
search","backport:prev-minor","v8.12.0","v8.11.1"],"number":170439,"url":"https://github.com/elastic/kibana/pull/170439","mergeCommit":{"message":"[UnifiedSearch]
Reduce length for filter badge id (#170439)\n\n## Summary\r\n\r\nThis PR
aims to reduce the possible long length of filter badge test
id.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4053f711b1bd0308bbacb32dad4762b1791cdec5"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/170439","number":170439,"mergeCommit":{"message":"[UnifiedSearch]
Reduce length for filter badge id (#170439)\n\n## Summary\r\n\r\nThis PR
aims to reduce the possible long length of filter badge test
id.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"4053f711b1bd0308bbacb32dad4762b1791cdec5"}},{"branch":"8.11","label":"v8.11.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2023-11-06 07:33:30 -05:00 committed by GitHub
parent 1a65a4a1e0
commit 2487b92ade
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View file

@ -11,6 +11,7 @@ import { i18n } from '@kbn/i18n';
import React, { FC } from 'react';
import { Filter, isFilterPinned } from '@kbn/es-query';
import { DataView } from '@kbn/data-views-plugin/common';
import { stringHash } from '@kbn/ml-string-hash';
import type { FilterLabelStatus } from '../filter_item/filter_item';
import { FilterBadge } from '../../filter_badge';
@ -103,7 +104,7 @@ export const FilterView: FC<Props> = ({
hideAlias={hideAlias}
{...badgeProps}
{...rest}
data-test-subj={`filter-badge-'${innerText}' ${rest['data-test-subj']}`}
data-test-subj={`filter-badge-${stringHash(innerText || '')} ${rest['data-test-subj']}`}
/>
);

View file

@ -41,6 +41,7 @@
"@kbn/text-based-editor",
"@kbn/core-doc-links-browser",
"@kbn/core-lifecycle-browser",
"@kbn/ml-string-hash",
],
"exclude": [
"target/**/*",

View file

@ -5,6 +5,7 @@
* 2.0.
*/
import { stringHash } from '@kbn/ml-string-hash';
import { FtrProviderContext } from '../ftr_provider_context';
export function AssetDetailsProvider({ getService }: FtrProviderContext) {
@ -101,7 +102,9 @@ export function AssetDetailsProvider({ getService }: FtrProviderContext) {
async getMetadataAppliedFilter() {
const filter = await testSubjects.find(
"filter-badge-'host.architecture: arm64' filter filter-enabled filter-key-host.architecture filter-value-arm64 filter-unpinned filter-id-0"
`filter-badge-${stringHash(
'host.architecture: arm64'
)} filter filter-enabled filter-key-host.architecture filter-value-arm64 filter-unpinned filter-id-0`
);
return filter.getVisibleText();
},