Skip to content

Commit

Permalink
Add markdown smoke tests for changing text size and inserting links (m…
Browse files Browse the repository at this point in the history
…icrosoft#18888)

* Temporarily disabled text size tests due to issues running on Unix.
  • Loading branch information
corivera authored Apr 5, 2022
1 parent 92a2233 commit 7c399e8
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class MarkdownToolbarComponent extends AngularDisposable {
undefined,
this._actionBar.actionRunner,
undefined,
'masked-pseudo-after dropdown-arrow',
'masked-pseudo-after dropdown-arrow heading-dropdown',
this.optionParagraph,
undefined
);
Expand Down
26 changes: 19 additions & 7 deletions test/automation/src/sql/notebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { QuickInput } from '../quickinput';
import { Editors } from '../editors';
import { IElement } from '..';

const winOrCtrl = process.platform === 'win32' ? 'win' : 'ctrl';
const ctrlOrCmd = process.platform === 'win32' ? 'ctrl' : 'cmd';
const winOrCtrl = process.platform === 'darwin' ? 'ctrl' : 'win';
const ctrlOrCmd = process.platform === 'darwin' ? 'cmd' : 'ctrl';

export class Notebook {

Expand Down Expand Up @@ -233,8 +233,16 @@ export class TextCellToolbar {
await this.clickToolbarButton('Insert code');
}

public async insertLink(): Promise<void> {
throw new Error('Method not implemented.');
public async insertLink(linkLabel: string, linkAddress: string): Promise<void> {
await this.clickToolbarButton('Insert link');
const linkDialogSelector = 'div.modal.callout-dialog[aria-label="Insert link"]';
const displayTextSelector = `${linkDialogSelector} input[aria-label="Text to display"]`;
await this.code.waitForSetValue(displayTextSelector, linkLabel);

const addressTextSelector = `${linkDialogSelector} input[aria-label="Address"]`;
await this.code.waitForSetValue(addressTextSelector, linkAddress);

await this.code.dispatchKeybinding('enter');
}

public async insertList(): Promise<void> {
Expand All @@ -245,9 +253,13 @@ export class TextCellToolbar {
await this.clickToolbarButton('Insert ordered list');
}

public async changeSelectedTextSize(): Promise<void> {
throw new Error('Method not implemented.');
}
// Disabled since the text size dropdown is not clickable on Unix from smoke tests
// public async changeSelectedTextSize(textSize: 'Heading 1' | 'Heading 2' | 'Heading 3' | 'Paragraph'): Promise<void> {
// const actionSelector = `${TextCellToolbar.textCellToolbar} .monaco-dropdown a.heading-dropdown`;
// await this.code.waitAndClick(actionSelector);
// const menuItemSelector = `.context-view.monaco-menu-container .monaco-menu .action-menu-item[title="${textSize}"]`;
// await this.code.waitAndClick(menuItemSelector);
// }

private async clickToolbarButton(buttonTitle: string) {
const actionSelector = `${TextCellToolbar.textCellToolbar} a[title="${buttonTitle}"]`;
Expand Down
48 changes: 48 additions & 0 deletions test/smoke/src/sql/areas/notebook/notebook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,54 @@ export function setup(opts: minimist.ParsedArgs) {
await app.code.dispatchKeybinding('escape');
await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'ol li');
});

// Text size tests are disabled because the text size dropdown
// is not clickable on Unix from the smoke tests
// it('can change text size to Heading 1', async function () {
// const app = this.app as Application;
// await createCellAndSelectAllText(app);
// await app.workbench.sqlNotebook.textCellToolbar.changeSelectedTextSize('Heading 1');
// await app.code.dispatchKeybinding('escape');
// await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'h1');
// });

// it('can change text size to Heading 2', async function () {
// const app = this.app as Application;
// await createCellAndSelectAllText(app);
// await app.workbench.sqlNotebook.textCellToolbar.changeSelectedTextSize('Heading 2');
// await app.code.dispatchKeybinding('escape');
// await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'h2');
// });

// it('can change text size to Heading 3', async function () {
// const app = this.app as Application;
// await createCellAndSelectAllText(app);
// await app.workbench.sqlNotebook.textCellToolbar.changeSelectedTextSize('Heading 3');
// await app.code.dispatchKeybinding('escape');
// await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'h3');
// });

// it('can change text size to Paragraph', async function () {
// const app = this.app as Application;
// await createCellAndSelectAllText(app);
// await app.workbench.sqlNotebook.textCellToolbar.changeSelectedTextSize('Paragraph');
// await app.code.dispatchKeybinding('escape');
// await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, 'p');
// });

it('can insert link', async function () {
const app = this.app as Application;
await app.workbench.sqlNotebook.newUntitledNotebook();
await app.workbench.sqlNotebook.addCellFromPlaceholder('Markdown');
await app.workbench.sqlNotebook.waitForPlaceholderGone();
await app.workbench.sqlNotebook.textCellToolbar.changeTextCellView('Split View');

const sampleLabel = 'Microsoft';
const sampleAddress = 'https://www.microsoft.com';
await app.workbench.sqlNotebook.textCellToolbar.insertLink(sampleLabel, sampleAddress);
await app.code.dispatchKeybinding('escape');
await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleLabel, `p a[href="${sampleAddress}"]`);
});
});

describe('markdown', function () {
Expand Down

0 comments on commit 7c399e8

Please sign in to comment.