mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
smoke: dont use monaco-editor.focused
This commit is contained in:
parent
d5275987a1
commit
3b06706a32
|
@ -24,7 +24,6 @@
|
|||
"spectron": "~3.6.4",
|
||||
"strip-json-comments": "^2.0.1",
|
||||
"tmp": "0.0.33",
|
||||
"typescript": "^2.2.2",
|
||||
"vscode-uri": "^1.0.1"
|
||||
"typescript": "^2.2.2"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,7 +23,6 @@ describe('CSS', () => {
|
|||
|
||||
it('verifies warnings for the empty rule', async () => {
|
||||
await app.workbench.quickopen.openFile('style.css');
|
||||
await app.client.waitForElement(`.monaco-editor.focused`);
|
||||
await app.client.type('.foo{}');
|
||||
|
||||
let warning = await app.client.waitForElement(Problems.getSelectorInEditor(ProblemSeverity.WARNING));
|
||||
|
|
|
@ -26,7 +26,7 @@ const VARIABLE = `${VIEWLET} .debug-variables .monaco-tree-row .expression`;
|
|||
const CONSOLE_OUTPUT = `.repl .output.expression`;
|
||||
const CONSOLE_INPUT_OUTPUT = `.repl .input-output-pair .output.expression .value`;
|
||||
|
||||
const REPL_FOCUSED = '.repl-input-wrapper .monaco-editor.focused';
|
||||
const REPL_FOCUSED = '.repl-input-wrapper .monaco-editor textarea';
|
||||
|
||||
export interface IStackFrame {
|
||||
id: string;
|
||||
|
@ -113,7 +113,7 @@ export class Debug extends Viewlet {
|
|||
|
||||
async waitForReplCommand(text: string, accept: (result: string) => boolean): Promise<void> {
|
||||
await this.spectron.workbench.quickopen.runCommand('Debug: Focus Debug Console');
|
||||
await this.spectron.client.waitForElement(REPL_FOCUSED);
|
||||
await this.spectron.client.waitForActiveElement(REPL_FOCUSED);
|
||||
await this.spectron.client.type(text);
|
||||
await this.spectron.client.waitForElement(CONSOLE_INPUT_OUTPUT);
|
||||
await this.spectron.client.waitFor(async () => {
|
||||
|
|
|
@ -18,11 +18,6 @@ export class Editor {
|
|||
constructor(private spectron: SpectronApplication) {
|
||||
}
|
||||
|
||||
public async getEditorFirstLineText(): Promise<string> {
|
||||
const result = await this.spectron.client.waitForText('.monaco-editor.focused .view-lines span span:nth-child(1)');
|
||||
return Array.isArray(result) ? result.join() : result;
|
||||
}
|
||||
|
||||
public async getEditorVisibleText(): Promise<string> {
|
||||
return await this.spectron.client.getText('.view-lines');
|
||||
}
|
||||
|
@ -102,11 +97,39 @@ export class Editor {
|
|||
await this.spectron.client.waitAndClick(selector);
|
||||
}
|
||||
|
||||
public async getFocusedEditorUri(): Promise<string> {
|
||||
return this.spectron.webclient.selectorExecute(`.editor-container .monaco-editor.focused`, (elements: HTMLElement[]) => {
|
||||
elements = Array.isArray(elements) ? elements : [elements];
|
||||
return elements[0].getAttribute('data-uri');
|
||||
});
|
||||
public async waitForActiveEditor(filename: string): Promise<any> {
|
||||
const selector = `.editor-container .monaco-editor[data-uri$="${filename}"] textarea`;
|
||||
return this.spectron.client.waitForActiveElement(selector);
|
||||
}
|
||||
|
||||
public async waitForActiveEditorFirstLineText(filename: string): Promise<string> {
|
||||
const selector = `.editor-container .monaco-editor[data-uri$="${filename}"] textarea`;
|
||||
const result = await this.spectron.client.waitFor(
|
||||
() => this.spectron.client.spectron.client.execute(s => {
|
||||
if (!document.activeElement.matches(s)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let element: Element | null = document.activeElement;
|
||||
while (element && !/monaco-editor/.test(element.className) && element !== document.body) {
|
||||
element = element.parentElement;
|
||||
}
|
||||
|
||||
if (element && /monaco-editor/.test(element.className)) {
|
||||
const firstLine = element.querySelector('.view-lines span span:nth-child(1)');
|
||||
|
||||
if (firstLine) {
|
||||
return (firstLine.textContent || '').replace(/\u00a0/g, ' '); // DAMN
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}, selector),
|
||||
r => typeof r.value === 'string',
|
||||
`wait for active editor first line: ${selector}`
|
||||
);
|
||||
|
||||
return result.value;
|
||||
}
|
||||
|
||||
private async getClassSelectors(term: string, viewline: number): Promise<string[]> {
|
||||
|
|
|
@ -27,13 +27,13 @@ describe('Dataloss', () => {
|
|||
|
||||
await app.workbench.waitForActiveTab(fileName, true);
|
||||
await app.screenCapturer.capture(`${fileName} after reload`);
|
||||
let actual = await app.workbench.editor.getEditorFirstLineText();
|
||||
assert.ok(actual.startsWith(textToType), `${actual} did not start with ${textToType}`);
|
||||
let actual = await app.workbench.editor.waitForActiveEditorFirstLineText(fileName);
|
||||
assert.ok(actual.startsWith(textToType), `'${actual}' did not start with '${textToType}'`);
|
||||
|
||||
await app.workbench.waitForTab(untitled, true);
|
||||
await app.workbench.selectTab('Untitled-1', true);
|
||||
await app.screenCapturer.capture('Untitled file after reload');
|
||||
actual = await app.workbench.editor.getEditorFirstLineText();
|
||||
assert.ok(actual.startsWith(textToTypeInUntitled), `${actual} did not start with ${textToTypeInUntitled}`);
|
||||
actual = await app.workbench.editor.waitForActiveEditorFirstLineText('Untitled-1');
|
||||
assert.ok(actual.startsWith(textToTypeInUntitled), `'${actual}' did not start with '${textToTypeInUntitled}'`);
|
||||
});
|
||||
});
|
|
@ -37,7 +37,7 @@ describe('Data Migration', () => {
|
|||
app.screenCapturer.testName = 'Untitled is restorted';
|
||||
|
||||
assert.ok(await app.workbench.waitForActiveTab('Untitled-1', true), `Untitled-1 tab is not present after migration.`);
|
||||
const actual = await app.workbench.editor.getEditorFirstLineText();
|
||||
const actual = await app.workbench.editor.waitForActiveEditorFirstLineText('Untitled-1');
|
||||
await app.screenCapturer.capture('Untitled file text');
|
||||
assert.ok(actual.startsWith(textToType), `${actual} did not start with ${textToType}`);
|
||||
});
|
||||
|
@ -65,8 +65,9 @@ describe('Data Migration', () => {
|
|||
await app.start('Data Migration');
|
||||
app.screenCapturer.testName = 'Newly created dirty file is restorted';
|
||||
|
||||
assert.ok(await app.workbench.waitForActiveTab(fileName.split('/')[1]), `Untitled-1 tab is not present after migration.`);
|
||||
const actual = await app.workbench.editor.getEditorFirstLineText();
|
||||
const filename = fileName.split('/')[1];
|
||||
assert.ok(await app.workbench.waitForActiveTab(filename), `Untitled-1 tab is not present after migration.`);
|
||||
const actual = await app.workbench.editor.waitForActiveEditorFirstLineText(filename);
|
||||
await app.screenCapturer.capture(fileName + ' text');
|
||||
assert.ok(actual.startsWith(firstTextPart.concat(secondTextPart)), `${actual} did not start with ${firstTextPart.concat(secondTextPart)}`);
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as path from 'path';
|
||||
import URI from 'vscode-uri';
|
||||
import { SpectronApplication } from '../../spectron/application';
|
||||
import { Explorer } from '../explorer/explorer';
|
||||
import { ActivityBar } from '../activitybar/activityBar';
|
||||
|
@ -70,10 +68,7 @@ export class Workbench {
|
|||
|
||||
public async waitForEditorFocus(fileName: string, untitled: boolean = false): Promise<void> {
|
||||
await this.waitForActiveTab(fileName);
|
||||
await this.spectron.client.waitFor(async () => {
|
||||
const uri = await this.editor.getFocusedEditorUri();
|
||||
return uri && path.basename(URI.parse(uri).path) === fileName;
|
||||
}, void 0, `Wait for editor with ${fileName} is focussed`);
|
||||
await this.editor.waitForActiveEditor(fileName);
|
||||
}
|
||||
|
||||
public async waitForActiveTab(fileName: string, isDirty: boolean = false): Promise<boolean> {
|
||||
|
|
|
@ -101,8 +101,12 @@ export class SpectronClient {
|
|||
.then(result => result.value);
|
||||
}
|
||||
|
||||
public async waitForActiveElement(accept: (result: Element | undefined) => boolean = result => !!result): Promise<any> {
|
||||
return this.waitFor<RawResult<Element>>(() => this.spectron.client.elementActive(), result => accept(result ? result.value : void 0), `elementActive`);
|
||||
public async waitForActiveElement(selector: string): Promise<any> {
|
||||
return this.waitFor(
|
||||
() => this.spectron.client.execute(s => document.activeElement.matches(s), selector),
|
||||
r => r.value,
|
||||
`wait for active element: ${selector}`
|
||||
);
|
||||
}
|
||||
|
||||
public async waitForAttribute(selector: string, attribute: string, accept: (result: string) => boolean = result => !!result): Promise<string> {
|
||||
|
|
Loading…
Reference in a new issue