From 5922047f6bbd2c61705f46986bcf0c19da6cb4fa Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Wed, 14 Apr 2021 08:43:45 -0700 Subject: [PATCH] Add Import smoke test (#15111) * Add smoke test * Add wait for service * Also revert liveshare * fixes * Use custom extensions dir * fix * compile extensions * Use build extensions dir * test break * revert * revert yarn.lock * Add comment * Add comments --- .../darwin/sql-product-build-darwin.yml | 7 ++++++- test/automation/src/code.ts | 5 +++-- test/automation/src/statusbar.ts | 5 +++-- test/smoke/src/main.ts | 13 ++++++++++--- .../smoke/src/sql/areas/import/import.test.ts | 19 +++++++++++++++++++ test/smoke/src/sql/main.ts | 2 ++ 6 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 test/smoke/src/sql/areas/import/import.test.ts diff --git a/build/azure-pipelines/darwin/sql-product-build-darwin.yml b/build/azure-pipelines/darwin/sql-product-build-darwin.yml index cfa24c508d..67a1a061ae 100644 --- a/build/azure-pipelines/darwin/sql-product-build-darwin.yml +++ b/build/azure-pipelines/darwin/sql-product-build-darwin.yml @@ -122,11 +122,16 @@ steps: displayName: Run integration tests (Electron) condition: and(succeeded(), eq(variables['RUN_TESTS'], 'true')) + - script: | + set -e + yarn gulp compile-extensions + displayName: Compile Extensions + - script: | set -e APP_ROOT=$(agent.builddirectory)/azuredatastudio-darwin-x64 APP_NAME="`ls $APP_ROOT | head -n 1`" - yarn smoketest --build "$APP_ROOT/$APP_NAME" --screenshots "$(build.artifactstagingdirectory)/smokeshots" --log "$(build.artifactstagingdirectory)/logs/darwin/smoke.log" + yarn smoketest --build "$APP_ROOT/$APP_NAME" --screenshots "$(build.artifactstagingdirectory)/smokeshots" --log "$(build.artifactstagingdirectory)/logs/darwin/smoke.log" --extensionsDir "$(build.sourcesdirectory)/extensions" displayName: Run smoke tests (Electron) continueOnError: true condition: and(succeeded(), eq(variables['RUN_TESTS'], 'true')) diff --git a/test/automation/src/code.ts b/test/automation/src/code.ts index 672482fdf2..6778ac5ed5 100644 --- a/test/automation/src/code.ts +++ b/test/automation/src/code.ts @@ -282,14 +282,15 @@ export class Code { await this.driver.exitApplication(); } - async waitForTextContent(selector: string, textContent?: string, accept?: (result: string) => boolean): Promise { + async waitForTextContent(selector: string, textContent?: string, accept?: (result: string) => boolean, retryCount?: number): Promise { // {{SQL CARBON EDIT}} Add retryCount const windowId = await this.getActiveWindowId(); accept = accept || (result => textContent !== undefined ? textContent === result : !!result); return await poll( () => this.driver.getElements(windowId, selector).then(els => els.length > 0 ? Promise.resolve(els[0].textContent) : Promise.reject(new Error('Element not found for textContent'))), s => accept!(typeof s === 'string' ? s : ''), - `get text content '${selector}'` + `get text content '${selector}'`, + retryCount // {{SQL CARBON EDIT}} Add retryCount ); } diff --git a/test/automation/src/statusbar.ts b/test/automation/src/statusbar.ts index 980d856c22..40ac72c05d 100644 --- a/test/automation/src/statusbar.ts +++ b/test/automation/src/statusbar.ts @@ -35,8 +35,9 @@ export class StatusBar { return this.code.waitForTextContent(this.getSelector(StatusBarElement.EOL_STATUS), eol); } - async waitForStatusbarText(title: string, text: string): Promise { - await this.code.waitForTextContent(`${this.mainSelector} .statusbar-item[title="${title}"]`, text); + // {{SQL CARBON EDIT}} Add retryCount + async waitForStatusbarText(title: string, text: string, retryCount?: number): Promise { + await this.code.waitForTextContent(`${this.mainSelector} .statusbar-item[title="${title}"]`, text, undefined, retryCount); } private getSelector(element: StatusBarElement): string { diff --git a/test/smoke/src/main.ts b/test/smoke/src/main.ts index 967f4347c9..a812cdf096 100644 --- a/test/smoke/src/main.ts +++ b/test/smoke/src/main.ts @@ -53,7 +53,8 @@ const opts = minimist(args, { 'wait-time', 'test-repo', 'screenshots', - 'log' + 'log', + 'extensionsDir' // {{SQL CARBON EDIT}} Let callers control extensions dir for non-packaged extensions ], boolean: [ 'verbose', @@ -67,8 +68,14 @@ const opts = minimist(args, { const testRepoUrl = 'https://github.com/Microsoft/azuredatastudio-smoke-test-repo.git'; const workspacePath = path.join(testDataPath, 'azuredatastudio-smoke-test-repo'); -const extensionsPath = path.join(testDataPath, 'extensions-dir'); -mkdirp.sync(extensionsPath); +// {{SQL CARBON EDIT}} Let callers control extensions dir for non-packaged extensions +let extensionsPath = opts.extensionsDir; +if (!extensionsPath) { + extensionsPath = path.join(testDataPath, 'extensions-dir'); + mkdirp.sync(extensionsPath); +} +console.log(`Using extensions dir : ${extensionsPath}`); + const screenshotsPath = opts.screenshots ? path.resolve(opts.screenshots) : null; if (screenshotsPath) { diff --git a/test/smoke/src/sql/areas/import/import.test.ts b/test/smoke/src/sql/areas/import/import.test.ts new file mode 100644 index 0000000000..3f90f47695 --- /dev/null +++ b/test/smoke/src/sql/areas/import/import.test.ts @@ -0,0 +1,19 @@ +/*--------------------------------------------------------------------------------------------- + * 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'; + +export function setup() { + describe('Import', () => { + + it('Opening import wizard without connection opens connection dialog', async function () { + const app = this.app as Application; + await app.workbench.quickaccess.runCommand('Flat File Import: Import Wizard'); + // Wait for the service to be downloaded and installed. This can take a while so set timeout to 5min (retryInterval default is 100ms) + await app.workbench.statusbar.waitForStatusbarText('', 'Flat File Import Service Started', 5 * 60 * 10); + await app.workbench.connectionDialog.waitForConnectionDialog(); + }); + }); +} diff --git a/test/smoke/src/sql/main.ts b/test/smoke/src/sql/main.ts index 1b6421ac60..dcdb01daf7 100644 --- a/test/smoke/src/sql/main.ts +++ b/test/smoke/src/sql/main.ts @@ -6,6 +6,7 @@ import { setup as setupQueryEditorTests, setupWeb as setupQueryEditorWebTests } from './areas/queryEditor/queryEditor.test'; 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 { ApplicationOptions } from '../../../automation'; import * as yazl from 'yauzl'; import * as fs from 'fs'; @@ -21,6 +22,7 @@ export function main(isWeb: boolean = false): void { } setupNotebookTests(); setupNotebookViewTests(); + setupImportTests(); } /* eslint-disable no-sync */