mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
@@ -15,12 +15,12 @@ export class Notebook {
|
|||||||
|
|
||||||
public readonly notebookToolbar: NotebookToolbar;
|
public readonly notebookToolbar: NotebookToolbar;
|
||||||
public readonly textCellToolbar: TextCellToolbar;
|
public readonly textCellToolbar: TextCellToolbar;
|
||||||
public readonly view: NotebookView;
|
public readonly view: NotebookTreeView;
|
||||||
|
|
||||||
constructor(private code: Code, private quickAccess: QuickAccess, private quickInput: QuickInput, private editors: Editors) {
|
constructor(private code: Code, private quickAccess: QuickAccess, private quickInput: QuickInput, private editors: Editors) {
|
||||||
this.notebookToolbar = new NotebookToolbar(code);
|
this.notebookToolbar = new NotebookToolbar(code);
|
||||||
this.textCellToolbar = new TextCellToolbar(code);
|
this.textCellToolbar = new TextCellToolbar(code);
|
||||||
this.view = new NotebookView(code, quickAccess);
|
this.view = new NotebookTreeView(code, quickAccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
async openFile(fileName: string): Promise<void> {
|
async openFile(fileName: string): Promise<void> {
|
||||||
@@ -331,7 +331,7 @@ export class NotebookToolbar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NotebookView {
|
export class NotebookTreeView {
|
||||||
private static readonly inputBox = '.notebookExplorer-viewlet .search-widget .input-box';
|
private static readonly inputBox = '.notebookExplorer-viewlet .search-widget .input-box';
|
||||||
private static searchResult = '.search-view .result-messages';
|
private static searchResult = '.search-view .result-messages';
|
||||||
private static notebookTreeItem = '.split-view-view .tree-explorer-viewlet-tree-view .monaco-list-row';
|
private static notebookTreeItem = '.split-view-view .tree-explorer-viewlet-tree-view .monaco-list-row';
|
||||||
@@ -355,7 +355,7 @@ export class NotebookView {
|
|||||||
async searchInNotebook(expr: string): Promise<IElement> {
|
async searchInNotebook(expr: string): Promise<IElement> {
|
||||||
await this.waitForSetSearchValue(expr);
|
await this.waitForSetSearchValue(expr);
|
||||||
await this.code.dispatchKeybinding('enter');
|
await this.code.dispatchKeybinding('enter');
|
||||||
let selector = NotebookView.searchResult;
|
let selector = NotebookTreeView.searchResult;
|
||||||
if (expr) {
|
if (expr) {
|
||||||
selector += ' .message';
|
selector += ' .message';
|
||||||
}
|
}
|
||||||
@@ -363,40 +363,44 @@ export class NotebookView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async waitForSetSearchValue(text: string): Promise<void> {
|
async waitForSetSearchValue(text: string): Promise<void> {
|
||||||
const textArea = `${NotebookView.inputBox} textarea`;
|
const textArea = `${NotebookTreeView.inputBox} textarea`;
|
||||||
await this.code.waitForTypeInEditor(textArea, text);
|
await this.code.waitForTypeInEditor(textArea, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function
|
* Gets tree items from Notebooks Tree View
|
||||||
* @returns tree item ids from Notebooks View
|
* @returns tree item from Notebooks View
|
||||||
*/
|
*/
|
||||||
async getNotebookTreeItemIds(): Promise<string[]> {
|
async getNotebookTreeItems(): Promise<IElement[]> {
|
||||||
return (await this.code.waitForElements(NotebookView.notebookTreeItem, false)).map(item => item.attributes['id']);
|
return this.code.waitForElements(NotebookTreeView.notebookTreeItem, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pin the first notebook in the Notebooks View
|
* Gets tree items from Pinned Notebooks View
|
||||||
|
* @returns tree item from Pinned Notebooks View
|
||||||
*/
|
*/
|
||||||
async pinNotebook(): Promise<void> {
|
async getPinnedNotebookTreeItems(): Promise<IElement[]> {
|
||||||
const notebookIds = await this.getNotebookTreeItemIds();
|
return this.code.waitForElements(NotebookTreeView.pinnedNotebooksSelector, false);
|
||||||
await this.code.waitAndDoubleClick(`${NotebookView.notebookTreeItem}[id="${notebookIds[0]}"]`);
|
|
||||||
await this.code.waitAndClick(`${NotebookView.notebookTreeItem}${NotebookView.selectedItem} .codicon-pinned`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
async pinNotebook(notebookId: string): Promise<void> {
|
||||||
* Unpin the only pinned notebook.
|
await this.code.waitAndDoubleClick(`${NotebookTreeView.notebookTreeItem}[id="${notebookId}"]`);
|
||||||
* Previously pinned by the pinNotebook method.
|
await this.code.waitAndClick(`${NotebookTreeView.notebookTreeItem}${NotebookTreeView.selectedItem} .codicon-pinned`);
|
||||||
*/
|
}
|
||||||
async unpinNotebook(): Promise<void> {
|
|
||||||
await this.code.waitAndClick(NotebookView.pinnedNotebooksSelector);
|
async unpinNotebook(notebookId: string): Promise<void> {
|
||||||
await this.code.waitAndClick(`${NotebookView.pinnedNotebooksSelector} .actions a[title="Unpin Notebook"]`);
|
await this.code.waitAndClick(NotebookTreeView.pinnedNotebooksSelector);
|
||||||
|
await this.code.waitAndClick(`${NotebookTreeView.pinnedNotebooksSelector}[id="${notebookId}"] .actions a[title="Unpin Notebook"]`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When pinning a notebook, the pinned notebook view will show.
|
* When pinning a notebook, the pinned notebook view will show.
|
||||||
*/
|
*/
|
||||||
async waitForPinnedNotebookView(): Promise<void> {
|
async waitForPinnedNotebookTreeView(): Promise<void> {
|
||||||
await this.code.waitForElement(NotebookView.pinnedNotebooksSelector);
|
await this.code.waitForElement(NotebookTreeView.pinnedNotebooksSelector);
|
||||||
|
}
|
||||||
|
|
||||||
|
async waitForPinnedNotebookTreeViewGone(): Promise<void> {
|
||||||
|
await this.code.waitForElementGone(NotebookTreeView.pinnedNotebooksSelector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,21 +9,36 @@ import * as minimist from 'minimist';
|
|||||||
import { afterSuite, beforeSuite } from '../../../utils';
|
import { afterSuite, beforeSuite } from '../../../utils';
|
||||||
|
|
||||||
export function setup(opts: minimist.ParsedArgs) {
|
export function setup(opts: minimist.ParsedArgs) {
|
||||||
describe('NotebookView', () => {
|
describe('NotebookTreeView', () => {
|
||||||
beforeSuite(opts);
|
beforeSuite(opts);
|
||||||
afterSuite(opts);
|
afterSuite(opts);
|
||||||
|
// Name of the SQL notebook from azuredatastudio-smoke-test-repo
|
||||||
it('Pin a notebook', async function () {
|
const SQL_NOTEBOOK = 'collapsed';
|
||||||
|
it('Pin notebook', async function () {
|
||||||
const app = this.app as Application;
|
const app = this.app as Application;
|
||||||
await app.workbench.sqlNotebook.view.focusNotebooksView();
|
await app.workbench.sqlNotebook.view.focusNotebooksView();
|
||||||
await app.workbench.sqlNotebook.view.pinNotebook();
|
const sqlNotebook = (await app.workbench.sqlNotebook.view.getNotebookTreeItems()).filter(n => n.textContent === SQL_NOTEBOOK);
|
||||||
await app.workbench.sqlNotebook.view.waitForPinnedNotebookView();
|
// Pinning SQL notebook to prevent the Configure Python Wizard from showing, since Python is no longer set up when the NotebookTreeView test suite starts
|
||||||
|
await app.workbench.sqlNotebook.view.pinNotebook(sqlNotebook[0].attributes.id);
|
||||||
|
await app.workbench.sqlNotebook.view.waitForPinnedNotebookTreeView();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Unpin Notebook', async function () {
|
it('Unpin Notebook', async function () {
|
||||||
const app = this.app as Application;
|
const app = this.app as Application;
|
||||||
await app.workbench.sqlNotebook.view.focusPinnedNotebooksView();
|
await app.workbench.sqlNotebook.view.focusPinnedNotebooksView();
|
||||||
await app.workbench.sqlNotebook.view.unpinNotebook();
|
let pinnedNotebooks = await app.workbench.sqlNotebook.view.getPinnedNotebookTreeItems();
|
||||||
|
const sqlNotebook = (pinnedNotebooks).filter(n => n.textContent === SQL_NOTEBOOK)[0];
|
||||||
|
await app.workbench.sqlNotebook.view.unpinNotebook(sqlNotebook.attributes.id);
|
||||||
|
// wait a second for unpinning to complete
|
||||||
|
await new Promise(c => setTimeout(c, 1000));
|
||||||
|
if (pinnedNotebooks.length > 1) {
|
||||||
|
// if theres multiple pinned notebooks check that the SQL notebook is no longer in the Pinned Notebooks View
|
||||||
|
pinnedNotebooks = await app.workbench.sqlNotebook.view.getPinnedNotebookTreeItems();
|
||||||
|
assert(pinnedNotebooks.find(n => n.textContent === SQL_NOTEBOOK) === undefined);
|
||||||
|
} else {
|
||||||
|
// check that the Pinned Notebook View is gone
|
||||||
|
await app.workbench.sqlNotebook.view.waitForPinnedNotebookTreeViewGone();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('No search results if search query is empty', async function () {
|
it('No search results if search query is empty', async function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user