Add smoke test for Create Book dialog (#15714)

* Add smoke test for Create Book dialog

* Add comment

* Update distro

* update distro 2

* distro
This commit is contained in:
Charles Gagnon
2021-06-16 10:54:04 -07:00
committed by GitHub
parent 4c039f7a88
commit be1ff8e37b
7 changed files with 100 additions and 1 deletions

View File

@@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------------------------
* 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';
export function setup() {
const bookName = 'my-book';
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('Jupyter Books: Create Jupyter Book');
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'));
assert(!!bookExists, 'Book was not created');
});
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
}
}
});
});
}

View File

@@ -7,6 +7,7 @@ import { setup as setupQueryEditorTests, setupWeb as setupQueryEditorWebTests }
import { setup as setupNotebookTests } from './areas/notebook/notebook.test';
import { setup as setupNotebookViewTests } from './areas/notebook/notebookView.test';
import { setup as setupImportTests } from './areas/import/import.test';
import { setup as setupCreateBookDialogTests } from './areas/notebook/createBook.test';
import { ApplicationOptions } from '../../../automation';
import * as yazl from 'yauzl';
import * as fs from 'fs';
@@ -22,6 +23,7 @@ export function main(isWeb: boolean = false): void {
}
setupNotebookTests();
setupNotebookViewTests();
setupCreateBookDialogTests();
setupImportTests();
}