From 04bf2a2a500b10932aebdcb68c51dc969e29aa71 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Fri, 15 Sep 2017 15:20:45 +0200 Subject: [PATCH] smoke: fix broken http ping --- test/smoke/src/areas/debug/debug.test.ts | 18 +++++++++++------- test/smoke/src/areas/debug/debug.ts | 11 +++++------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/test/smoke/src/areas/debug/debug.test.ts b/test/smoke/src/areas/debug/debug.test.ts index 1d5e0c080cf..4aeeba790ee 100644 --- a/test/smoke/src/areas/debug/debug.test.ts +++ b/test/smoke/src/areas/debug/debug.test.ts @@ -69,10 +69,12 @@ describe('Debug', () => { port = await app.workbench.debug.startDebugging(); await app.screenCapturer.capture('debugging has started'); - await new Promise((c, e) => http.get(`http://localhost:${port}`).on('response', c).on('error', e)); - await app.screenCapturer.capture('server was pinged'); + await new Promise((c, e) => { + const request = http.get(`http://localhost:${port}`); + request.on('error', e); + app.workbench.debug.waitForStackFrame(sf => sf.name === 'index.js' && sf.lineNumber === 6).then(c, e); + }); - await app.workbench.debug.waitForStackFrame(sf => sf.name === 'index.js' && sf.lineNumber === 6); await app.screenCapturer.capture('debugging is paused'); }); @@ -108,15 +110,17 @@ describe('Debug', () => { await app.workbench.debug.continue(); await app.screenCapturer.capture('debugging has continued'); - await new Promise((c, e) => http.get(`http://localhost:${port}`).on('response', c).on('error', e)); - await app.screenCapturer.capture('server was pinged'); + await new Promise((c, e) => { + const request = http.get(`http://localhost:${port}`); + request.on('error', e); + app.workbench.debug.waitForStackFrame(sf => sf.name === 'index.js' && sf.lineNumber === 6).then(c, e); + }); - await app.workbench.debug.waitForStackFrame(sf => sf.name === 'index.js' && sf.lineNumber === 6); await app.screenCapturer.capture('debugging is paused'); }); it('debug console', async function () { - await app.client.waitFor(() => app.workbench.debug.console('2 + 2 \n'), r => r === '4', 'debug console should return 2 + 2 = 4'); + await app.workbench.debug.waitForReplCommand('2 + 2 \n', r => r === '4'); }); it('stop debugging', async function () { diff --git a/test/smoke/src/areas/debug/debug.ts b/test/smoke/src/areas/debug/debug.ts index ddca2631983..e16e3a51bc5 100644 --- a/test/smoke/src/areas/debug/debug.ts +++ b/test/smoke/src/areas/debug/debug.ts @@ -25,7 +25,6 @@ const STACK_FRAME = `${VIEWLET} .monaco-tree-row .stack-frame`; const VARIABLE = `${VIEWLET} .debug-variables .monaco-tree-row .expression`; const CONSOLE_OUTPUT = `.repl .output.expression`; const CONSOLE_INPUT_OUTPUT = `.repl .input-output-pair .output.expression .value`; -const SCOPE = `${VIEWLET} .debug-variables .scope`; const REPL_FOCUSED = '.repl-input-wrapper .monaco-editor.focused'; @@ -112,18 +111,18 @@ export class Debug extends Viewlet { await this.spectron.workbench.waitForTab(name); } - async console(text: string): Promise { + async waitForReplCommand(text: string, accept: (result: string) => boolean): Promise { await this.spectron.workbench.quickopen.runCommand('Debug: Focus Debug Console'); await this.spectron.client.waitForElement(REPL_FOCUSED); await this.spectron.client.type(text); await this.spectron.client.waitForElement(CONSOLE_INPUT_OUTPUT); - - const result = await this.getConsoleOutput(); - return result[result.length - 1] || ''; + await this.spectron.client.waitFor(async () => { + const result = await this.getConsoleOutput(); + return result[result.length - 1] || ''; + }, accept); } async getLocalVariableCount(): Promise { - await this.spectron.client.waitForElement(SCOPE); return await this.spectron.webclient.selectorExecute(VARIABLE, div => (Array.isArray(div) ? div : [div]).length); }