mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-06 17:23:53 -05:00
69 lines
2.9 KiB
TypeScript
69 lines
2.9 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { Application } from '../../../../../automation';
|
|
import { promises as fs } from 'fs';
|
|
import * as rimraf from 'rimraf';
|
|
import * as path from 'path';
|
|
import { assert } from 'console';
|
|
import * as tmp from 'tmp';
|
|
|
|
const CreateBookCommand = 'Jupyter Books: Create Jupyter Book';
|
|
const bookName = 'my-book';
|
|
|
|
export function setup() {
|
|
|
|
describe('CreateBookDialog', () => {
|
|
|
|
let tmpDir = '';
|
|
it('can create new book with default 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;
|
|
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, 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 () {
|
|
if (tmpDir) {
|
|
try {
|
|
rimraf.sync(tmpDir);
|
|
} catch (err) {
|
|
// Try our best to clean up but don't fail the test if we can't
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|