Add create content folder test (#15849)

* Add create book from content folder test

* Remove hardcoded
This commit is contained in:
Charles Gagnon
2021-06-22 08:56:50 -07:00
committed by GitHub
parent a35f8ffc52
commit 49562239a0

View File

@@ -10,9 +10,10 @@ import * as path from 'path';
import { assert } from 'console';
import * as tmp from 'tmp';
export function setup() {
const CreateBookCommand = 'Jupyter Books: Create Jupyter Book';
const bookName = 'my-book';
const bookName = 'my-book';
export function setup() {
describe('CreateBookDialog', () => {
@@ -24,12 +25,34 @@ export function setup() {
await new Promise(r => setTimeout(r, 10000));
// eslint-disable-next-line no-sync
tmpDir = tmp.dirSync().name;
await app.workbench.quickaccess.runCommand('Jupyter Books: Create Jupyter Book');
await app.workbench.quickaccess.runCommand(CreateBookCommand);
await app.workbench.createBookDialog.setName(bookName);
await app.workbench.createBookDialog.setLocation(tmpDir);
await app.workbench.createBookDialog.create();
const bookExists = await fs.stat(path.join(tmpDir, 'my-book'));
const bookExists = await fs.stat(path.join(tmpDir, bookName));
assert(!!bookExists, 'Book was not created');
await new Promise(r => setTimeout(r, 2500));
});
it('can create new book with specified content folder', async function () {
const app = this.app as Application;
// Add timeout for giving time for the SQL Tools Service to start (it'll error if it's not started yet)
// TODO @chgagnon - Figure out better way to have tests wait for STS
await new Promise(r => setTimeout(r, 10000));
// eslint-disable-next-line no-sync
tmpDir = tmp.dirSync().name;
// Our content folder is just the workspace folder containing the test notebooks
const contentFolder = path.join(app.workspacePathOrFolder, 'Notebooks');
await app.workbench.quickaccess.runCommand(CreateBookCommand);
await app.workbench.createBookDialog.setName(bookName);
await app.workbench.createBookDialog.setLocation(tmpDir);
await app.workbench.createBookDialog.setContentFolder(contentFolder);
await app.workbench.createBookDialog.create();
const bookExists = await fs.stat(path.join(tmpDir, bookName));
assert(!!bookExists, 'Book was not created');
const contentNotebookExists = await fs.stat(path.join(tmpDir, bookName, 'hello.ipynb'));
assert(!!contentNotebookExists, 'Notebook from content folder wasn\'t copied over');
await new Promise(r => setTimeout(r, 2500));
});
afterEach(async function () {