From d8989c95964ce06c64ffebc2fb400a0327bd447d Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 8 Dec 2017 10:56:20 +0100 Subject: [PATCH] fix smoketests fixes #37603 --- test/smoke/src/areas/debug/debug.test.ts | 43 +++++++++++++++++++ test/smoke/src/areas/git/git.test.ts | 13 ------ test/smoke/src/areas/git/scm.ts | 6 +-- .../src/areas/multiroot/multiroot.test.ts | 2 +- test/smoke/src/areas/search/search.test.ts | 6 +-- test/smoke/src/main.ts | 2 +- test/smoke/src/spectron/application.ts | 4 +- test/smoke/src/spectron/client.ts | 4 -- 8 files changed, 53 insertions(+), 27 deletions(-) diff --git a/test/smoke/src/areas/debug/debug.test.ts b/test/smoke/src/areas/debug/debug.test.ts index 7ccef119531..5439d138232 100644 --- a/test/smoke/src/areas/debug/debug.test.ts +++ b/test/smoke/src/areas/debug/debug.test.ts @@ -12,6 +12,7 @@ import * as stripJsonComments from 'strip-json-comments'; import { SpectronApplication, Quality } from '../../spectron/application'; describe('Debug', () => { + let skip = false; before(async function () { const app = this.app as SpectronApplication; @@ -27,11 +28,13 @@ describe('Debug', () => { if (!debugExists) { console.warn(`Skipping debug tests because vscode-node-debug extension was not found in ${extensionsPath}`); + skip = true; return; } if (!debug2Exists) { console.warn(`Skipping debug tests because vscode-node-debug2 extension was not found in ${extensionsPath}`); + skip = true; return; } @@ -44,6 +47,11 @@ describe('Debug', () => { }); it('configure launch json', async function () { + if (skip) { + this.skip(); + return; + } + const app = this.app as SpectronApplication; await app.workbench.debug.openDebugViewlet(); @@ -69,6 +77,11 @@ describe('Debug', () => { }); it('breakpoints', async function () { + if (skip) { + this.skip(); + return; + } + const app = this.app as SpectronApplication; await app.workbench.quickopen.openFile('index.js'); @@ -78,6 +91,11 @@ describe('Debug', () => { let port: number; it('start debugging', async function () { + if (skip) { + this.skip(); + return; + } + const app = this.app as SpectronApplication; port = await app.workbench.debug.startDebugging(); @@ -93,6 +111,11 @@ describe('Debug', () => { }); it('focus stack frames and variables', async function () { + if (skip) { + this.skip(); + return; + } + const app = this.app as SpectronApplication; await app.client.waitFor(() => app.workbench.debug.getLocalVariableCount(), c => c === 4, 'there should be 4 local variables'); @@ -108,6 +131,11 @@ describe('Debug', () => { }); it('stepOver, stepIn, stepOut', async function () { + if (skip) { + this.skip(); + return; + } + const app = this.app as SpectronApplication; await app.workbench.debug.stepIn(); @@ -125,6 +153,11 @@ describe('Debug', () => { }); it('continue', async function () { + if (skip) { + this.skip(); + return; + } + const app = this.app as SpectronApplication; await app.workbench.debug.continue(); @@ -140,12 +173,22 @@ describe('Debug', () => { }); it('debug console', async function () { + if (skip) { + this.skip(); + return; + } + const app = this.app as SpectronApplication; await app.workbench.debug.waitForReplCommand('2 + 2', r => r === '4'); }); it('stop debugging', async function () { + if (skip) { + this.skip(); + return; + } + const app = this.app as SpectronApplication; await app.workbench.debug.stopDebugging(); diff --git a/test/smoke/src/areas/git/git.test.ts b/test/smoke/src/areas/git/git.test.ts index d64a72f7d43..f089fd97818 100644 --- a/test/smoke/src/areas/git/git.test.ts +++ b/test/smoke/src/areas/git/git.test.ts @@ -52,12 +52,6 @@ describe('Git', () => { it('stages correctly', async function () { const app = this.app as SpectronApplication; - // TODO@joao get these working once joh fixes scm viewlet - if (!false) { - this.skip(); - return; - } - await app.workbench.scm.openSCMViewlet(); const appJs = await app.workbench.scm.waitForChange(c => c.name === 'app.js' && c.type === 'Modified'); @@ -72,13 +66,6 @@ describe('Git', () => { it(`stages, commits changes and verifies outgoing change`, async function () { const app = this.app as SpectronApplication; - // TODO@joao get these working once joh fixes scm viewlet - if (!false) { - cp.execSync('git reset --hard origin/master', { cwd: app.workspacePath }); - this.skip(); - return; - } - await app.workbench.scm.openSCMViewlet(); const appJs = await app.workbench.scm.waitForChange(c => c.name === 'app.js' && c.type === 'Modified'); diff --git a/test/smoke/src/areas/git/scm.ts b/test/smoke/src/areas/git/scm.ts index bc99619478a..ed33e320710 100644 --- a/test/smoke/src/areas/git/scm.ts +++ b/test/smoke/src/areas/git/scm.ts @@ -13,7 +13,7 @@ const SCM_RESOURCE = `${VIEWLET} .monaco-list-row > .resource`; const SCM_RESOURCE_GROUP = `${VIEWLET} .monaco-list-row > .resource-group`; const REFRESH_COMMAND = `div[id="workbench.parts.sidebar"] .actions-container a.action-label[title="Refresh"]`; const COMMIT_COMMAND = `div[id="workbench.parts.sidebar"] .actions-container a.action-label[title="Commit"]`; -const SCM_RESOURCE_CLICK = name => `${SCM_RESOURCE} .monaco-icon-label[title$="${name}"]`; +const SCM_RESOURCE_CLICK = name => `${SCM_RESOURCE} .monaco-icon-label[title*="${name}"]`; const SCM_RESOURCE_GROUP_COMMAND_CLICK = name => `${SCM_RESOURCE_GROUP} .actions .action-label[title="${name}"]`; export interface Change { @@ -49,7 +49,7 @@ export class SCM extends Viewlet { const result = await this.spectron.webclient.selectorExecute(SCM_RESOURCE, div => (Array.isArray(div) ? div : [div]).map(element => { const name = element.querySelector('.label-name') as HTMLElement; - const icon = element.querySelector('.monaco-icon-label') as HTMLElement; + const icon = element.querySelector('.decoration-icon') as HTMLElement; const actionElementList = element.querySelectorAll('.actions .action-label'); const actionElements: any[] = []; @@ -60,7 +60,7 @@ export class SCM extends Viewlet { return { name: name.textContent, - type: (icon.title || '').replace(/^([^,]+),.*$/, '$1'), + type: (icon.title || ''), element, actionElements }; diff --git a/test/smoke/src/areas/multiroot/multiroot.test.ts b/test/smoke/src/areas/multiroot/multiroot.test.ts index 9529fe3c324..ce837f20965 100644 --- a/test/smoke/src/areas/multiroot/multiroot.test.ts +++ b/test/smoke/src/areas/multiroot/multiroot.test.ts @@ -17,7 +17,7 @@ describe('Multiroot', () => { // for some reason Code opens 2 windows at this point // so let's select the last one - await app.client.windowByIndex(2); + await app.client.windowByIndex(1); }); it('shows results from all folders', async function () { diff --git a/test/smoke/src/areas/search/search.test.ts b/test/smoke/src/areas/search/search.test.ts index 6f43bbab341..48fdd923d68 100644 --- a/test/smoke/src/areas/search/search.test.ts +++ b/test/smoke/src/areas/search/search.test.ts @@ -15,7 +15,7 @@ describe('Search', () => { await app.workbench.search.openSearchViewlet(); await app.workbench.search.searchFor('body'); - await app.workbench.search.waitForResultText('7 results in 4 files'); + await app.workbench.search.waitForResultText('14 results in 5 files'); }); it('searches only for *.js files & checks for correct result number', async function () { @@ -34,7 +34,7 @@ describe('Search', () => { const app = this.app as SpectronApplication; await app.workbench.search.searchFor('body'); await app.workbench.search.removeFileMatch(1); - await app.workbench.search.waitForResultText('3 results in 3 files'); + await app.workbench.search.waitForResultText('10 results in 4 files'); }); it('replaces first search result with a replace term', async function () { @@ -46,7 +46,7 @@ describe('Search', () => { await app.workbench.search.replaceFileMatch(1); await app.workbench.saveOpenedFile(); - await app.workbench.search.waitForResultText('3 results in 3 files'); + await app.workbench.search.waitForResultText('10 results in 4 files'); await app.workbench.search.searchFor('ydob'); await app.workbench.search.setReplaceText('body'); diff --git a/test/smoke/src/main.ts b/test/smoke/src/main.ts index 8c71329b907..b82af3837da 100644 --- a/test/smoke/src/main.ts +++ b/test/smoke/src/main.ts @@ -195,7 +195,7 @@ async function setup(): Promise { * @see https://github.com/webdriverio/webdriverio/issues/2076 */ // Filter out the following messages: -const wdioDeprecationWarning = /^WARNING: the "\w+" command will be depcrecated soon./; // [sic] +const wdioDeprecationWarning = /^WARNING: the "\w+" command will be deprecated soon../; // [sic] // Monkey patch: const warn = console.warn; console.warn = function suppressWebdriverWarnings(message) { diff --git a/test/smoke/src/spectron/application.ts b/test/smoke/src/spectron/application.ts index 22c1c23010d..dc1bd47dd6d 100644 --- a/test/smoke/src/spectron/application.ts +++ b/test/smoke/src/spectron/application.ts @@ -271,9 +271,9 @@ export class SpectronApplication { await this.webclient.waitUntilWindowLoaded(); // Spectron opens multiple terminals in Windows platform // Workaround to focus the right window - https://github.com/electron/spectron/issues/60 - await this.client.windowByIndex(1); + // await this.client.windowByIndex(1); // await this.app.browserWindow.focus(); - await this.client.waitForHTML('[id="workbench.main.container"]'); + await this.client.waitForElement('.monaco-workbench'); } private async waitForWelcome(): Promise { diff --git a/test/smoke/src/spectron/client.ts b/test/smoke/src/spectron/client.ts index 9ec19afd2f5..ac828847ef4 100644 --- a/test/smoke/src/spectron/client.ts +++ b/test/smoke/src/spectron/client.ts @@ -54,10 +54,6 @@ export class SpectronClient { return this.waitFor(() => this.spectron.client.getValue(selector), accept, `getValue with selector ${selector}`); } - async waitForHTML(selector: string, accept: (result: string) => boolean = (result: string) => !!result): Promise { - return this.waitFor(() => this.spectron.client.getHTML(selector), accept, `getHTML with selector ${selector}`); - } - async waitAndClick(selector: string): Promise { return this.waitFor(() => this.spectron.client.click(selector), void 0, `click with selector ${selector}`); } -- GitLab