提交 9e40cc9d 编写于 作者: S Sandeep Somavarapu

smoke test: Improve quick open behaviour

上级 526c71c4
......@@ -15,10 +15,10 @@ describe('CSS', () => {
it('verifies quick outline', async () => {
await app.workbench.quickopen.openFile('style.css');
const outline = await app.workbench.editor.openOutline();
const elements = await outline.getQuickOpenElements();
await app.screenCapturer.capture('CSS Outline result');
assert.equal(elements.length, 2, `Did not find two outline elements`);
await outline.waitForQuickOpenElements(2);
});
it('verifies warnings for the empty rule', async () => {
......
......@@ -104,7 +104,7 @@ export class Debug extends Viewlet {
}
async console(text: string, type: string): Promise<string> {
await this.spectron.workbench.commandPallette.runCommand('Debug: Focus Debug Console');
await this.spectron.workbench.quickopen.runCommand('Debug: Focus Debug Console');
await this.spectron.client.waitForElement(REPL_FOCUSED);
await this.spectron.client.type(text);
await this.spectron.client.waitForElement(CONSOLE_INPUT_OUTPUT + ` .${type}`);
......
......@@ -18,9 +18,7 @@ describe('Editor', () => {
const outline = await app.workbench.editor.openOutline();
const symbols = await outline.getQuickOpenElements();
await app.screenCapturer.capture('Javascript Outline result');
assert.equal(symbols.length, 12, 'Quick outline elements count does not match to expected.');
await outline.waitForQuickOpenElements(12);
});
it(`finds 'All References' to 'app'`, async function () {
......
......@@ -35,7 +35,7 @@ export class Editor {
public async findReferences(term: string, line: number): Promise<References> {
await this.clickOnTerm(term, line);
await this.spectron.workbench.commandPallette.runCommand('Find All References');
await this.spectron.workbench.quickopen.runCommand('Find All References');
const references = new References(this.spectron);
await references.waitUntilOpen();
return references;
......@@ -43,7 +43,7 @@ export class Editor {
public async rename(term: string, line: number): Promise<Rename> {
await this.clickOnTerm(term, line);
await this.spectron.workbench.commandPallette.runCommand('Rename Symbol');
await this.spectron.workbench.quickopen.runCommand('Rename Symbol');
const rename = new Rename(term, this.spectron);
await rename.waitUntilOpen();
return rename;
......@@ -51,12 +51,12 @@ export class Editor {
public async gotoDefinition(term: string, line: number): Promise<void> {
await this.clickOnTerm(term, line);
await this.spectron.workbench.commandPallette.runCommand('Go to Definition');
await this.spectron.workbench.quickopen.runCommand('Go to Definition');
}
public async peekDefinition(term: string, line: number): Promise<References> {
await this.clickOnTerm(term, line);
await this.spectron.workbench.commandPallette.runCommand('Peek Definition');
await this.spectron.workbench.quickopen.runCommand('Peek Definition');
const peek = new References(this.spectron);
await peek.waitUntilOpen();
return peek;
......
......@@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { SpectronApplication } from '../../spectron/application';
describe('Explorer', () => {
......@@ -14,22 +13,19 @@ describe('Explorer', () => {
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();
await app.client.keys(['Escape', 'NULL']);
await app.screenCapturer.capture('Quick open result');
assert.equal(elements.length, 7, 'There are 7 elements in quick open');
await app.workbench.quickopen.waitForQuickOpenElements(7);
await app.client.keys(['Escape', 'NULL']);
});
it('quick open respects fuzzy matching', async function () {
await app.workbench.quickopen.openQuickOpen();
await app.client.type('a.s');
const elements = await app.workbench.quickopen.getQuickOpenElements();
await app.workbench.quickopen.waitForQuickOpenElements(3);
await app.client.keys(['Escape', 'NULL']);
await app.screenCapturer.capture('fuzzy match result');
assert.equal(elements.length, 3, 'There are 3 elements in quick open');
});
});
\ No newline at end of file
......@@ -22,7 +22,7 @@ describe('Extensions', () => {
await app.reload();
await app.workbench.extensions.waitForExtensionsViewlet();
await app.workbench.commandPallette.runCommand('Smoke Test Check');
await app.workbench.quickopen.runCommand('Smoke Test Check');
const statusbarText = await app.workbench.statusbar.getStatusbarTextByTitle('smoke test');
await app.screenCapturer.capture('Statusbar');
......
......@@ -68,7 +68,7 @@ describe('Git', () => {
await app.workbench.scm.commit('first commit');
await app.client.waitForText(SYNC_STATUSBAR, ' 0↓ 1↑');
await app.workbench.commandPallette.runCommand('Git: Stage All Changes');
await app.workbench.quickopen.runCommand('Git: Stage All Changes');
await app.workbench.scm.waitForChange(c => c.name === 'index.jade' && c.type === 'Index Modified');
await app.workbench.scm.commit('second commit');
......
......@@ -5,7 +5,6 @@
import * as assert from 'assert';
import { SpectronApplication, CODE_WORKSPACE_PATH, VSCODE_BUILD } from '../../spectron/application';
import { QuickOpen } from '../quickopen/quickopen';
import { Window } from '../window';
describe('Multi Root', () => {
......@@ -19,12 +18,11 @@ describe('Multi Root', () => {
beforeEach(function () { app.screenCapturer.testName = this.currentTest.title; });
it('shows results from all folders', async function () {
let quickOpen = new QuickOpen(app);
await quickOpen.openQuickOpen();
await app.client.type('*.*');
const elements = await quickOpen.getQuickOpenElements();
await app.screenCapturer.capture('quick open result');
assert.equal(elements.length, 6);
await app.workbench.quickopen.openQuickOpen();
await app.workbench.quickopen.type('*.*');
await app.workbench.quickopen.waitForQuickOpenElements(6);
});
it('shows workspace name in title', async function () {
......
......@@ -8,6 +8,10 @@ import { Element } from 'webdriverio';
export class QuickOpen {
static QUICK_OPEN_HIDDEN = 'div.quick-open-widget[aria-hidden="true"]';
static QUICK_OPEN = 'div.quick-open-widget[aria-hidden="false"]';
static QUICK_OPEN_FOCUSSED_INPUT = `${QuickOpen.QUICK_OPEN} .quick-open-input input:focus`;
static QUICK_OPEN_FOCUSED_ELEMENT = `${QuickOpen.QUICK_OPEN} .quick-open-tree .monaco-tree-row.focused .monaco-highlighted-label`;
static QUICK_OPEN_ENTRY_SELECTOR = 'div[aria-label="Quick Picker"] .monaco-tree-rows.show-twisties .monaco-tree-row .quick-open-entry';
constructor(readonly spectron: SpectronApplication) {
......@@ -23,13 +27,23 @@ export class QuickOpen {
await this.waitForQuickOpenClosed();
}
public async type(text: string): Promise<void> {
await this.spectron.client.keys([text, 'NULL']);
await this.spectron.client.waitForValue(QuickOpen.QUICK_OPEN_FOCUSSED_INPUT, text);
}
public async getQuickOpenElements(): Promise<Element[]> {
return this.spectron.client.waitForElements(QuickOpen.QUICK_OPEN_ENTRY_SELECTOR);
}
public async waitForQuickOpenElements(count: number): Promise<Element[]> {
return this.spectron.client.waitForElements(QuickOpen.QUICK_OPEN_ENTRY_SELECTOR, elements => elements && elements.length === count);
}
public async openFile(fileName: string): Promise<void> {
await this.openQuickOpen();
await this.spectron.client.type(fileName);
await this.type(fileName);
await this.getQuickOpenElements();
await this.spectron.client.keys(['Enter', 'NULL']);
await this.spectron.client.waitForElement(`.tabs-container div[aria-selected="true"][aria-label="${fileName}, tab"]`);
......@@ -37,12 +51,25 @@ export class QuickOpen {
await this.spectron.workbench.waitForEditorFocus(fileName);
}
public async runCommand(commandText: string): Promise<void> {
await this.openQuickOpen();
// type the text
await this.type(`>${commandText}`);
// wait for best choice to be focused
await this.spectron.client.waitForTextContent(QuickOpen.QUICK_OPEN_FOCUSED_ELEMENT, commandText);
// wait and click on best choice
await this.spectron.client.waitAndClick(QuickOpen.QUICK_OPEN_FOCUSED_ELEMENT);
}
protected waitForQuickOpenOpened(): Promise<Element> {
return this.spectron.client.waitForElement('.quick-open-widget .quick-open-input input:focus');
return this.spectron.client.waitForElement(QuickOpen.QUICK_OPEN_FOCUSSED_INPUT);
}
protected waitForQuickOpenClosed(): Promise<Element> {
return this.spectron.client.waitForElement('div.quick-open-widget[aria-hidden="true"]');
return this.spectron.client.waitForElement(QuickOpen.QUICK_OPEN_HIDDEN);
}
public async isQuickOpenVisible(): Promise<boolean> {
......
......@@ -16,7 +16,7 @@ export class Terminal {
public async showTerminal(): Promise<void> {
if (!await this.isVisible()) {
await this.spectron.workbench.commandPallette.runCommand('View: Toggle Integrated Terminal');
await this.spectron.workbench.quickopen.runCommand('View: Toggle Integrated Terminal');
await this.spectron.client.waitForElement(Terminal.TERMINAL_CURSOR);
await this.waitForTerminalText(text => text.length > 0, 'Waiting for Terminal to be ready');
}
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { QuickOpen } from '../quickopen/quickopen';
const QUICK_OPEN_INPUT = '.quick-open-widget .quick-open-input input';
const QUICK_OPEN_FOCUSED_ELEMENT = '.quick-open-widget .quick-open-tree .monaco-tree-row.focused .monaco-highlighted-label';
export class CommandPallette extends QuickOpen {
public async runCommand(commandText: string): Promise<void> {
// run command
await this.spectron.command('workbench.action.showCommands');
// wait for quick open
await this.waitForQuickOpenOpened();
// type the text
await this.spectron.client.keys([commandText, 'NULL']);
// wait for text to be in input box
await this.spectron.client.waitForValue(QUICK_OPEN_INPUT, `>${commandText}`);
// wait for best choice to be focused
await this.spectron.client.waitForTextContent(QUICK_OPEN_FOCUSED_ELEMENT, commandText);
// wait and click on best choice
await this.spectron.client.waitAndClick(QUICK_OPEN_FOCUSED_ELEMENT);
}
}
......@@ -8,7 +8,6 @@ import { Explorer } from '../explorer/explorer';
import { ActivityBar } from '../activitybar/activityBar';
import { QuickOpen } from '../quickopen/quickopen';
import { Extensions } from '../extensions/extensions';
import { CommandPallette } from './commandPallette';
import { Search } from '../search/search';
import { Editor } from '../editor/editor';
import { SCM } from '../git/scm';
......@@ -23,7 +22,6 @@ export class Workbench {
readonly explorer: Explorer;
readonly activitybar: ActivityBar;
readonly commandPallette: CommandPallette;
readonly quickopen: QuickOpen;
readonly search: Search;
readonly extensions: Extensions;
......@@ -40,7 +38,6 @@ export class Workbench {
this.explorer = new Explorer(spectron);
this.activitybar = new ActivityBar(spectron);
this.quickopen = new QuickOpen(spectron);
this.commandPallette = new CommandPallette(spectron);
this.search = new Search(spectron);
this.extensions = new Extensions(spectron);
this.editor = new Editor(spectron);
......
......@@ -79,7 +79,7 @@ export class SpectronApplication {
}
public async reload(): Promise<any> {
await this.workbench.commandPallette.runCommand('Reload Window');
await this.workbench.quickopen.runCommand('Reload Window');
// TODO @sandy: Find a proper condition to wait for reload
await this.wait(.5);
await this.checkWindowReady();
......@@ -165,7 +165,7 @@ export class SpectronApplication {
public command(command: string, capture?: boolean): Promise<any> {
const binding = this.keybindings.find(x => x['command'] === command);
if (!binding) {
return this.workbench.commandPallette.runCommand(command);
return this.workbench.quickopen.runCommand(command);
}
const keys: string = binding.key;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册