Smoke tests (#9814)

* move

* add inital test; need basic sqllite connection

* before sqlite

* sqlite

* add smoke tests

* working tests

* fix app names

* fix quick open

* fix smoke tests

* add win32 smoke tests

* fix smoke test

* fix win32 smoke

* no continue

* continue on error

* add vscode smokes

* remove vscode tests

* continue on error

* allow sqlite to use relative paths

* add linux smoke tests

* fix build files

* use dispatch instead of select

* fix linux build again

* fix darwin

* get select working

* try and use screen shots

* screen shots

* remove smoke tests linux

* try vscodes sqlite

* fix compile

* fix webpack

* fix deps

* try this again

* try force a rebuild

* try npm rebuild

* add sqlite to be rebuilt

* distro

* try vscode sqlite again

* revert changes to driver and simplify edits

* fix compile

* fix imports

* move sqlite out

* remove unneeded change

* add extensions path

* fix web tests

* no continue on error
This commit is contained in:
Anthony Dresser
2020-04-03 00:01:32 -07:00
committed by GitHub
parent 589de854d5
commit 6e6649d006
33 changed files with 234 additions and 244 deletions

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Application, getStandaloneServer } from '../../../../automation';
import { Application, getStandaloneServer } from '../../../../../automation';
export function setup() {
describe('profiler test suite', () => {

View File

@@ -0,0 +1,22 @@
/*---------------------------------------------------------------------------------------------
* 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('Query Editor', () => {
it('can open and connect file', async function () {
const app = this.app as Application;
await app.workbench.quickaccess.openFile('test.sql');
await app.workbench.queryEditor.commandBar.clickButton(3);
await app.workbench.connectionDialog.waitForConnectionDialog();
await app.code.waitForSetValue('.modal .modal-body select[aria-label="Connection type"]', 'Sqlite');
await app.code.waitForSetValue('.modal .modal-body input[aria-label="File"]', 'chinook.db');
await app.code.waitAndClick('.modal .modal-footer a[aria-label="Connect"]');
await app.workbench.queryEditor.commandBar.waitForButton(3, 'Disconnect');
});
});
}

View File

@@ -0,0 +1,94 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { setup as setupQueryEditorTest } from './areas/queryEditor/queryEditor.test';
import { ApplicationOptions } from '../../../automation';
import * as yazl from 'yauzl';
import * as fs from 'fs';
import * as path from 'path';
import { request } from 'https';
import * as mkdirp from 'mkdirp';
export function main(): void {
setupQueryEditorTest();
}
/* eslint-disable no-sync */
const PLATFORM = '${PLATFORM}';
const RUNTIME = '${RUNTIME}';
const VERSION = '${VERSION}';
const sqliteUrl = `https://github.com/anthonydresser/azuredatastudio-sqlite/releases/download/1.0.5/azuredatastudio-sqlite-${PLATFORM}-${RUNTIME}-${VERSION}.zip`;
export async function setup(app: ApplicationOptions): Promise<void> {
const requestUrl = sqliteUrl.replace(PLATFORM, process.platform).replace(RUNTIME, getRuntime(app.web || app.remote || false)).replace(VERSION, getVersion(app.web || app.remote || false));
const zip = await fetch(requestUrl);
return new Promise<void>((resolve, reject) => {
yazl.fromBuffer(zip, (e, zipFile) => {
if (e || !zipFile) {
reject(e);
return;
}
zipFile.on('entry', (entry: yazl.Entry) => {
if (/\/$/.test(entry.fileName)) {
return;
}
zipFile.openReadStream(entry, (err, readStream) => {
if (err || !readStream) {
reject(err);
return;
}
const destination = path.join(app.extensionsPath, 'azuredatastudio-sqlite', entry.fileName);
if (fs.existsSync(path.dirname(destination))) {
readStream.pipe(fs.createWriteStream(destination));
return;
}
mkdirp(path.dirname(destination), err => {
if (err) {
reject(err);
return;
}
readStream.pipe(fs.createWriteStream(destination));
});
});
}).once('end', () => resolve());
});
});
}
const root = path.dirname(path.dirname(path.dirname(path.dirname(__dirname))));
function getRuntime(remote: boolean) {
// eslint-disable-next-line no-sync
const yarnrc = fs.readFileSync(remote ? path.join(root, 'remote', '.yarnrc') : path.join(root, '.yarnrc'), 'utf8');
const runtime = /^runtime "(.*)"$/m.exec(yarnrc)![1];
return runtime;
}
function getVersion(remote: boolean) {
// eslint-disable-next-line no-sync
const yarnrc = fs.readFileSync(remote ? path.join(root, 'remote', '.yarnrc') : path.join(root, '.yarnrc'), 'utf8');
const target = /^target "(.*)"$/m.exec(yarnrc)![1];
return target;
}
function fetch(url: string): Promise<Buffer> {
return new Promise<Buffer>((resolve, reject) => {
const buffers: Buffer[] = [];
const req = request(url, res => {
if (res.headers.location) {
resolve(fetch(res.headers.location));
} else {
res.on('data', chunk => buffers.push(chunk));
res.on('end', () => resolve(Buffer.concat(buffers)));
res.on('error', e => reject(e));
}
});
req.end();
});
}

View File

@@ -1,28 +0,0 @@
/*---------------------------------------------------------------------------------------------
* 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 os from 'os';
import * as path from 'path';
export function setup() {
describe('Query Editor Test Suite', () => {
it('Can open and edit existing file', async function () {
const testFilePath = path.join(os.tmpdir(), 'QueryEditorSmokeTest.sql');
await fs.writeFile(testFilePath, '');
try {
const app = this.app as Application;
await app.workbench.quickaccess.openFile(testFilePath);
const fileBaseName = path.basename(testFilePath);
await app.workbench.editor.waitForTypeInEditor(fileBaseName, 'SELECT * FROM sys.tables');
}
finally {
await fs.unlink(testFilePath);
}
});
});
}