diff --git a/test/automation/src/sql/notebook.ts b/test/automation/src/sql/notebook.ts index 39e3380775..0e85b52775 100644 --- a/test/automation/src/sql/notebook.ts +++ b/test/automation/src/sql/notebook.ts @@ -68,10 +68,10 @@ export class Notebook { await this.code.waitForActiveElement(textarea); await this.code.waitForTypeInEditor(textarea, text); - await this._waitForActiveCellEditorContents(c => c.indexOf(text) > -1); + await this.waitForActiveCellEditorContents(c => c.indexOf(text) > -1); } - private async _waitForActiveCellEditorContents(accept: (contents: string) => boolean): Promise { + async waitForActiveCellEditorContents(accept: (contents: string) => boolean): Promise { const selector = '.notebook-cell.active .monaco-editor .view-lines'; return this.code.waitForTextContent(selector, undefined, c => accept(c.replace(/\u00a0/g, ' '))); } @@ -81,9 +81,18 @@ export class Notebook { await this.code.waitForElement(span); } + public async selectAllTextInRichTextEditor(): Promise { + const editor = '.notebook-cell.active .notebook-preview[contenteditable="true"]'; + await this.selectAllText(editor); + } + public async selectAllTextInEditor(): Promise { const editor = '.notebook-cell.active .monaco-editor'; - await this.code.waitAndClick(editor); + await this.selectAllText(editor); + } + + private async selectAllText(selector: string): Promise { + await this.code.waitAndClick(selector); await this.code.dispatchKeybinding(ctrlOrCmd + '+a'); } diff --git a/test/smoke/src/sql/areas/notebook/notebook.test.ts b/test/smoke/src/sql/areas/notebook/notebook.test.ts index 860455e40b..d1db02946b 100644 --- a/test/smoke/src/sql/areas/notebook/notebook.test.ts +++ b/test/smoke/src/sql/areas/notebook/notebook.test.ts @@ -326,6 +326,7 @@ export function setup(opts: minimist.ParsedArgs) { const linkSelector = '.notebook-cell.active .notebook-text a[href=\'http://www.microsoft.com\']'; await verifyElementRendered(app, markdownString, linkSelector); }); + it('can create img from markdown', async function () { const app = this.app as Application; const markdownString = '![Churn-Index](https://www.ngdata.com/wp-content/uploads/2016/05/churn.jpg)'; @@ -333,6 +334,24 @@ export function setup(opts: minimist.ParsedArgs) { const imgSelector = '.notebook-cell.active .notebook-text img[src=\'https://www.ngdata.com/wp-content/uploads/2016/05/churn.jpg\'][alt=\'Churn-Index\']'; await verifyElementRendered(app, markdownString, imgSelector); }); + + it('can convert WYSIWYG to Markdown', async function () { + const app = this.app as Application; + await app.workbench.sqlNotebook.newUntitledNotebook(); + await app.workbench.sqlNotebook.addCellFromPlaceholder('Markdown'); + await app.workbench.sqlNotebook.waitForPlaceholderGone(); + await app.workbench.sqlNotebook.textCellToolbar.changeTextCellView('Markdown View'); + await app.workbench.sqlNotebook.waitForTypeInEditor('Markdown Test'); + await app.workbench.sqlNotebook.textCellToolbar.changeTextCellView('Rich Text View'); + await app.workbench.sqlNotebook.selectAllTextInRichTextEditor(); + await app.workbench.sqlNotebook.textCellToolbar.boldSelectedText(); + await app.workbench.sqlNotebook.textCellToolbar.italicizeSelectedText(); + await app.workbench.sqlNotebook.textCellToolbar.underlineSelectedText(); + await app.workbench.sqlNotebook.textCellToolbar.highlightSelectedText(); + await app.workbench.sqlNotebook.textCellToolbar.insertList(); + await app.workbench.sqlNotebook.textCellToolbar.changeTextCellView('Markdown View'); + await app.workbench.sqlNotebook.waitForActiveCellEditorContents(s => s.includes('- **_Markdown Test_**')); + }); }); describe('Cell Actions', function () {