diff --git a/test/automation/src/sql/notebook.ts b/test/automation/src/sql/notebook.ts index b0a0947e9c..5b12df7d0b 100644 --- a/test/automation/src/sql/notebook.ts +++ b/test/automation/src/sql/notebook.ts @@ -13,11 +13,13 @@ const winOrCtrl = process.platform === 'darwin' ? 'ctrl' : 'win'; export class Notebook { - public readonly toolbar: NotebookToolbar; + public readonly notebookToolbar: NotebookToolbar; + public readonly textCellToolbar: TextCellToolbar; public readonly view: NotebookView; constructor(private code: Code, private quickAccess: QuickAccess, private quickInput: QuickInput, private editors: Editors) { - this.toolbar = new NotebookToolbar(code); + this.notebookToolbar = new NotebookToolbar(code); + this.textCellToolbar = new TextCellToolbar(code); this.view = new NotebookView(code, quickAccess); } @@ -48,11 +50,11 @@ export class Notebook { } async changeKernel(kernel: string): Promise { - await this.toolbar.changeKernel(kernel); + await this.notebookToolbar.changeKernel(kernel); } async waitForKernel(kernel: string): Promise { - await this.toolbar.waitForKernel(kernel); + await this.notebookToolbar.waitForKernel(kernel); } async runActiveCell(): Promise { @@ -70,15 +72,15 @@ export class Notebook { } async trustNotebook(): Promise { - await this.toolbar.trustNotebook(); + await this.notebookToolbar.trustNotebook(); } async waitForTrustedIcon(): Promise { - await this.toolbar.waitForTrustedIcon(); + await this.notebookToolbar.waitForTrustedIcon(); } async waitForNotTrustedIcon(): Promise { - await this.toolbar.waitForNotTrustedIcon(); + await this.notebookToolbar.waitForNotTrustedIcon(); } // Cell Actions @@ -99,6 +101,12 @@ export class Notebook { return this.code.waitForTextContent(selector, undefined, c => accept(c.replace(/\u00a0/g, ' '))); } + public async selectAllTextInEditor(): Promise { + const editor = '.notebook-cell.active .monaco-editor'; + await this.code.waitAndClick(editor); + await this.code.dispatchKeybinding('ctrl+a'); + } + private static readonly placeholderSelector = 'div.placeholder-cell-component'; async addCellFromPlaceholder(cellType: 'Markdown' | 'Code'): Promise { await this.code.waitAndClick(`${Notebook.placeholderSelector} p a[id="add${cellType}"]`); @@ -126,14 +134,11 @@ export class Notebook { await this.code.waitForElementGone(Notebook.doubleClickToEditSelector); } - private static readonly textCellToolbar = 'text-cell-component markdown-toolbar-component ul.actions-container'; - async changeTextCellView(view: 'Rich Text View' | 'Split View' | 'Markdown View'): Promise { - const actionSelector = `${Notebook.textCellToolbar} a[title="${view}"]`; - await this.code.waitAndClick(actionSelector); - } - - async waitForTextCellPreviewContent(text: string, fontType: 'p' | 'h1' | 'h2' | 'h3'): Promise { - const textSelector = `${Notebook.textCellPreviewSelector} ${fontType}`; + async waitForTextCellPreviewContent(text: string, fontType: 'p' | 'h1' | 'h2' | 'h3', textStyle?: 'strong' | 'i' | 'u' | 'mark'): Promise { + let textSelector = `${Notebook.textCellPreviewSelector} ${fontType}`; + if (textStyle) { + textSelector = `${textSelector} ${textStyle}`; + } await this.code.waitForElement(textSelector, result => result?.textContent === text); } @@ -196,6 +201,57 @@ export class Notebook { } } +export class TextCellToolbar { + private static readonly textCellToolbar = 'text-cell-component markdown-toolbar-component ul.actions-container'; + + constructor(private code: Code) { } + + public async changeTextCellView(view: 'Rich Text View' | 'Split View' | 'Markdown View'): Promise { + await this.clickToolbarButton(view); + } + + public async boldSelectedText(): Promise { + await this.clickToolbarButton('Bold'); + } + + public async italicizeSelectedText(): Promise { + await this.clickToolbarButton('Italics'); + } + + public async underlineSelectedText(): Promise { + await this.clickToolbarButton('Underline'); + } + + public async highlightSelectedText(): Promise { + await this.clickToolbarButton('Highlight'); + } + + public async codifySelectedText(): Promise { + await this.clickToolbarButton('Code'); + } + + public async insertLink(): Promise { + throw new Error('Method not implemented.'); + } + + public async insertList(): Promise { + await this.clickToolbarButton('List'); + } + + public async insertOrderedList(): Promise { + await this.clickToolbarButton('Ordered list'); + } + + public async changeSelectedTextSize(): Promise { + throw new Error('Method not implemented.'); + } + + private async clickToolbarButton(buttonTitle: string) { + const actionSelector = `${TextCellToolbar.textCellToolbar} a[title="${buttonTitle}"]`; + await this.code.waitAndClick(actionSelector); + } +} + export class NotebookToolbar { private static readonly toolbarSelector = '.notebookEditor .editor-toolbar .actions-container'; diff --git a/test/smoke/src/sql/areas/notebook/notebook.test.ts b/test/smoke/src/sql/areas/notebook/notebook.test.ts index cf4d32acc1..cf9c56334a 100644 --- a/test/smoke/src/sql/areas/notebook/notebook.test.ts +++ b/test/smoke/src/sql/areas/notebook/notebook.test.ts @@ -73,11 +73,13 @@ export function setup() { await app.workbench.sqlNotebook.doubleClickTextCell(); await app.workbench.sqlNotebook.waitForDoubleClickToEditGone(); - await app.workbench.sqlNotebook.changeTextCellView('Split View'); + await app.workbench.sqlNotebook.textCellToolbar.changeTextCellView('Split View'); const sampleText: string = 'Test text cells'; await app.workbench.sqlNotebook.waitForTypeInEditor(sampleText); + await app.workbench.sqlNotebook.selectAllTextInEditor(); + await app.workbench.sqlNotebook.textCellToolbar.boldSelectedText(); await app.code.dispatchKeybinding('escape'); - await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'p'); + await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'p', 'strong'); await app.workbench.quickaccess.runCommand('workbench.action.revertAndCloseActiveEditor'); });