mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.16`: - [[Console] Avoid duplicate suggestions in autocomplete (#201766)](https://github.com/elastic/kibana/pull/201766) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Ignacio Rivas","email":"rivasign@gmail.com"},"sourceCommit":{"committedDate":"2024-11-29T11:58:39Z","message":"[Console] Avoid duplicate suggestions in autocomplete (#201766)","sha":"82de734e6c7b67d90213b7058b1109f9f375710e","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana Management","release_note:skip","backport missing","v9.0.0","backport:prev-minor","v8.16.0","v8.17.0"],"number":201766,"url":"https://github.com/elastic/kibana/pull/201766","mergeCommit":{"message":"[Console] Avoid duplicate suggestions in autocomplete (#201766)","sha":"82de734e6c7b67d90213b7058b1109f9f375710e"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.17"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201766","number":201766,"mergeCommit":{"message":"[Console] Avoid duplicate suggestions in autocomplete (#201766)","sha":"82de734e6c7b67d90213b7058b1109f9f375710e"}},{"branch":"8.16","label":"v8.16.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
This commit is contained in:
parent
2faee8a967
commit
2670a3fad1
2 changed files with 30 additions and 3 deletions
|
@ -119,7 +119,7 @@ export function populateContext(tokenPath, context, editor, includeAutoComplete,
|
|||
editor
|
||||
);
|
||||
if (includeAutoComplete) {
|
||||
let autoCompleteSet = [];
|
||||
let autoCompleteSet = new Map();
|
||||
_.each(walkStates, function (ws) {
|
||||
const contextForState = passThroughContext(context, ws.contextExtensionList);
|
||||
_.each(ws.components, function (component) {
|
||||
|
@ -127,11 +127,16 @@ export function populateContext(tokenPath, context, editor, includeAutoComplete,
|
|||
if (!_.isObject(term)) {
|
||||
term = { name: term };
|
||||
}
|
||||
autoCompleteSet.push(term);
|
||||
|
||||
// Add the term to the autoCompleteSet if it doesn't already exist
|
||||
if (!autoCompleteSet.has(term.name)) {
|
||||
autoCompleteSet.set(term.name, term);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
autoCompleteSet = _.uniq(autoCompleteSet);
|
||||
// Convert Map values to an array of objects
|
||||
autoCompleteSet = Array.from(autoCompleteSet.values());
|
||||
context.autoCompleteSet = autoCompleteSet;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,28 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await PageObjects.console.clearEditorText();
|
||||
});
|
||||
|
||||
it('should not show duplicate suggestions', async () => {
|
||||
await PageObjects.console.enterText(`POST _ingest/pipeline/_simulate
|
||||
{
|
||||
"pipeline": {
|
||||
"processors": [
|
||||
{
|
||||
"script": {`);
|
||||
await PageObjects.console.pressEnter();
|
||||
await PageObjects.console.sleepForDebouncePeriod();
|
||||
await PageObjects.console.enterText(`"`);
|
||||
expect(PageObjects.console.isAutocompleteVisible()).to.be.eql(true);
|
||||
|
||||
// Iterate on the first 10 suggestions (the ones that are only visible without scrolling)
|
||||
const suggestions = [];
|
||||
for (let i = 0; i < 10; i++) {
|
||||
suggestions.push(await PageObjects.console.getAutocompleteSuggestion(i));
|
||||
}
|
||||
|
||||
// and expect the array to not have duplicates
|
||||
expect(suggestions).to.eql(_.uniq(suggestions));
|
||||
});
|
||||
|
||||
it('HTTP methods', async () => {
|
||||
const suggestions = {
|
||||
G: ['GET'],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue