diff --git a/extension/src/test/e2e/debugConfig.ts b/extension/src/test/e2e/debugConfig.ts index 8a3ff1b9..3f7f89ac 100644 --- a/extension/src/test/e2e/debugConfig.ts +++ b/extension/src/test/e2e/debugConfig.ts @@ -2,50 +2,99 @@ import { expect } from 'chai'; import { InputBox, Workbench } from 'vscode-extension-tester'; describe('Debug Configuration Test', () => { - let input: InputBox; + let workbench: Workbench = null; + let activeInput: InputBox = null; + let debugStarted: boolean = false; - const attachConfigText:string = 'AutoLISP Debug: Attach'; - const launchConfigText:string = 'AutoLISP Debug: Launch'; - const startDebugCmd:string = 'workbench.action.debug.start'; - - before(async () => { - }); + const attachConfigText: string = 'AutoLISP Debug: Attach'; + const launchConfigText: string = 'AutoLISP Debug: Launch'; + + const startDebugCmd: string = 'workbench.action.debug.start'; + const stopDebugCmd: string = 'workbench.action.debug.stop'; - after(async () => { - await input.cancel(); - }); + const expectedAttachHint = 'Pick the process to attach.'; + const expectedLaunchHint = 'Specify the absolute path for the product.'; - // to verify that the Attach and Launch config items show up when starting to debug via. VS Code - it('should show debug config items on F5', async function() { - this.timeout(15000); + beforeEach(async () => { + activeInput = null; + debugStarted = false; - const workbench = new Workbench(); + workbench = new Workbench(); await workbench.executeCommand(startDebugCmd); + }); - input = await InputBox.create(); - expect(await input.isDisplayed()).is.true; + afterEach(async () => { + if (activeInput) { + if (await activeInput.isDisplayed()) + await activeInput.cancel(); + } - const picks = await input.getQuickPicks(); + if(debugStarted) { + await workbench.executeCommand(stopDebugCmd); + } + }); - const attachCfg:InputBox[] = await findAll(picks, async (x:InputBox) => { return attachConfigText === await x.getText();}); + // to verify that the config item named "Attach" is really for attach mode + it('should show debug config items on F5', async function () { + const cmdInput = await getActiveInputBox(); + expect(await cmdInput.isDisplayed()).is.true; + + const picks = await cmdInput.getQuickPicks(); + + const attachCfg: InputBox[] = await findAll(picks, async (x: InputBox) => { return attachConfigText === await x.getText(); }); expect(attachCfg.length).equals(1); - const launchCfg:InputBox[] = await findAll(picks, async (x:InputBox) => { return launchConfigText === await x.getText();}); + const launchCfg: InputBox[] = await findAll(picks, async (x: InputBox) => { return launchConfigText === await x.getText(); }); expect(launchCfg.length).equals(1); }); - async function findAll(array, callbackFind) : Promise>{ - let ret:Array = []; + // to verify that the "Attach" config item is bound to attach mode + it('should debug in attach mode after selecting Debug: Attach', async function () { + const cmdInput = await getActiveInputBox(); + expect(await cmdInput.isDisplayed()).is.true; + + await cmdInput.setText(attachConfigText); + await cmdInput.confirm(); + + debugStarted = true; + + const procInput = await getActiveInputBox(); + expect((await procInput.getPlaceHolder()).startsWith(expectedAttachHint)).true; + }); + + // to verify that the config item named "Launch" is really for launch mode + it('should debug in launch mode after selecting Debug: Launch', async function () { + const cmdInput = await getActiveInputBox(); + expect(await cmdInput.isDisplayed()).is.true; + + await cmdInput.setText(launchConfigText); + await cmdInput.confirm(); + + debugStarted = true; + + const pathInput = await getActiveInputBox(); + expect((await pathInput.getPlaceHolder()).startsWith(expectedLaunchHint)).true; + }); - for(const item of array) { + async function findAll(array, callbackFind): Promise> { + let ret: Array = []; + + for (const item of array) { const matched: boolean = await callbackFind(item); - if(!matched) + if (!matched) continue; - + ret.push(item); } return ret; } + async function getActiveInputBox(): Promise { + let input = await InputBox.create(); + activeInput = input; + + return activeInput; + } + }); diff --git a/package.json b/package.json index 935912a1..2b59c021 100644 --- a/package.json +++ b/package.json @@ -617,7 +617,7 @@ "watch": "tsc -p -watch ./", "test": "npm run compile && node ./out/test/runTest.js", "cc": "npm run compile && node ./out/test/runTest.js --codecoverage", - "e2etest": "npm run compile && extest setup-and-run -c 1.50.0 ./out/test/e2e/*.js -m ./out/test/e2e/config.js" + "e2etest": "npm run compile && extest setup-and-run -c 1.50.0 ./out/test/e2e/*.js -m ./out/test/e2e/config.js -u" }, "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.1",