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

@@ -17,6 +17,7 @@
"@types/ncp": "2.0.1",
"@types/node": "^12.19.9",
"@types/rimraf": "^2.0.4",
"@types/tmp": "0.0.33",
"cpx": "^1.5.0",
"htmlparser2": "^3.9.2",
"mkdirp": "^0.5.1",

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();
}

View File

@@ -63,6 +63,11 @@
"@types/glob" "*"
"@types/node" "*"
"@types/tmp@0.0.33":
version "0.0.33"
resolved "https://registry.yarnpkg.com/@types/tmp/-/tmp-0.0.33.tgz#1073c4bc824754ae3d10cfab88ab0237ba964e4d"
integrity sha1-EHPEvIJHVK49EM+riKsCN7qWTk0=
ansi-styles@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"