mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Pin and unpin notebook smoke test (#15936)
* add pin/unpin smoketest * fix simple search query assert
This commit is contained in:
@@ -316,26 +316,70 @@ export class NotebookToolbar {
|
|||||||
|
|
||||||
export class NotebookView {
|
export class NotebookView {
|
||||||
private static readonly inputBox = '.notebookExplorer-viewlet .search-widget .input-box';
|
private static readonly inputBox = '.notebookExplorer-viewlet .search-widget .input-box';
|
||||||
private static actualResult = '.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 selectedItem = '.focused.selected';
|
||||||
|
private static pinnedNotebooksSelector = '.split-view-view .tree-explorer-viewlet-tree-view .monaco-list[aria-label="Pinned notebooks"] .monaco-list-row';
|
||||||
|
|
||||||
constructor(private code: Code, private quickAccess: QuickAccess) { }
|
constructor(private code: Code, private quickAccess: QuickAccess) { }
|
||||||
|
|
||||||
async focus(): Promise<void> {
|
async focusSearchResultsView(): Promise<void> {
|
||||||
return this.quickAccess.runCommand('Notebooks: Focus on Search Results View');
|
return this.quickAccess.runCommand('Notebooks: Focus on Search Results View');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async focusNotebooksView(): Promise<void> {
|
||||||
|
return this.quickAccess.runCommand('Notebooks: Focus on Notebooks View');
|
||||||
|
}
|
||||||
|
|
||||||
|
async focusPinnedNotebooksView(): Promise<void> {
|
||||||
|
return this.quickAccess.runCommand('Notebooks: Focus on Pinned notebooks View');
|
||||||
|
}
|
||||||
|
|
||||||
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.actualResult} `;
|
let selector = NotebookView.searchResult;
|
||||||
if (expr) {
|
if (expr) {
|
||||||
selector += '.message';
|
selector += ' .message';
|
||||||
}
|
}
|
||||||
return await this.code.waitForElement(selector, undefined);
|
return this.code.waitForElement(selector, undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
async waitForSetSearchValue(text: string): Promise<void> {
|
async waitForSetSearchValue(text: string): Promise<void> {
|
||||||
const textArea = `${NotebookView.inputBox} textarea`;
|
const textArea = `${NotebookView.inputBox} textarea`;
|
||||||
await this.code.waitForTypeInEditor(textArea, text);
|
await this.code.waitForTypeInEditor(textArea, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function
|
||||||
|
* @returns tree item ids from Notebooks View
|
||||||
|
*/
|
||||||
|
async getNotebookTreeItemIds(): Promise<string[]> {
|
||||||
|
return (await this.code.waitForElements(NotebookView.notebookTreeItem, false)).map(item => item.attributes['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin the first notebook in the Notebooks View
|
||||||
|
*/
|
||||||
|
async pinNotebook(): Promise<void> {
|
||||||
|
const notebookIds = await this.getNotebookTreeItemIds();
|
||||||
|
await this.code.waitAndDoubleClick(`${NotebookView.notebookTreeItem}[id="${notebookIds[0]}"]`);
|
||||||
|
await this.code.waitAndClick(`${NotebookView.notebookTreeItem}${NotebookView.selectedItem} .codicon-pinned`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unpin the only pinned notebook.
|
||||||
|
* Previously pinned by the pinNotebook method.
|
||||||
|
*/
|
||||||
|
async unpinNotebook(): Promise<void> {
|
||||||
|
await this.code.waitAndClick(NotebookView.pinnedNotebooksSelector);
|
||||||
|
await this.code.waitAndClick(`${NotebookView.pinnedNotebooksSelector} .actions a[title="Unpin Notebook"]`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When pinning a notebook, the pinned notebook view will show.
|
||||||
|
*/
|
||||||
|
async waitForPinnedNotebookView(): Promise<void> {
|
||||||
|
await this.code.waitForElement(NotebookView.pinnedNotebooksSelector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,19 +8,31 @@ import { Application } from '../../../../../automation';
|
|||||||
|
|
||||||
export function setup() {
|
export function setup() {
|
||||||
describe('NotebookView', () => {
|
describe('NotebookView', () => {
|
||||||
|
it('Pin a notebook', async function () {
|
||||||
|
const app = this.app as Application;
|
||||||
|
await app.workbench.sqlNotebook.view.focusNotebooksView();
|
||||||
|
await app.workbench.sqlNotebook.view.pinNotebook();
|
||||||
|
await app.workbench.sqlNotebook.view.waitForPinnedNotebookView();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Unpin Notebook', async function () {
|
||||||
|
const app = this.app as Application;
|
||||||
|
await app.workbench.sqlNotebook.view.focusPinnedNotebooksView();
|
||||||
|
await app.workbench.sqlNotebook.view.unpinNotebook();
|
||||||
|
});
|
||||||
|
|
||||||
it('No search results if search query is empty', async function () {
|
it('No search results if search query is empty', async function () {
|
||||||
const app = this.app as Application;
|
const app = this.app as Application;
|
||||||
await app.workbench.sqlNotebook.view.focus();
|
await app.workbench.sqlNotebook.view.focusSearchResultsView();
|
||||||
const results = await app.workbench.sqlNotebook.view.searchInNotebook('');
|
const results = await app.workbench.sqlNotebook.view.searchInNotebook('');
|
||||||
assert(results.children !== undefined && results.children.length === 0);
|
assert(results.children !== undefined && results.children.length === 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Simple query search works correctly', async function () {
|
it('Simple query search works correctly', async function () {
|
||||||
const app = this.app as Application;
|
const app = this.app as Application;
|
||||||
await app.workbench.sqlNotebook.view.focus();
|
await app.workbench.sqlNotebook.view.focusSearchResultsView();
|
||||||
// Adding a regex expression to not depend on specific results of files
|
// Adding a regex expression to not depend on specific results of files
|
||||||
const regexExpr = /[0-9]+( results in )[0-9]+( files)/;
|
const regexExpr = /[0-9]+( results? in )[0-9]+( files?)/;
|
||||||
const results = await app.workbench.sqlNotebook.view.searchInNotebook('hello');
|
const results = await app.workbench.sqlNotebook.view.searchInNotebook('hello');
|
||||||
assert(results.textContent !== '' && results.textContent.match(regexExpr));
|
assert(results.textContent !== '' && results.textContent.match(regexExpr));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user