diff --git a/test/automation/src/sql/notebook.ts b/test/automation/src/sql/notebook.ts index cea041e901..ca20537b11 100644 --- a/test/automation/src/sql/notebook.ts +++ b/test/automation/src/sql/notebook.ts @@ -10,6 +10,7 @@ import { Editors } from '../editors'; import { IElement } from '..'; const winOrCtrl = process.platform === 'win32' ? 'win' : 'ctrl'; +const ctrlOrCmd = process.platform === 'win32' ? 'ctrl' : 'cmd'; export class Notebook { @@ -83,7 +84,7 @@ export class Notebook { public async selectAllTextInEditor(): Promise { const editor = '.notebook-cell.active .monaco-editor'; await this.code.waitAndClick(editor); - await this.code.dispatchKeybinding('cmd+a'); + await this.code.dispatchKeybinding(ctrlOrCmd + '+a'); } private static readonly placeholderSelector = 'div.placeholder-cell-component'; @@ -149,12 +150,9 @@ export class Notebook { await this.code.waitForElementGone(Notebook.doubleClickToEditSelector); } - 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); + async waitForTextCellPreviewContent(text: string, selector: string): Promise { + let textSelector = `${Notebook.textCellPreviewSelector} ${selector}`; + await this.code.waitForElement(textSelector, result => !!result?.textContent?.includes(text)); // Use includes to handle whitespace/quote edge cases } // Cell Output Actions @@ -207,7 +205,7 @@ export class Notebook { } export class TextCellToolbar { - private static readonly textCellToolbar = 'text-cell-component markdown-toolbar-component ul.actions-container'; + private static readonly textCellToolbar = 'text-cell-component markdown-toolbar-component ul.actions-container li.action-item'; constructor(private code: Code) { } @@ -220,7 +218,7 @@ export class TextCellToolbar { } public async italicizeSelectedText(): Promise { - await this.clickToolbarButton('Italics'); + await this.clickToolbarButton('Italic'); } public async underlineSelectedText(): Promise { @@ -232,7 +230,7 @@ export class TextCellToolbar { } public async codifySelectedText(): Promise { - await this.clickToolbarButton('Code'); + await this.clickToolbarButton('Insert code'); } public async insertLink(): Promise { @@ -240,11 +238,11 @@ export class TextCellToolbar { } public async insertList(): Promise { - await this.clickToolbarButton('List'); + await this.clickToolbarButton('Insert list'); } public async insertOrderedList(): Promise { - await this.clickToolbarButton('Ordered list'); + await this.clickToolbarButton('Insert ordered list'); } public async changeSelectedTextSize(): Promise { diff --git a/test/smoke/src/sql/areas/notebook/notebook.test.ts b/test/smoke/src/sql/areas/notebook/notebook.test.ts index 0660a2430c..9130fa57e4 100644 --- a/test/smoke/src/sql/areas/notebook/notebook.test.ts +++ b/test/smoke/src/sql/areas/notebook/notebook.test.ts @@ -31,7 +31,7 @@ export function setup(opts: minimist.ParsedArgs) { await app.workbench.sqlNotebook.selectAllTextInEditor(); await app.workbench.sqlNotebook.textCellToolbar.boldSelectedText(); await app.code.dispatchKeybinding('escape'); - await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'p', 'strong'); + await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'p strong'); }); it('can perform basic code cell functionality', async function () { @@ -145,6 +145,74 @@ export function setup(opts: minimist.ParsedArgs) { }); }); + describe('Cell Toolbar Actions', function () { + const sampleText: string = 'Test Text'; + async function createCellAndSelectAllText(app: Application): Promise { + await app.workbench.sqlNotebook.newUntitledNotebook(); + await app.workbench.sqlNotebook.addCellFromPlaceholder('Markdown'); + await app.workbench.sqlNotebook.waitForPlaceholderGone(); + await app.workbench.sqlNotebook.textCellToolbar.changeTextCellView('Split View'); + await app.workbench.sqlNotebook.waitForTypeInEditor(sampleText); + await app.workbench.sqlNotebook.selectAllTextInEditor(); + } + + it('can bold selected text', async function () { + const app = this.app as Application; + await createCellAndSelectAllText(app); + await app.workbench.sqlNotebook.textCellToolbar.boldSelectedText(); + await app.code.dispatchKeybinding('escape'); + await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'p strong'); + }); + + it('can italicize selected text', async function () { + const app = this.app as Application; + await createCellAndSelectAllText(app); + await app.workbench.sqlNotebook.textCellToolbar.italicizeSelectedText(); + await app.code.dispatchKeybinding('escape'); + await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'p em'); + }); + + it('can underline selected text', async function () { + const app = this.app as Application; + await createCellAndSelectAllText(app); + await app.workbench.sqlNotebook.textCellToolbar.underlineSelectedText(); + await app.code.dispatchKeybinding('escape'); + await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'p u'); + }); + + it('can highlight selected text', async function () { + const app = this.app as Application; + await createCellAndSelectAllText(app); + await app.workbench.sqlNotebook.textCellToolbar.highlightSelectedText(); + await app.code.dispatchKeybinding('escape'); + await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'p mark'); + }); + + it('can codify selected text', async function () { + const app = this.app as Application; + await createCellAndSelectAllText(app); + await app.workbench.sqlNotebook.textCellToolbar.codifySelectedText(); + await app.code.dispatchKeybinding('escape'); + await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'pre code'); + }); + + it('can bullet selected text', async function () { + const app = this.app as Application; + await createCellAndSelectAllText(app); + await app.workbench.sqlNotebook.textCellToolbar.insertList(); + await app.code.dispatchKeybinding('escape'); + await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'ul li'); + }); + + it('can number selected text', async function () { + const app = this.app as Application; + await createCellAndSelectAllText(app); + await app.workbench.sqlNotebook.textCellToolbar.insertOrderedList(); + await app.code.dispatchKeybinding('escape'); + await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'ol li'); + }); + }); + describe('markdown', function () { it('can create http link from markdown', async function () { const app = this.app as Application;