diff --git a/src/sql/workbench/contrib/notebook/browser/cellViews/placeholderCell.component.html b/src/sql/workbench/contrib/notebook/browser/cellViews/placeholderCell.component.html index c70c404e9c..287e17c464 100644 --- a/src/sql/workbench/contrib/notebook/browser/cellViews/placeholderCell.component.html +++ b/src/sql/workbench/contrib/notebook/browser/cellViews/placeholderCell.component.html @@ -7,7 +7,7 @@
-

{{clickOn}} {{plusCode}} {{or}} {{plusText}} {{toAddCell}}

+

{{clickOn}} {{plusCode}} {{or}} {{plusText}} {{toAddCell}}

-
\ No newline at end of file + diff --git a/test/automation/src/sql/notebook.ts b/test/automation/src/sql/notebook.ts index afc6b827c1..96b6aa0ee5 100644 --- a/test/automation/src/sql/notebook.ts +++ b/test/automation/src/sql/notebook.ts @@ -15,6 +15,7 @@ export class Notebook { public readonly toolbar: NotebookToolbar; public readonly view: NotebookView; + private newNotebookCount: number = 0; constructor(private code: Code, private quickAccess: QuickAccess, private quickInput: QuickInput, private editors: Editors) { this.toolbar = new NotebookToolbar(code); @@ -31,10 +32,13 @@ export class Notebook { async newUntitledNotebook(): Promise { await this.code.dispatchKeybinding(winOrCtrl + '+alt+n'); - await this.editors.waitForActiveTab('Notebook-0'); + await this.editors.waitForActiveTab(`Notebook-${this.newNotebookCount}`); await this.code.waitForElement('.notebookEditor'); + this.newNotebookCount++; } + // Notebook Toolbar Actions + async addCell(cellType: 'markdown' | 'code'): Promise { if (cellType === 'markdown') { await this.code.dispatchKeybinding('ctrl+shift+t'); @@ -79,6 +83,8 @@ export class Notebook { await this.toolbar.waitForNotTrustedIcon(); } + // Cell Actions + async waitForTypeInEditor(text: string) { const editor = '.notebook-cell.active .monaco-editor'; await this.code.waitAndClick(editor); @@ -95,6 +101,46 @@ export class Notebook { return this.code.waitForTextContent(selector, undefined, c => accept(c.replace(/\u00a0/g, ' '))); } + 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}"]`); + await this.code.waitForElement('.notebook-cell.active'); + } + + async waitForPlaceholderGone(): Promise { + await this.code.waitForElementGone(Notebook.placeholderSelector); + } + + // Text Cell Actions + + private static readonly textCellPreviewSelector = 'div.notebook-preview'; + private static readonly doubleClickToEditSelector = `${Notebook.textCellPreviewSelector} p i`; + async waitForDoubleClickToEdit(): Promise { + await this.code.waitForElement(Notebook.doubleClickToEditSelector); + } + + async doubleClickTextCell(): Promise { + await this.code.waitAndClick(Notebook.textCellPreviewSelector); + await this.code.waitAndDoubleClick(`${Notebook.textCellPreviewSelector}.actionselect`); + } + + async waitForDoubleClickToEditGone(): Promise { + 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}`; + await this.code.waitForElement(textSelector, result => result?.textContent === text); + } + + // Cell Output Actions + async waitForActiveCellResults(): Promise { const outputComponent = '.notebook-cell.active .notebook-output'; await this.code.waitForElement(outputComponent); diff --git a/test/smoke/src/sql/areas/notebook/notebook.test.ts b/test/smoke/src/sql/areas/notebook/notebook.test.ts index c18ca387d5..05696a08e9 100644 --- a/test/smoke/src/sql/areas/notebook/notebook.test.ts +++ b/test/smoke/src/sql/areas/notebook/notebook.test.ts @@ -59,6 +59,24 @@ export function setup() { await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor'); }); + + it('can perform basic text cell functionality', 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.code.dispatchKeybinding('escape'); + await app.workbench.sqlNotebook.waitForDoubleClickToEdit(); + await app.workbench.sqlNotebook.doubleClickTextCell(); + await app.workbench.sqlNotebook.waitForDoubleClickToEditGone(); + + await app.workbench.sqlNotebook.changeTextCellView('Split View'); + const sampleText: string = 'Test text cells'; + await app.workbench.sqlNotebook.waitForTypeInEditor(sampleText); + await app.code.dispatchKeybinding('escape'); + await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'p'); + }); }); }