Skip to content

Commit

Permalink
Update spectron app handler to pick VSCode window
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Campos committed Nov 13, 2018
1 parent 3cb73a7 commit 14f7ecb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test_script:
"Running npm run test:without-system-tests..."
"--------------------------------------------"
npm run test:without-system-tests
#npm run coverage:system-tests
npm run coverage:system-tests
npm run aggregateJUnit
junit-merge -d junit-aggregate -o junit-aggregate.xml
$NpmTestsExitCode = $LastExitCode
Expand Down
31 changes: 22 additions & 9 deletions packages/system-tests/src/spectron/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' &&
title !== '' &&
/Visual Studio Code/.test(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');
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 14f7ecb

Please sign in to comment.