further smoke test improvements

This commit is contained in:
Joao 2017-09-04 14:54:26 +02:00
parent eec1386efe
commit 12d8f1c97e
14 changed files with 69 additions and 117 deletions

View file

@ -10,18 +10,11 @@ import { ProblemSeverity, Problems } from '../problems/problems';
import { QuickOutline } from '../editor/quickoutline';
import { SettingsEditor } from '../preferences/settings';
let app: SpectronApplication;
export function testCSS() {
describe('CSS', () => {
beforeEach(async function () {
app = new SpectronApplication(LATEST_PATH, this.currentTest.fullTitle(), (this.currentTest as any).currentRetry(), [WORKSPACE_PATH]);
return await app.start();
});
afterEach(async function () {
return await app.stop();
});
let app: SpectronApplication = new SpectronApplication(LATEST_PATH, '', 0, [WORKSPACE_PATH]);
before(() => app.start());
after(() => app.stop());
it('verifies quick outline', async function () {
await app.workbench.quickopen.openFile('style.css');
@ -43,6 +36,7 @@ export function testCSS() {
await problems.showProblemsView();
warning = await app.client.waitForElement(Problems.getSelectorInProblemsView(ProblemSeverity.WARNING));
assert.ok(warning, 'Warning does not appear in Problems view.');
await problems.hideProblemsView();
});
it('verifies that warning becomes an error once setting changed', async function () {
@ -57,6 +51,7 @@ export function testCSS() {
await problems.showProblemsView();
error = await app.client.waitForElement(Problems.getSelectorInProblemsView(ProblemSeverity.ERROR));
assert.ok(error, 'Warning does not appear in Problems view.');
await problems.hideProblemsView();
});
});
}

View file

@ -7,24 +7,19 @@ import * as assert from 'assert';
import { SpectronApplication, LATEST_PATH, WORKSPACE_PATH } from '../../spectron/application';
let app: SpectronApplication;
export function testExplorer() {
describe('Explorer', () => {
beforeEach(async function () {
app = new SpectronApplication(LATEST_PATH, this.currentTest.fullTitle(), (this.currentTest as any).currentRetry(), [WORKSPACE_PATH]);
return await app.start();
});
afterEach(async function () {
return await app.stop();
});
let app: SpectronApplication = new SpectronApplication(LATEST_PATH, '', 0, [WORKSPACE_PATH]);
before(() => app.start());
after(() => app.stop());
it('quick open search produces correct result', async function () {
await app.workbench.quickopen.openQuickOpen();
await app.client.type('.js');
const elements = await app.workbench.quickopen.getQuickOpenElements();
assert.equal(elements.length, 7);
await app.client.keys(['Escape', 'NULL']);
assert.equal(elements.length, 7, 'There are 7 elements in quick open');
});
it('quick open respects fuzzy matching', async function () {
@ -32,7 +27,9 @@ export function testExplorer() {
await app.client.type('a.s');
const elements = await app.workbench.quickopen.getQuickOpenElements();
assert.equal(elements.length, 3);
await app.client.keys(['Escape', 'NULL']);
assert.equal(elements.length, 3, 'There are 3 elements in quick open');
});
});
}

View file

@ -5,34 +5,20 @@
import * as assert from 'assert';
import { SpectronApplication, LATEST_PATH, WORKSPACE_PATH, EXTENSIONS_DIR } from '../../spectron/application';
import { Util } from '../../helpers/utilities';
var dns = require('dns');
let app: SpectronApplication;
import { SpectronApplication, LATEST_PATH, WORKSPACE_PATH } from '../../spectron/application';
export function testExtensions() {
describe('Extensions', () => {
const extensionName = 'vscode-smoketest-check';
let app: SpectronApplication = new SpectronApplication(LATEST_PATH, '', 0, [WORKSPACE_PATH]);
before(() => app.start());
after(() => app.stop());
beforeEach(async function () {
const network = await networkAttached();
if (!network) {
return Promise.reject('There is no network connection for testing extensions.');
}
app = new SpectronApplication(LATEST_PATH, this.currentTest.fullTitle(), (this.currentTest as any).currentRetry(), [WORKSPACE_PATH, `--extensions-dir=${EXTENSIONS_DIR}`]);
await Util.rimraf(EXTENSIONS_DIR);
return await app.start();
});
afterEach(async function () {
await app.stop();
await Util.rimraf(EXTENSIONS_DIR);
});
// this used to run before each test
// await Util.rimraf(EXTENSIONS_DIR);
it(`install and activate vscode-smoketest-check extension`, async function () {
const extensionName = 'vscode-smoketest-check';
await app.workbench.extensions.openExtensionsViewlet();
const installed = await app.workbench.extensions.installExtension(extensionName);
@ -49,11 +35,3 @@ export function testExtensions() {
});
}
function networkAttached(): Promise<boolean> {
return new Promise((res, rej) => {
dns.resolve('marketplace.visualstudio.com', (err) => {
err ? res(false) : res(true);
});
});
}

View file

@ -9,19 +9,11 @@ import { SpectronApplication, LATEST_PATH, CODE_WORKSPACE_PATH } from '../../spe
import { QuickOpen } from '../quickopen/quickopen';
import { Window } from '../window';
let app: SpectronApplication;
export function testMultiRoot() {
describe('Multi Root', () => {
beforeEach(async function () {
app = new SpectronApplication(LATEST_PATH, this.currentTest.fullTitle(), (this.currentTest as any).currentRetry(), [CODE_WORKSPACE_PATH]);
return app.start();
});
afterEach(async function () {
return app.stop();
});
let app: SpectronApplication = new SpectronApplication(LATEST_PATH, '', 0, [CODE_WORKSPACE_PATH]);
before(() => app.start());
after(() => app.stop());
it('shows results from all folders', async function () {
let quickOpen = new QuickOpen(app);

View file

@ -6,26 +6,15 @@
import * as assert from 'assert';
import { SpectronApplication, LATEST_PATH, WORKSPACE_PATH } from '../../spectron/application';
import { CommonActions } from '../../areas/common';
import { ActivityBarPosition } from '../../areas/activitybar/activityBar';
import { KeybindingsEditor } from './keybindings';
let app: SpectronApplication;
let common: CommonActions;
export function testKeybindings() {
describe('Keybindings Customisation', () => {
beforeEach(async function () {
app = new SpectronApplication(LATEST_PATH, this.currentTest.fullTitle(), (this.currentTest as any).currentRetry(), [WORKSPACE_PATH]);
common = new CommonActions(app);
return await app.start();
});
afterEach(async function () {
await app.stop();
});
let app: SpectronApplication = new SpectronApplication(LATEST_PATH, '', 0, [WORKSPACE_PATH]);
before(() => app.start());
after(() => app.stop());
it(`changes 'workbench.action.toggleSidebarPosition' command key binding and verifies it`, async function () {
let activityBarElement = await app.workbench.activitybar.getActivityBar(ActivityBarPosition.LEFT);

View file

@ -8,19 +8,11 @@ import * as assert from 'assert';
import { SpectronApplication, LATEST_PATH, WORKSPACE_PATH } from '../../spectron/application';
import { SettingsEditor } from './settings';
let app: SpectronApplication;
export function testSettings() {
describe('Settings Customisation', () => {
beforeEach(async function () {
app = new SpectronApplication(LATEST_PATH, this.currentTest.fullTitle(), (this.currentTest as any).currentRetry(), [WORKSPACE_PATH]);
return await app.start();
});
afterEach(async function () {
await app.stop();
});
let app: SpectronApplication = new SpectronApplication(LATEST_PATH, '', 0, [WORKSPACE_PATH]);
before(() => app.start());
after(() => app.stop());
it('turns off editor line numbers and verifies the live change', async function () {
await app.workbench.explorer.openFile('app.js');

View file

@ -19,7 +19,7 @@ export class SettingsEditor {
public async openUserSettings(): Promise<Element> {
await this.spectron.command('workbench.action.openGlobalSettings');
return this.spectron.client.waitForElement('.settings-search-input .synthetic-focus');
return this.spectron.client.waitForElement('.settings-search-input input:focus');
}
public async focusEditableSettings(): Promise<void> {
@ -30,6 +30,8 @@ export class SettingsEditor {
public async addUserSetting(setting: string, value: string): Promise<void> {
await this.openUserSettings();
// await this.spectron.wait(1);
await this.focusEditableSettings();
await this.spectron.client.keys(`"${setting}": ${value}`);
await this.spectron.workbench.saveOpenedFile();

View file

@ -17,8 +17,27 @@ export class Problems {
}
public async showProblemsView(): Promise<any> {
const panelSelector = '.panel.markers-panel';
const result = await this.spectron.client.element(panelSelector);
if (result) {
return;
}
await this.spectron.command('workbench.actions.view.problems');
await this.spectron.client.waitForElement('.panel.markers-panel');
await this.spectron.client.waitForElement(panelSelector);
}
public async hideProblemsView(): Promise<any> {
const panelSelector = '.panel.markers-panel';
const result = await this.spectron.client.element(panelSelector);
if (!result) {
return;
}
await this.spectron.command('workbench.actions.view.problems');
await this.spectron.client.waitForElement(panelSelector, el => !el);
}
public static getSelectorInProblemsView(problemType: ProblemSeverity): string {

View file

@ -7,18 +7,11 @@ import * as assert from 'assert';
import { SpectronApplication, LATEST_PATH, WORKSPACE_PATH } from '../../spectron/application';
let app: SpectronApplication;
export function testSearch() {
describe('Search', () => {
beforeEach(async function () {
app = new SpectronApplication(LATEST_PATH, this.currentTest.fullTitle(), (this.currentTest as any).currentRetry(), [WORKSPACE_PATH]);
return await app.start();
});
afterEach(async function () {
return await app.stop();
});
let app: SpectronApplication = new SpectronApplication(LATEST_PATH, '', 0, [WORKSPACE_PATH]);
before(() => app.start());
after(() => app.stop());
it('searches for body & checks for correct result number', async function () {
await app.workbench.search.openSearchViewlet();

View file

@ -6,21 +6,15 @@
import * as assert from 'assert';
import { SpectronApplication, USER_DIR, LATEST_PATH, WORKSPACE_PATH } from '../../spectron/application';
import { Util } from '../../helpers/utilities';
let app: SpectronApplication;
export function testDataLoss() {
describe('Data Loss', () => {
let app: SpectronApplication = new SpectronApplication(LATEST_PATH, '', 0, [WORKSPACE_PATH], [`--user-data-dir=${USER_DIR}`]);
before(() => app.start());
after(() => app.stop());
beforeEach(async function () {
app = new SpectronApplication(LATEST_PATH, this.currentTest.fullTitle(), (this.currentTest as any).currentRetry(), [WORKSPACE_PATH], [`--user-data-dir=${USER_DIR}`]);
await Util.rimraf(USER_DIR);
return await app.start();
});
afterEach(async function () {
return await app.stop();
});
// this used to run before each test
// await Util.rimraf(USER_DIR);
it(`verifies that 'hot exit' works for dirty files`, async function () {
const textToType = 'Hello, Code', fileName = 'readme.md', untitled = 'Untitled-1';

View file

@ -124,7 +124,7 @@ async function main(): Promise<void> {
}
console.log('Running npm install...');
cp.execSync('npm install', { cwd: testRepoLocalDir, stdio: 'inherit' });
// cp.execSync('npm install', { cwd: testRepoLocalDir, stdio: 'inherit' });
console.log('Running tests...');
const mocha = cp.spawnSync(process.execPath, ['out/mocha-runner.js'], { cwd: path.join(__dirname, '..'), stdio: 'inherit' });

View file

@ -12,8 +12,8 @@ import { RawResult, Element } from 'webdriverio';
*/
export class SpectronClient {
private readonly trials = 50;
private readonly trialWait = 100; // in milliseconds
private readonly retryCount = 50;
private readonly retryDuration = 100; // in milliseconds
constructor(private spectron: Application, private shot: IScreenshot) {
}
@ -164,8 +164,8 @@ export class SpectronClient {
let trial = 1;
while (true) {
if (trial > this.trials) {
return new Promise<T>((res, rej) => rej(`${timeoutMessage}: Timed out after ${this.trials * this.trialWait} seconds.`));
if (trial > this.retryCount) {
throw new Error(`${timeoutMessage}: Timed out after ${this.retryCount * this.retryDuration} seconds.`);
}
let result;
@ -179,7 +179,7 @@ export class SpectronClient {
return result;
}
await new Promise(resolve => setTimeout(resolve, this.trialWait));
await new Promise(resolve => setTimeout(resolve, this.retryDuration));
trial++;
}
}

View file

@ -14,6 +14,7 @@ import { testDataLoss } from './areas/workbench/data-loss.test';
// import { testDataMigration } from './areas/workbench/data-migration.test';
describe('Smoke:', () => {
testCSS();
testExplorer();
testSettings();

View file

@ -18,4 +18,4 @@
"exclude": [
"node_modules"
]
}
}