mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Add smoke tests for cell toolbar keyboard shortcuts. (#19208)
This commit is contained in:
@@ -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<void> {
|
||||
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<void> {
|
||||
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';
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user