Add smoke tests for cell toolbar keyboard shortcuts. (#19208)

This commit is contained in:
Cory Rivera
2022-04-26 15:09:36 -07:00
committed by GitHub
parent 6e2bf7521f
commit b406dda13c
2 changed files with 43 additions and 5 deletions

View File

@@ -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 () {