diff --git a/.appveyor.yml b/.appveyor.yml index 16f7bf7915..5a53f39c68 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -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 diff --git a/packages/salesforcedx-vscode-apex-debugger/test/unit/adapter/MockApexExtension.ts b/packages/salesforcedx-vscode-apex-debugger/test/unit/adapter/MockApexExtension.ts new file mode 100644 index 0000000000..d344678d8a --- /dev/null +++ b/packages/salesforcedx-vscode-apex-debugger/test/unit/adapter/MockApexExtension.ts @@ -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 { + 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 { + 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; + } +} diff --git a/packages/salesforcedx-vscode-apex-debugger/test/unit/adapter/debugConfigurationProvider.test.ts b/packages/salesforcedx-vscode-apex-debugger/test/unit/adapter/debugConfigurationProvider.test.ts index ec4c0059b1..308c5f76d4 100644 --- a/packages/salesforcedx-vscode-apex-debugger/test/unit/adapter/debugConfigurationProvider.test.ts +++ b/packages/salesforcedx-vscode-apex-debugger/test/unit/adapter/debugConfigurationProvider.test.ts @@ -11,29 +11,35 @@ import { } from '@salesforce/salesforcedx-apex-debugger/out/src'; import { expect } from 'chai'; import * as sinon from 'sinon'; -import * as vscode from 'vscode'; +import { DebugConfiguration, extensions, Uri, WorkspaceFolder } from 'vscode'; import { DebugConfigurationProvider } from '../../../src/adapter/debugConfigurationProvider'; import { nls } from '../../../src/messages'; +import { MockApexExtension } from './MockApexExtension'; // tslint:disable:no-unused-expression describe('Configuration provider', () => { let provider: DebugConfigurationProvider; let getConfigSpy: sinon.SinonSpy; - const folder: vscode.WorkspaceFolder = { + const folder: WorkspaceFolder = { name: 'mySfdxProject', index: 0, uri: { fsPath: '/foo' - } as vscode.Uri + } as Uri }; + let mockApexExtension: sinon.SinonStub; beforeEach(() => { + mockApexExtension = sinon + .stub(extensions, 'getExtension') + .returns(new MockApexExtension()); provider = new DebugConfigurationProvider(); getConfigSpy = sinon.spy(DebugConfigurationProvider, 'getConfig'); }); afterEach(() => { getConfigSpy.restore(); + mockApexExtension.restore(); }); it('Should provide default config', () => { @@ -45,7 +51,7 @@ describe('Configuration provider', () => { requestTypeFilter: [], entryPointFilter: '', sfdxProject: '/foo' - } as vscode.DebugConfiguration; + } as DebugConfiguration; const configs = provider.provideDebugConfigurations(folder); @@ -70,6 +76,7 @@ describe('Configuration provider', () => { expect(config.sfdxProject).to.equals('/foo'); expect(config.workspaceSettings).to.not.equals(undefined); expect(config.lineBreakpointInfo).to.not.equals(undefined); + expect(mockApexExtension.calledOnce).to.be.true; } else { expect.fail( 'Did not get configuration information from resolveDebugConfiguration' @@ -106,6 +113,7 @@ describe('Configuration provider', () => { expect(config.trace).to.equals(true); expect(config.workspaceSettings).to.not.equals(undefined); expect(config.lineBreakpointInfo).to.not.equals(undefined); + expect(mockApexExtension.calledOnce).to.be.true; } else { expect.fail( 'Did not get configuration information from resolveDebugConfiguration' diff --git a/packages/salesforcedx-vscode-apex-replay-debugger/test/unit/adapter/MockApexExtension.ts b/packages/salesforcedx-vscode-apex-replay-debugger/test/unit/adapter/MockApexExtension.ts new file mode 100644 index 0000000000..d344678d8a --- /dev/null +++ b/packages/salesforcedx-vscode-apex-replay-debugger/test/unit/adapter/MockApexExtension.ts @@ -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 { + 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 { + 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; + } +} diff --git a/packages/salesforcedx-vscode-apex-replay-debugger/test/unit/adapter/MockJorje.ts b/packages/salesforcedx-vscode-apex-replay-debugger/test/unit/adapter/MockJorje.ts deleted file mode 100644 index 34c9ff9060..0000000000 --- a/packages/salesforcedx-vscode-apex-replay-debugger/test/unit/adapter/MockJorje.ts +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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 - */ - -export 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); - } -} diff --git a/packages/salesforcedx-vscode-apex-replay-debugger/test/unit/adapter/debugConfigurationProvider.test.ts b/packages/salesforcedx-vscode-apex-replay-debugger/test/unit/adapter/debugConfigurationProvider.test.ts index d2def05317..a185003514 100644 --- a/packages/salesforcedx-vscode-apex-replay-debugger/test/unit/adapter/debugConfigurationProvider.test.ts +++ b/packages/salesforcedx-vscode-apex-replay-debugger/test/unit/adapter/debugConfigurationProvider.test.ts @@ -23,7 +23,7 @@ import { import { DebugConfigurationProvider } from '../../../src/adapter/debugConfigurationProvider'; import { updateLastOpened } from '../../../src/index'; import { nls } from '../../../src/messages'; -import { MockJorje } from './MockJorje'; +import { MockApexExtension } from './MockApexExtension'; // tslint:disable:no-unused-expression describe('Configuration provider', () => { @@ -36,19 +36,19 @@ describe('Configuration provider', () => { fsPath: '/foo' } as Uri }; - let mockApexJorje: sinon.SinonStub; + let mockApexExtension: sinon.SinonStub; beforeEach(() => { - provider = new DebugConfigurationProvider(); getConfigSpy = sinon.spy(DebugConfigurationProvider, 'getConfig'); - mockApexJorje = sinon + mockApexExtension = sinon .stub(extensions, 'getExtension') - .returns({ exports: new MockJorje() }); + .returns(new MockApexExtension()); + provider = new DebugConfigurationProvider(); }); afterEach(() => { getConfigSpy.restore(); - mockApexJorje.restore(); + mockApexExtension.restore(); }); it('Should provide default config', () => { @@ -97,6 +97,7 @@ describe('Configuration provider', () => { expect(config.trace).to.equals(true); expect(config.projectPath).to.not.equals(undefined); expect(config.lineBreakpointInfo).to.not.equals(undefined); + expect(mockApexExtension.calledOnce).to.be.true; } else { expect.fail( 'Did not get configuration information from resolveDebugConfiguration' @@ -123,6 +124,7 @@ describe('Configuration provider', () => { expect(config.trace).to.equals(false); expect(config.projectPath).to.not.equals(undefined); expect(config.lineBreakpointInfo).to.not.equals(undefined); + expect(mockApexExtension.calledOnce).to.be.true; } else { expect.fail( 'Did not get configuration information from resolveDebugConfiguration' diff --git a/packages/system-tests/src/spectron/application.ts b/packages/system-tests/src/spectron/application.ts index bdcf099172..505bd42daf 100644 --- a/packages/system-tests/src/spectron/application.ts +++ b/packages/system-tests/src/spectron/application.ts @@ -120,15 +120,28 @@ export class SpectronApplication { private async checkWindowReady(): Promise { 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'); @@ -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; }