smoke: this breaks more often than I'd like

This commit is contained in:
Joao Moreno 2017-09-25 19:47:01 +02:00
parent c8f5358f36
commit b82fa8dcb0
8 changed files with 44 additions and 32 deletions

View file

@ -16,9 +16,8 @@ describe('CSS', () => {
it('verifies quick outline', async () => {
await app.workbench.quickopen.openFile('style.css');
const outline = await app.workbench.editor.openOutline();
await outline.waitForQuickOpenElements(2);
await app.workbench.editor.openOutline();
await app.workbench.quickopen.waitForQuickOpenElements(names => names.length === 2);
});
it('verifies warnings for the empty rule', async () => {

View file

@ -46,7 +46,7 @@ describe('Debug', () => {
it('configure launch json', async function () {
await app.workbench.debug.openDebugViewlet();
await app.workbench.openFile('app.js');
await app.workbench.quickopen.openFile('app.js');
await app.workbench.debug.configure();
const launchJsonPath = path.join(WORKSPACE_PATH, '.vscode', 'launch.json');
@ -68,7 +68,7 @@ describe('Debug', () => {
});
it('breakpoints', async function () {
await app.workbench.openFile('index.js');
await app.workbench.quickopen.openFile('index.js');
await app.workbench.debug.setBreakpointOnLine(6);
await app.screenCapturer.capture('breakpoints are set');
});

View file

@ -16,9 +16,8 @@ describe('Editor', () => {
it('shows correct quick outline', async function () {
await app.workbench.quickopen.openFile('www');
const outline = await app.workbench.editor.openOutline();
await outline.waitForQuickOpenElements(12);
await app.workbench.editor.openOutline();
await app.workbench.quickopen.waitForQuickOpenElements(names => names.length === 12);
});
it(`finds 'All References' to 'app'`, async function () {

View file

@ -12,20 +12,32 @@ describe('Explorer', () => {
beforeEach(function () { app.screenCapturer.testName = this.currentTest.title; });
it('quick open search produces correct result', async function () {
const expectedNames = [
'.eslintrc.json',
'tasks.json',
'app.js',
'index.js',
'users.js',
'package.json',
'jsconfig.json'
];
await app.workbench.quickopen.openQuickOpen();
await app.client.type('.js');
await app.workbench.quickopen.waitForQuickOpenElements(7);
await app.workbench.quickopen.waitForQuickOpenElements(names => expectedNames.every(n => names.some(m => n === m)));
await app.client.keys(['Escape', 'NULL']);
});
it('quick open respects fuzzy matching', async function () {
const expectedNames = [
'tasks.json',
'app.js',
'package.json'
];
await app.workbench.quickopen.openQuickOpen();
await app.client.type('a.s');
await app.workbench.quickopen.waitForQuickOpenElements(3);
await app.workbench.quickopen.waitForQuickOpenElements(names => expectedNames.every(n => names.some(m => n === m)));
await app.client.keys(['Escape', 'NULL']);
});
});

View file

@ -19,11 +19,11 @@ describe('Git', () => {
it('reflects working tree changes', async function () {
await app.workbench.scm.openSCMViewlet();
await app.workbench.openFile('app.js');
await app.workbench.quickopen.openFile('app.js');
await app.client.type('.foo{}');
await app.workbench.saveOpenedFile();
await app.workbench.openFile('index.jade');
await app.workbench.quickopen.openFile('index.jade');
await app.client.type('hello world');
await app.workbench.saveOpenedFile();

View file

@ -7,7 +7,7 @@ import * as assert from 'assert';
import { SpectronApplication, CODE_WORKSPACE_PATH, VSCODE_BUILD } from '../../spectron/application';
import { Window } from '../window';
describe('Multi Root', () => {
describe('Multiroot', () => {
let app: SpectronApplication = new SpectronApplication(void 0, CODE_WORKSPACE_PATH);
if (app.build === VSCODE_BUILD.STABLE) {
return;
@ -20,7 +20,8 @@ describe('Multi Root', () => {
it('shows results from all folders', async function () {
await app.workbench.quickopen.openQuickOpen();
await app.workbench.quickopen.type('*.*');
await app.workbench.quickopen.waitForQuickOpenElements(6);
await app.workbench.quickopen.waitForQuickOpenElements(names => names.length >= 6);
await app.workbench.quickopen.closeQuickOpen();
});

View file

@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import { SpectronApplication } from '../../spectron/application';
import { Element } from 'webdriverio';
export class QuickOpen {
@ -36,19 +35,11 @@ export class QuickOpen {
await this.spectron.client.type(text);
}
async getQuickOpenElements(): Promise<Element[]> {
return this.spectron.client.waitForElements(QuickOpen.QUICK_OPEN_ENTRY_SELECTOR);
}
async waitForQuickOpenElements(count: number): Promise<Element[]> {
return this.spectron.client.waitForElements(QuickOpen.QUICK_OPEN_ENTRY_SELECTOR, elements => elements && elements.length === count);
}
async openFile(fileName: string): Promise<void> {
await this.openQuickOpen();
await this.type(fileName);
await this.getQuickOpenElements();
await this.waitForQuickOpenElements(names => names.some(n => n === fileName));
await this.spectron.client.keys(['Enter', 'NULL']);
await this.spectron.workbench.waitForActiveTab(fileName);
await this.spectron.workbench.waitForEditorFocus(fileName);
@ -93,4 +84,18 @@ export class QuickOpen {
await this.spectron.client.keys(['Enter', 'NULL']);
await this.waitForQuickOpenClosed();
}
async waitForQuickOpenElements(accept: (names: string[]) => boolean): Promise<void> {
await this.spectron.client.waitFor(() => this.getQuickOpenElements(), accept);
}
private async getQuickOpenElements(): Promise<string[]> {
return await this.spectron.webclient.selectorExecute(QuickOpen.QUICK_OPEN_ENTRY_SELECTOR,
div => (Array.isArray(div) ? div : [div]).map(element => {
const name = element.querySelector('.label-name') as HTMLElement;
return name.textContent;
})
);
}
}

View file

@ -83,8 +83,4 @@ export class Workbench {
await this.spectron.command('workbench.action.files.newUntitledFile');
await this.waitForEditorFocus('Untitled-1', true);
}
async openFile(fileName: string): Promise<void> {
await this.quickopen.openFile(fileName);
}
}