-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update spectron app handler to pick VSCode window #744
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2018, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import { Extension } from 'vscode'; | ||
export class MockApexExtension implements Extension<any> { | ||
constructor() { | ||
this.id = 'salesforce.salesforcedx-vscode-apex'; | ||
this.extensionPath = 'extension/local/path'; | ||
this.isActive = true; | ||
this.exports = new MockJorje(); | ||
} | ||
public id: string; | ||
public extensionPath: string; | ||
public isActive: boolean; | ||
public packageJSON: any; | ||
public activate(): Thenable<any> { | ||
return Promise.resolve('activated'); | ||
} | ||
public exports: any; | ||
} | ||
|
||
class MockJorje { | ||
constructor() {} | ||
public getLineBreakpointInfo(): Promise<{}> { | ||
const response = [ | ||
{ | ||
uri: '/force-app/main/default/classes/A.cls', | ||
typeref: 'A', | ||
lines: [2, 5, 6, 7] | ||
} | ||
]; | ||
return Promise.resolve(response); | ||
} | ||
|
||
public isLanguageClientReady() { | ||
return true; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2018, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import { Extension } from 'vscode'; | ||
export class MockApexExtension implements Extension<any> { | ||
constructor() { | ||
this.id = 'salesforce.salesforcedx-vscode-apex'; | ||
this.extensionPath = 'extension/local/path'; | ||
this.isActive = true; | ||
this.exports = new MockJorje(); | ||
} | ||
public id: string; | ||
public extensionPath: string; | ||
public isActive: boolean; | ||
public packageJSON: any; | ||
public activate(): Thenable<any> { | ||
return Promise.resolve('activated'); | ||
} | ||
public exports: any; | ||
} | ||
|
||
class MockJorje { | ||
constructor() {} | ||
public getLineBreakpointInfo(): Promise<{}> { | ||
const response = [ | ||
{ | ||
uri: '/force-app/main/default/classes/A.cls', | ||
typeref: 'A', | ||
lines: [2, 5, 6, 7] | ||
} | ||
]; | ||
return Promise.resolve(response); | ||
} | ||
|
||
public isLanguageClientReady() { | ||
return true; | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,15 +120,28 @@ export class SpectronApplication { | |
private async checkWindowReady(): Promise<any> { | ||
await this.webclient.waitUntilWindowLoaded(60000); | ||
|
||
// Pick the first workbench window here | ||
// Pick the window that loads VSCode, | ||
// added code to address Spectron limitation in Windows OS (https://github.com/electron/spectron/issues/60) | ||
const count = await this.webclient.getWindowCount(); | ||
|
||
for (let i = 0; i < count; i++) { | ||
await this.webclient.windowByIndex(i); | ||
|
||
if (/bootstrap\/index\.html/.test(await this.webclient.getUrl())) { | ||
break; | ||
if (count > 1) { | ||
for (let i = 0; i < count; i++) { | ||
await this.webclient.windowByIndex(i); | ||
const title = await this.webclient.getTitle(); | ||
|
||
if ( | ||
process.platform === 'win32' && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NodeJs always returns |
||
title !== '' && | ||
/Visual Studio Code/.test(title) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could do without this check but wanted to make sure we look for the vscode window in case the empty terminals start returning a title (currently they return an empty title). |
||
) { | ||
break; | ||
} else if ( | ||
/bootstrap\/index\.html/.test(await this.webclient.getUrl()) | ||
) { | ||
break; | ||
} | ||
} | ||
} else { | ||
await this.webclient.windowByIndex(0); | ||
} | ||
|
||
await this.waitFor(this.spectron.client.getHTML, '.monaco-workbench'); | ||
|
@@ -177,8 +190,8 @@ export class SpectronApplication { | |
await this.screenshot.capture(); | ||
rej( | ||
`Could not retrieve the element in ${this.testRetry * | ||
this.pollTrials * | ||
this.pollTimeout} seconds. (${JSON.stringify(args)})` | ||
this.pollTrials * | ||
this.pollTimeout} seconds. (${JSON.stringify(args)})` | ||
); | ||
break; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a basic question, but why is the window that we want in focus during the Spectron test going to be named "...bootstrap/index.html"? Is that a Spectron convention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That has to do with how spectron loads the vscode window, it's normally a file path that represents the local vscode location being used.
I think the path might've changed with vscode moving to a newer electron version (now we get something like
electron-browser/workbench/workbench.html
) but I was only able to test in Windows and Mac OS so I kept this for now.