diff --git a/test/automation/src/sql/notebook.ts b/test/automation/src/sql/notebook.ts index 0e85b52775..b6bb9a775c 100644 --- a/test/automation/src/sql/notebook.ts +++ b/test/automation/src/sql/notebook.ts @@ -9,15 +9,15 @@ import { QuickInput } from '../quickinput'; import { Editors } from '../editors'; import { IElement } from '..'; -const winOrCtrl = process.platform === 'darwin' ? 'ctrl' : 'win'; -const ctrlOrCmd = process.platform === 'darwin' ? 'cmd' : 'ctrl'; - export class Notebook { public readonly notebookToolbar: NotebookToolbar; public readonly textCellToolbar: TextCellToolbar; public readonly view: NotebookTreeView; + public readonly winOrCtrl = process.platform === 'darwin' ? 'ctrl' : 'win'; + public readonly ctrlOrCmd = process.platform === 'darwin' ? 'cmd' : 'ctrl'; + constructor(private code: Code, private quickAccess: QuickAccess, private quickInput: QuickInput, private editors: Editors) { this.notebookToolbar = new NotebookToolbar(code); this.textCellToolbar = new TextCellToolbar(code); @@ -33,7 +33,7 @@ export class Notebook { } async newUntitledNotebook(): Promise { - await this.code.dispatchKeybinding(winOrCtrl + '+Alt+n'); + await this.code.dispatchKeybinding(this.winOrCtrl + '+Alt+n'); await this.editors.waitForActiveTab(`Notebook-0`); await this.code.waitForElement('.notebookEditor'); } @@ -93,7 +93,7 @@ export class Notebook { private async selectAllText(selector: string): Promise { await this.code.waitAndClick(selector); - await this.code.dispatchKeybinding(ctrlOrCmd + '+a'); + await this.code.dispatchKeybinding(this.ctrlOrCmd + '+a'); } private static readonly placeholderSelector = 'div.placeholder-cell-component'; diff --git a/test/smoke/src/sql/areas/notebook/notebook.test.ts b/test/smoke/src/sql/areas/notebook/notebook.test.ts index d1db02946b..5b4bf3c3e7 100644 --- a/test/smoke/src/sql/areas/notebook/notebook.test.ts +++ b/test/smoke/src/sql/areas/notebook/notebook.test.ts @@ -187,6 +187,19 @@ export function setup(opts: minimist.ParsedArgs) { } } + async function verifyToolbarKeyboardShortcut(app: Application, keyboardShortcut: string, selector: string) { + await app.workbench.sqlNotebook.newUntitledNotebook(); + await app.workbench.sqlNotebook.addCellFromPlaceholder('Markdown'); + await app.workbench.sqlNotebook.waitForPlaceholderGone(); + await app.workbench.sqlNotebook.textCellToolbar.changeTextCellView('Markdown View'); + let testText = 'Markdown Keyboard Shortcut Test'; + await app.workbench.sqlNotebook.waitForTypeInEditor(testText); + await app.workbench.sqlNotebook.selectAllTextInEditor(); + await app.code.dispatchKeybinding(keyboardShortcut); + await app.code.dispatchKeybinding('escape'); + await app.workbench.sqlNotebook.waitForTextCellPreviewContent(testText, selector); + } + it('can bold selected text', async function () { const app = this.app as Application; await verifyCellToolbarBehavior(app, () => app.workbench.sqlNotebook.textCellToolbar.boldSelectedText(), 'p strong'); @@ -317,6 +330,31 @@ export function setup(opts: minimist.ParsedArgs) { await app.code.dispatchKeybinding('escape'); await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleLabel, `p a[href="${sampleAddress}"]`); }); + + it('can bold text with keyboard shortcut', async function () { + const app = this.app as Application; + await verifyToolbarKeyboardShortcut(app, app.workbench.sqlNotebook.ctrlOrCmd + '+b', 'p strong'); + }); + + it('can italicize text with keyboard shortcut', async function () { + const app = this.app as Application; + await verifyToolbarKeyboardShortcut(app, app.workbench.sqlNotebook.ctrlOrCmd + '+i', 'p em'); + }); + + it('can underline text with keyboard shortcut', async function () { + const app = this.app as Application; + await verifyToolbarKeyboardShortcut(app, app.workbench.sqlNotebook.ctrlOrCmd + '+u', 'p u'); + }); + + it('can highlight text with keyboard shortcut', async function () { + const app = this.app as Application; + await verifyToolbarKeyboardShortcut(app, app.workbench.sqlNotebook.ctrlOrCmd + '+shift+h', 'p mark'); + }); + + it('can codify text with keyboard shortcut', async function () { + const app = this.app as Application; + await verifyToolbarKeyboardShortcut(app, app.workbench.sqlNotebook.ctrlOrCmd + '+shift+k', 'pre code'); + }); }); describe('markdown', function () {