Keyboard navigation smoke test (#18796)

This commit is contained in:
Barbara Valdez
2022-04-28 17:05:23 -07:00
committed by GitHub
parent 7ef0ef65f4
commit 5dd1cbeed8
4 changed files with 101 additions and 22 deletions

View File

@@ -3,11 +3,10 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application } from '../../../../../automation';
import { Application, ctrlOrCmd } from '../../../../../automation';
import * as minimist from 'minimist';
import { afterSuite, beforeSuite } from '../../../utils';
import * as assert from 'assert';
export function setup(opts: minimist.ParsedArgs) {
describe('Notebook', () => {
beforeSuite(opts);
@@ -59,6 +58,7 @@ export function setup(opts: minimist.ParsedArgs) {
await app.workbench.sqlNotebook.waitForColorization('6', 'mtk1'); // employees
});
// Python Notebooks
it('can open new notebook, configure Python, and execute one cell', async function () {
@@ -132,6 +132,50 @@ export function setup(opts: minimist.ParsedArgs) {
await app.code.dispatchKeybinding('escape');
});
describe('Notebook keyboard navigation', async () => {
it('can enter and exit edit mode and navigate using keyboard nav', async function () {
const app = this.app as Application;
await app.workbench.sqlNotebook.newUntitledNotebook();
await app.workbench.sqlNotebook.addCellFromPlaceholder('Code'); // add new code cell
await app.workbench.sqlNotebook.waitForPlaceholderGone();
const activeCodeCellId = (await app.workbench.sqlNotebook.getActiveCell()).attributes['id'];
await app.workbench.sqlNotebook.waitForTypeInEditor('code cell', activeCodeCellId); // the new cell should be in edit mode
await app.workbench.sqlNotebook.exitActiveCell();
await app.workbench.sqlNotebook.waitForActiveCellGone();
await app.workbench.sqlNotebook.addCell('markdown'); // add markdown cell
await app.workbench.sqlNotebook.textCellToolbar.changeTextCellView('Split View');
const activeTextCellId = (await app.workbench.sqlNotebook.getActiveCell()).attributes['id'];
await app.workbench.sqlNotebook.waitForTypeInEditor('text cell', activeTextCellId); // Text cell should be in edit mode
await app.code.dispatchKeybinding('escape'); // exit edit mode and stay in browse mode
await app.code.dispatchKeybinding('up'); // select code cell
await app.workbench.sqlNotebook.getActiveCell(activeCodeCellId); // check that the code cell is now active
await app.code.dispatchKeybinding('enter');
await app.workbench.sqlNotebook.waitForTypeInEditor('test', activeCodeCellId); // code cell should be in edit mode after hitting enter
await app.code.dispatchKeybinding('escape'); // exit edit mode and stay in browse mode
await app.code.dispatchKeybinding('down'); // select text cell
await app.code.dispatchKeybinding('enter');
await app.workbench.sqlNotebook.textCellToolbar.changeTextCellView('Split View');
await app.workbench.sqlNotebook.waitForTypeInEditor('test', activeTextCellId); // text cell should be in edit mode after hitting enter
});
it('cannot move through cells when find widget is invoked', async function () {
const app = this.app as Application;
await app.workbench.sqlNotebook.newUntitledNotebook();
await app.workbench.sqlNotebook.addCell('markdown');
await app.workbench.sqlNotebook.exitActiveCell();
await app.workbench.sqlNotebook.addCell('markdown');
await app.workbench.sqlNotebook.exitActiveCell();
await app.workbench.sqlNotebook.addCell('markdown');
await app.code.dispatchKeybinding('escape');
const activeCellId = (await app.workbench.sqlNotebook.getActiveCell()).attributes['id'];
await app.workbench.sqlNotebook.notebookFind.openFindWidget();
await app.code.dispatchKeybinding('down');
await app.workbench.sqlNotebook.getActiveCell(activeCellId); // verify that the active cell is the same
});
});
describe('Notebook Toolbar Actions', async () => {
it('Collapse and Expand Cell', async function () {
@@ -333,27 +377,27 @@ export function setup(opts: minimist.ParsedArgs) {
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');
await verifyToolbarKeyboardShortcut(app, `${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');
await verifyToolbarKeyboardShortcut(app, `${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');
await verifyToolbarKeyboardShortcut(app, `${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');
await verifyToolbarKeyboardShortcut(app, `${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');
await verifyToolbarKeyboardShortcut(app, `${ctrlOrCmd}+shift+k`, 'pre code');
});
});