clean up trust notebook smoke test (#15926)

This commit is contained in:
Lucy Zhang
2021-06-28 15:39:29 -07:00
committed by GitHub
parent a9e8885fe6
commit 5fa53c3519
2 changed files with 35 additions and 60 deletions

View File

@@ -37,7 +37,7 @@ export class Notebook {
await this.code.waitForElement('.notebookEditor');
}
// Notebook Toolbar Actions
// Notebook Toolbar Actions (keyboard shortcuts)
async addCell(cellType: 'markdown' | 'code'): Promise<void> {
if (cellType === 'markdown') {
@@ -49,14 +49,6 @@ export class Notebook {
await this.code.waitForElement('.notebook-cell.active');
}
async changeKernel(kernel: string): Promise<void> {
await this.notebookToolbar.changeKernel(kernel);
}
async waitForKernel(kernel: string): Promise<void> {
await this.notebookToolbar.waitForKernel(kernel);
}
async runActiveCell(): Promise<void> {
await this.code.dispatchKeybinding('F5');
}
@@ -65,24 +57,6 @@ export class Notebook {
await this.code.dispatchKeybinding('ctrl+shift+F5');
}
async clearResults(): Promise<void> {
await this.code.waitAndClick('.notebookEditor');
const clearResultsButton = '.editor-toolbar a[class="action-label codicon icon-clear-results masked-icon"]';
await this.code.waitAndClick(clearResultsButton);
}
async trustNotebook(): Promise<void> {
await this.notebookToolbar.trustNotebook();
}
async waitForTrustedIcon(): Promise<void> {
await this.notebookToolbar.waitForTrustedIcon();
}
async waitForNotTrustedIcon(): Promise<void> {
await this.notebookToolbar.waitForNotTrustedIcon();
}
// Cell Actions
async waitForTypeInEditor(text: string) {
@@ -280,14 +254,11 @@ export class NotebookToolbar {
private static readonly toolbarSelector = '.notebookEditor .editor-toolbar .actions-container';
private static readonly toolbarButtonSelector = `${NotebookToolbar.toolbarSelector} a.action-label.codicon.masked-icon`;
private static readonly trustedButtonClass = 'action-label codicon masked-icon icon-shield';
private static readonly trustedButtonSelector = `${NotebookToolbar.toolbarSelector} a[class="${NotebookToolbar.trustedButtonClass}"]`;
private static readonly notTrustedButtonClass = 'action-label codicon masked-icon icon-shield-x';
private static readonly notTrustedButtonSelector = `${NotebookToolbar.toolbarSelector} a[class="${NotebookToolbar.notTrustedButtonClass}"]`;
private static readonly collapseCellsClass = 'action-label codicon masked-icon icon-collapse-cells';
private static readonly collapseCellsButtonSelector = `${NotebookToolbar.toolbarSelector} a[class="${NotebookToolbar.collapseCellsClass}"]`;
private static readonly expandCellsClass = 'action-label codicon masked-icon icon-expand-cells';
private static readonly expandCellsButtonSelector = `${NotebookToolbar.toolbarSelector} a[class="${NotebookToolbar.expandCellsClass}"]`;
private static readonly trustedButtonSelector = `${NotebookToolbar.toolbarButtonSelector}.icon-shield`;
private static readonly notTrustedButtonSelector = `${NotebookToolbar.toolbarButtonSelector}.icon-shield-x`;
private static readonly collapseCellsButtonSelector = `${NotebookToolbar.toolbarButtonSelector}.icon-collapse-cells`;
private static readonly expandCellsButtonSelector = `${NotebookToolbar.toolbarButtonSelector}.icon-expand-cells`;
private static readonly clearResultsButtonSelector = `${NotebookToolbar.toolbarButtonSelector}.icon-clear-results`;
constructor(private code: Code) { }
@@ -347,6 +318,10 @@ export class NotebookToolbar {
async waitForExpandCellsNotebookIcon(): Promise<void> {
await this.code.waitForElement(NotebookToolbar.expandCellsButtonSelector);
}
async clearResults(): Promise<void> {
await this.code.waitAndClick(NotebookToolbar.clearResultsButtonSelector);
}
}
export class NotebookView {

View File

@@ -38,25 +38,6 @@ export function setup() {
await app.workbench.sqlNotebook.waitForTypeInEditor(sampleText);
});
it('can open untrusted notebook, trust, save, and reopen trusted notebook', async function () {
const app = this.app as Application;
await app.workbench.sqlNotebook.openFile('untrusted.ipynb');
await app.workbench.sqlNotebook.waitForKernel('SQL');
await app.workbench.sqlNotebook.waitForNotTrustedIcon();
await app.workbench.sqlNotebook.waitForTrustedElementsGone();
await app.workbench.sqlNotebook.trustNotebook();
await app.workbench.sqlNotebook.waitForTrustedIcon();
await app.workbench.sqlNotebook.waitForTrustedElements();
await app.workbench.quickaccess.runCommand('workbench.action.files.save');
await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor');
await app.workbench.sqlNotebook.openFile('untrusted.ipynb');
await app.workbench.sqlNotebook.waitForTrustedIcon();
await app.workbench.sqlNotebook.waitForTrustedElements();
});
// Python Notebooks
it('can open new notebook, configure Python, and execute one cell', async function () {
@@ -64,12 +45,12 @@ export function setup() {
await app.workbench.sqlNotebook.newUntitledNotebook();
await app.workbench.sqlNotebook.addCell('code');
await app.workbench.sqlNotebook.waitForTypeInEditor('print("Hello world!")');
await app.workbench.sqlNotebook.waitForKernel('SQL');
await app.workbench.sqlNotebook.notebookToolbar.waitForKernel('SQL');
await app.workbench.sqlNotebook.changeKernel('Python 3');
await app.workbench.sqlNotebook.notebookToolbar.changeKernel('Python 3');
await app.workbench.configurePythonDialog.waitForConfigurePythonDialog();
await app.workbench.configurePythonDialog.installPython();
await app.workbench.sqlNotebook.waitForKernel('Python 3');
await app.workbench.sqlNotebook.notebookToolbar.waitForKernel('Python 3');
await app.workbench.sqlNotebook.runActiveCell();
await app.workbench.sqlNotebook.waitForActiveCellResults();
@@ -109,15 +90,34 @@ export function setup() {
await app.workbench.sqlNotebook.waitForCollapseIconInCells();
await app.workbench.sqlNotebook.notebookToolbar.waitForCollapseCellsNotebookIcon();
});
it('can open untrusted notebook, trust, save, and reopen trusted notebook', async function () {
const app = this.app as Application;
await app.workbench.sqlNotebook.openFile('untrusted.ipynb');
await app.workbench.sqlNotebook.notebookToolbar.waitForKernel('SQL');
await app.workbench.sqlNotebook.notebookToolbar.waitForNotTrustedIcon();
await app.workbench.sqlNotebook.waitForTrustedElementsGone();
await app.workbench.sqlNotebook.notebookToolbar.trustNotebook();
await app.workbench.sqlNotebook.notebookToolbar.waitForTrustedIcon();
await app.workbench.sqlNotebook.waitForTrustedElements();
await app.workbench.quickaccess.runCommand('workbench.action.files.save');
await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor');
await app.workbench.sqlNotebook.openFile('untrusted.ipynb');
await app.workbench.sqlNotebook.notebookToolbar.waitForTrustedIcon();
await app.workbench.sqlNotebook.waitForTrustedElements();
});
});
});
}
async function openAndRunNotebook(app: Application, filename: string): Promise<void> {
await app.workbench.sqlNotebook.openFile(filename);
await app.workbench.sqlNotebook.waitForKernel('Python 3');
await app.workbench.sqlNotebook.notebookToolbar.waitForKernel('Python 3');
await app.workbench.sqlNotebook.clearResults();
await app.workbench.sqlNotebook.notebookToolbar.clearResults();
await app.workbench.sqlNotebook.waitForAllResultsGone();
await app.workbench.sqlNotebook.runAllCells();
await app.workbench.sqlNotebook.waitForAllResults();
@@ -126,6 +126,6 @@ async function openAndRunNotebook(app: Application, filename: string): Promise<v
await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor');
await app.workbench.sqlNotebook.openFile(filename);
await app.workbench.sqlNotebook.waitForKernel('Python 3');
await app.workbench.sqlNotebook.notebookToolbar.waitForKernel('Python 3');
await app.workbench.sqlNotebook.waitForAllResults();
}