From 7c14ec2b6da1542d95f45ec7d40bbc8cf62fc504 Mon Sep 17 00:00:00 2001 From: Lucy Zhang Date: Tue, 27 Jul 2021 11:02:52 -0700 Subject: [PATCH] Add intellisense checks in code cell smoke test (#16362) * check colorization and completion suggestions * check for suggestions widget * make selector more specific --- test/automation/src/sql/notebook.ts | 17 +++++++++++++++++ .../src/sql/areas/notebook/notebook.test.ts | 19 +++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/test/automation/src/sql/notebook.ts b/test/automation/src/sql/notebook.ts index 5aaa257dd1..67369efb9b 100644 --- a/test/automation/src/sql/notebook.ts +++ b/test/automation/src/sql/notebook.ts @@ -75,6 +75,11 @@ export class Notebook { return this.code.waitForTextContent(selector, undefined, c => accept(c.replace(/\u00a0/g, ' '))); } + async waitForColorization(spanNumber: string, color: string): Promise { + const span = `span:nth-child(${spanNumber})[class="${color}"]`; + await this.code.waitForElement(span); + } + public async selectAllTextInEditor(): Promise { const editor = '.notebook-cell.active .monaco-editor'; await this.code.waitAndClick(editor); @@ -115,6 +120,18 @@ export class Notebook { return (await this.code.waitForElements('div.notebook-cell', false)).map(cell => cell.attributes['id']); } + // Code Cell Actions + + async waitForSuggestionWidget(): Promise { + const suggestionWidgetSelector = 'div.editor-widget.suggest-widget'; + await this.code.waitForElement(suggestionWidgetSelector); + } + + async waitForSuggestionResult(expectedResult: string): Promise { + const expectedResultSelector = `div.editor-widget.suggest-widget div.monaco-list-row.focused[aria-label="${expectedResult}"]`; + await this.code.waitForElement(expectedResultSelector); + } + // Text Cell Actions private static readonly textCellPreviewSelector = 'div.notebook-preview'; diff --git a/test/smoke/src/sql/areas/notebook/notebook.test.ts b/test/smoke/src/sql/areas/notebook/notebook.test.ts index 19eae61d0a..2c78849a5e 100644 --- a/test/smoke/src/sql/areas/notebook/notebook.test.ts +++ b/test/smoke/src/sql/areas/notebook/notebook.test.ts @@ -31,11 +31,26 @@ export function setup() { it('can perform basic code cell functionality', async function () { const app = this.app as Application; await app.workbench.sqlNotebook.newUntitledNotebook(); + await app.workbench.sqlNotebook.notebookToolbar.waitForKernel('SQL'); await app.workbench.sqlNotebook.addCellFromPlaceholder('Code'); await app.workbench.sqlNotebook.waitForPlaceholderGone(); - const sampleText: string = 'SELECT * FROM sys.tables'; - await app.workbench.sqlNotebook.waitForTypeInEditor(sampleText); + const text1: string = 'SEL'; + await app.workbench.sqlNotebook.waitForTypeInEditor(text1); + await app.code.dispatchKeybinding('ctrl+space bar'); + + // check for completion suggestions + await app.workbench.sqlNotebook.waitForSuggestionWidget(); + await app.workbench.sqlNotebook.waitForSuggestionResult('SELECT'); + await app.code.dispatchKeybinding('tab'); + + const text2: string = ' * FROM employees'; + await app.workbench.sqlNotebook.waitForTypeInEditor(text2); + + await app.workbench.sqlNotebook.waitForColorization('1', 'mtk5'); // SELECT + await app.workbench.sqlNotebook.waitForColorization('3', 'mtk13'); // * + await app.workbench.sqlNotebook.waitForColorization('5', 'mtk5'); // FROM + await app.workbench.sqlNotebook.waitForColorization('6', 'mtk1'); // employees }); // Python Notebooks