提交 7e1f12fe 编写于 作者: S Sandeep Somavarapu

smoke test - improve waiting for active editor

上级 f9c49d7d
......@@ -104,7 +104,7 @@ export class Debug extends Viewlet {
async focusStackFrame(name: string): Promise<any> {
const stackFrame = await this.waitForStackFrame(sf => sf.name === name);
await this.spectron.client.spectron.client.elementIdClick(stackFrame.id);
await this.spectron.workbench.waitForOpen(name);
await this.spectron.workbench.waitForTab(name);
}
async console(text: string): Promise<string> {
......
......@@ -64,7 +64,7 @@ describe('Editor', () => {
await app.workbench.editor.gotoDefinition('express', 11);
await app.workbench.waitForActiveOpen('index.d.ts');
await app.workbench.waitForActiveTab('index.d.ts');
});
it(`verifies that 'Peek Definition' works`, async function () {
......
......@@ -52,8 +52,7 @@ export class QuickOpen {
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"]`);
await this.spectron.client.waitForElement(`div.editor-container[aria-label="${fileName}. Text file editor., Group 1."]`);
await this.spectron.workbench.waitForActiveTab(fileName);
await this.spectron.workbench.waitForEditorFocus(fileName);
}
......
......@@ -25,12 +25,12 @@ describe('Dataloss', () => {
await app.reload();
await app.screenCapturer.capture('After reload');
await app.workbench.waitForActiveOpen(fileName, true);
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}`);
await app.workbench.waitForOpen(untitled, true);
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();
......
......@@ -36,7 +36,7 @@ describe('Data Migration', () => {
await app.start('Data Migration');
app.screenCapturer.testName = 'Untitled is restorted';
assert.ok(await app.workbench.waitForActiveOpen('Untitled-1', true), `Untitled-1 tab is not present after migration.`);
assert.ok(await app.workbench.waitForActiveTab('Untitled-1', true), `Untitled-1 tab is not present after migration.`);
const actual = await app.workbench.editor.getEditorFirstLineText();
await app.screenCapturer.capture('Untitled file text');
assert.ok(actual.startsWith(textToType), `${actual} did not start with ${textToType}`);
......@@ -52,7 +52,7 @@ describe('Data Migration', () => {
await app.start('Data Migration');
app.screenCapturer.testName = 'Newly created dirty file is restorted';
await app.workbench.waitForActiveOpen(fileName);
await app.workbench.waitForActiveTab(fileName);
await app.client.type(firstTextPart);
await app.workbench.saveOpenedFile();
await app.client.type(secondTextPart);
......@@ -65,7 +65,7 @@ describe('Data Migration', () => {
await app.start('Data Migration');
app.screenCapturer.testName = 'Newly created dirty file is restorted';
assert.ok(await app.workbench.waitForActiveOpen(fileName.split('/')[1]), `Untitled-1 tab is not present after migration.`);
assert.ok(await app.workbench.waitForActiveTab(fileName.split('/')[1]), `Untitled-1 tab is not present after migration.`);
const actual = await app.workbench.editor.getEditorFirstLineText();
await app.screenCapturer.capture(fileName + ' text');
assert.ok(actual.startsWith(firstTextPart.concat(secondTextPart)), `${actual} did not start with ${firstTextPart.concat(secondTextPart)}`);
......@@ -88,8 +88,8 @@ describe('Data Migration', () => {
await app.start('Data Migration');
app.screenCapturer.testName = 'Opened tabs are restored';
assert.ok(await app.workbench.waitForOpen(fileName1), `${fileName1} tab was not restored after migration.`);
assert.ok(await app.workbench.waitForOpen(fileName2), `${fileName2} tab was not restored after migration.`);
assert.ok(await app.workbench.waitForOpen(fileName3), `${fileName3} tab was not restored after migration.`);
assert.ok(await app.workbench.waitForTab(fileName1), `${fileName1} tab was not restored after migration.`);
assert.ok(await app.workbench.waitForTab(fileName2), `${fileName2} tab was not restored after migration.`);
assert.ok(await app.workbench.waitForTab(fileName3), `${fileName3} tab was not restored after migration.`);
});
});
\ No newline at end of file
......@@ -63,30 +63,28 @@ export class Workbench {
public async selectTab(tabName: string, untitled: boolean = false): Promise<void> {
await this.spectron.client.waitAndClick(`.tabs-container div.tab[aria-label="${tabName}, tab"]`);
await this.waitForActiveOpen(tabName);
await this.waitForEditorFocus(tabName, untitled);
}
public async waitForEditorFocus(fileName: string, untitled: boolean = false): Promise<void> {
await this.spectron.client.waitForElement(`.editor-container[aria-label="${fileName}. ${untitled ? 'Untitled file text editor.' : 'Text file editor.'}, Group 1."] .monaco-editor.focused`);
await this.waitForActiveTab(fileName);
await this.spectron.client.waitForElement(`.editor-container[aria-label="${fileName}. ${untitled ? 'Untitled file text editor.' : 'Text file editor.'}, Group 1."] .monaco-editor textarea:focus`);
}
public async waitForActiveOpen(fileName: string, isDirty: boolean = false): Promise<boolean> {
public async waitForActiveTab(fileName: string, isDirty: boolean = false): Promise<boolean> {
return this.spectron.client.waitForElement(`.tabs-container div.tab.active${isDirty ? '.dirty' : ''}[aria-selected="true"][aria-label="${fileName}, tab"]`).then(() => true);
}
public async waitForOpen(fileName: string, isDirty: boolean = false): Promise<boolean> {
public async waitForTab(fileName: string, isDirty: boolean = false): Promise<boolean> {
return this.spectron.client.waitForElement(`.tabs-container div.tab${isDirty ? '.dirty' : ''}[aria-label="${fileName}, tab"]`).then(() => true);
}
public async newUntitledFile(): Promise<void> {
await this.spectron.command('workbench.action.files.newUntitledFile');
await this.waitForActiveOpen('Untitled-1');
await this.waitForEditorFocus('Untitled-1', true);
}
async openFile(fileName: string): Promise<void> {
await this.quickopen.openFile(fileName);
await this.spectron.client.waitForElement(`.monaco-editor.focused`);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册