Skip to content

Commit

Permalink
[Console] Fix index fields autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
yuliacech committed Jun 19, 2024
1 parent 9352437 commit 316e9a4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ export class IndexAutocompleteComponent extends ListComponent {
}
return !_.find(tokens, nonValidIndexType);
}

getDefaultTermMeta() {
return 'index';
}

getContextKey() {
return 'indices';
}
}
26 changes: 26 additions & 0 deletions test/functional/apps/console/monaco/_autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,5 +370,31 @@ GET _search
});
});
});

describe('index fields autocomplete', () => {
const indexName = `index_field_test-${Date.now()}-${Math.random()}`;

before(async () => {
await PageObjects.console.monaco.clearEditorText();
// create an index with only 1 field
await PageObjects.console.monaco.enterText(`PUT ${indexName}/_doc/1\n{\n"test":1\n}`);
await PageObjects.console.clickPlay();
});

after(async () => {
await PageObjects.console.monaco.clearEditorText();
// delete the test index
await PageObjects.console.monaco.enterText(`DELETE ${indexName}`);
await PageObjects.console.clickPlay();
});

it('fields autocomplete only shows fields of the index', async () => {
await PageObjects.console.monaco.clearEditorText();
await PageObjects.console.monaco.enterText('GET _search\n{\n"fields": ["');

expect(await PageObjects.console.monaco.getAutocompleteSuggestion(0)).to.be.eql('test');
expect(await PageObjects.console.monaco.getAutocompleteSuggestion(1)).to.be.eql(undefined);
});
});
});
}
6 changes: 5 additions & 1 deletion test/functional/page_objects/console_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ export class ConsolePageObject extends FtrService {
getAutocompleteSuggestion: async (index: number) => {
const suggestionsWidget = await this.find.byClassName('suggest-widget');
const suggestions = await suggestionsWidget.findAllByClassName('monaco-list-row');
const label = await suggestions[index].findByClassName('label-name');
const suggestion = suggestions[index];
if (!suggestion) {
return undefined;
}
const label = await suggestion.findByClassName('label-name');
return label.getVisibleText();
},
pressUp: async (shift: boolean = false) => {
Expand Down

0 comments on commit 316e9a4

Please sign in to comment.