mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Select notebook in viewlet when opened in editor (#14854)
* test changes * code clean up * remove extra line * remove commented code * remove unnecessary import * update expand logic * implement parent,children on bookitem * merge conflicts * refactor code * fix trustBook test * typo on condition * feedback * indexOf to include * fix undefined error on expand * remove set parent * revert getTreeItem logic * Fix duplicated nodes * remove debug * Clean up logic * Fix tests * Fix logic * cleanup * Cleanup findAndExpandParentNode (#14960) Co-authored-by: chgagnon <chgagnon@microsoft.com>
This commit is contained in:
@@ -184,6 +184,7 @@ describe('BooksTreeViewTests', function () {
|
||||
should(children).be.Array();
|
||||
should(children.length).equal(1);
|
||||
book = children[0];
|
||||
should(book).equal(bookTreeViewProvider.currentBook.rootNode);
|
||||
should(book.title).equal(expectedBook.title);
|
||||
});
|
||||
|
||||
@@ -210,13 +211,13 @@ describe('BooksTreeViewTests', function () {
|
||||
});
|
||||
|
||||
it('should set notebooks trusted to true on trustBook', async () => {
|
||||
let notebook1Path = path.join(rootFolderPath, 'Book', 'content', 'notebook1.ipynb');
|
||||
let notebook1Path = notebook1.tooltip;
|
||||
let bookTrustManager: BookTrustManager = new BookTrustManager(bookTreeViewProvider.books);
|
||||
let isTrusted = bookTrustManager.isNotebookTrustedByDefault(vscode.Uri.file(notebook1Path).fsPath);
|
||||
let isTrusted = bookTrustManager.isNotebookTrustedByDefault(notebook1Path);
|
||||
should(isTrusted).equal(false, 'Notebook should not be trusted by default');
|
||||
|
||||
bookTreeViewProvider.trustBook(bookTreeViewProvider.currentBook.bookItems[0]);
|
||||
isTrusted = bookTrustManager.isNotebookTrustedByDefault(vscode.Uri.file(notebook1Path).fsPath);
|
||||
bookTreeViewProvider.trustBook(notebook1);
|
||||
isTrusted = bookTrustManager.isNotebookTrustedByDefault(notebook1Path);
|
||||
should(isTrusted).equal(true, 'Failed to set trust on trustBook');
|
||||
|
||||
});
|
||||
@@ -252,7 +253,7 @@ describe('BooksTreeViewTests', function () {
|
||||
let notebook2Path = path.join(rootFolderPath, 'Book', 'content', 'notebook2.ipynb');
|
||||
let notebookUri = vscode.Uri.file(notebook2Path);
|
||||
|
||||
let revealActiveDocumentInViewletSpy = sinon.spy(bookTreeViewProvider, 'revealActiveDocumentInViewlet');
|
||||
let revealActiveDocumentInViewletSpy = sinon.spy(bookTreeViewProvider, 'revealDocumentInTreeView');
|
||||
await azdata.nb.showNotebookDocument(notebookUri);
|
||||
should(azdata.nb.notebookDocuments.find(doc => doc.fileName === notebookUri.fsPath)).not.be.undefined();
|
||||
should(revealActiveDocumentInViewletSpy.calledOnce).be.true('revealActiveDocumentInViewlet should have been called');
|
||||
@@ -335,7 +336,7 @@ describe('BooksTreeViewTests', function () {
|
||||
const untitledNotebook1Uri = vscode.Uri.parse(`untitled:notebook1.ipynb`);
|
||||
const untitledNotebook2Uri = vscode.Uri.parse(`untitled:notebook2.ipynb`);
|
||||
|
||||
let revealActiveDocumentInViewletSpy = sinon.spy(providedbookTreeViewProvider, 'revealActiveDocumentInViewlet');
|
||||
let revealActiveDocumentInViewletSpy = sinon.spy(providedbookTreeViewProvider, 'revealDocumentInTreeView');
|
||||
await azdata.nb.showNotebookDocument(untitledNotebook1Uri);
|
||||
should(azdata.nb.notebookDocuments.find(doc => doc.fileName === untitledNotebook1Uri.fsPath)).not.be.undefined();
|
||||
should(revealActiveDocumentInViewletSpy.calledOnce).be.true('revealActiveDocumentInViewlet should have been called');
|
||||
@@ -652,7 +653,7 @@ describe('BooksTreeViewTests', function () {
|
||||
|
||||
it('should show error if notebook or markdown file is missing', async function (): Promise<void> {
|
||||
let books: BookTreeItem[] = bookTreeViewProvider.currentBook.bookItems;
|
||||
let children = await bookTreeViewProvider.currentBook.getSections({ sections: [] }, books[0].sections, rootFolderPath, books[0].book);
|
||||
let children = await bookTreeViewProvider.currentBook.getSections(books[0]);
|
||||
should(bookTreeViewProvider.currentBook.errorMessage).equal('Missing file : Notebook1 from '.concat(bookTreeViewProvider.currentBook.bookItems[0].title));
|
||||
// rest of book should be detected correctly even with a missing file
|
||||
equalBookItems(children[0], expectedNotebook2);
|
||||
|
||||
Reference in New Issue
Block a user