Pin and unpin notebook smoke test (#15936)

* add pin/unpin smoketest

* fix simple search query assert
This commit is contained in:
Barbara Valdez
2021-06-30 22:14:18 -07:00
committed by GitHub
parent 7cf7ca5d15
commit a6644333c0
2 changed files with 64 additions and 8 deletions

View File

@@ -316,26 +316,70 @@ export class NotebookToolbar {
export class NotebookView {
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) { }
async focus(): Promise<void> {
async focusSearchResultsView(): Promise<void> {
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> {
await this.waitForSetSearchValue(expr);
await this.code.dispatchKeybinding('enter');
let selector = `${NotebookView.actualResult} `;
let selector = NotebookView.searchResult;
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> {
const textArea = `${NotebookView.inputBox} textarea`;
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);
}
}