From ec2f2b19fb6b0fb7dac7f9a4e7444eeaadabe46f Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Tue, 22 Jun 2021 13:05:21 -0700 Subject: [PATCH] Wait for SqlToolsService to start before running smoke tests (#15864) --- test/automation/src/application.ts | 10 +++++++++- test/smoke/src/sql/areas/notebook/createBook.test.ts | 10 ++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/test/automation/src/application.ts b/test/automation/src/application.ts index a7151fe907..2264ed9e68 100644 --- a/test/automation/src/application.ts +++ b/test/automation/src/application.ts @@ -146,10 +146,18 @@ export class Application { await this.code.waitForWindowIds(ids => ids.length > 0); await this.code.waitForElement('.monaco-workbench'); + // {{SQL CARBON EDIT}} Wait for specified status bar items before considering the app ready - we wait for them together to avoid timing + // issues with the status bar items disappearing + const statusbarPromises: Promise[] = []; + if (this.remote) { - await this.code.waitForTextContent('.monaco-workbench .statusbar-item[id="status.host"]', ' TestResolver', undefined, 2000); + statusbarPromises.push(this.code.waitForTextContent('.monaco-workbench .statusbar-item[id="status.host"]', ' TestResolver', undefined, 2000)); } + // Wait for SQL Tools Service to start before considering the app ready + statusbarPromises.push(this.code.waitForTextContent('.monaco-workbench .statusbar-item[id="Microsoft.mssql"]', 'SQL Tools Service Started', undefined, 30000)); + await Promise.all(statusbarPromises); + // wait a bit, since focus might be stolen off widgets // as soon as they open (e.g. quick access) await new Promise(c => setTimeout(c, 1000)); diff --git a/test/smoke/src/sql/areas/notebook/createBook.test.ts b/test/smoke/src/sql/areas/notebook/createBook.test.ts index 336e51a5d0..76a696b0b3 100644 --- a/test/smoke/src/sql/areas/notebook/createBook.test.ts +++ b/test/smoke/src/sql/areas/notebook/createBook.test.ts @@ -20,9 +20,6 @@ export function setup() { 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); @@ -31,14 +28,13 @@ export function setup() { await app.workbench.createBookDialog.create(); const bookExists = await fs.stat(path.join(tmpDir, bookName)); assert(!!bookExists, 'Book was not created'); + // Wait a bit for the book to load in the viewlet before ending the test, otherwise we can get an error when it tries to read the deleted files + // TODO Instead it would be better to either not add the book to the viewlet to begin with or close it after the test is done 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 @@ -52,6 +48,8 @@ export function setup() { 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'); + // Wait a bit for the book to load in the viewlet before ending the test, otherwise we can get an error when it tries to read the deleted files + // TODO Instead it would be better to either not add the book to the viewlet to begin with or close it after the test is done await new Promise(r => setTimeout(r, 2500)); });