From 2f43db1905f9c1fc660cc09c1a0a13db621a193a Mon Sep 17 00:00:00 2001 From: Alena Khineika Date: Tue, 6 Sep 2022 21:50:51 +0200 Subject: [PATCH] fix: export to language actions appear for regular playground results VSCODE-334 (#434) * fix: export to language actions appear for regular playground results VSCODE-334 * test: try without disabling extensions * test: return disable extensions arg * refactor: fix spaces in package.json * refactor: remove metadata * test: try to set setting in tests * test: try other settings format * fix: write settings to global * test: try to disable from connection controller * test: trigger ci again to check * test: remove disabling the dialogue for prompting the user where to store the connection --- package-lock.json | 154 +++++++++++++++++- .../exportToLanguageCodeLensProvider.ts | 4 + src/editors/playgroundController.ts | 5 + .../exportToLanguageCodeLensProvider.test.ts | 26 +++ src/test/suite/index.ts | 35 ++-- 5 files changed, 200 insertions(+), 24 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2e8636430..33eea74e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5390,6 +5390,17 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/cli": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/cli/-/cli-0.4.5.tgz", + "integrity": "sha512-dbn5HyeJWSOU58RwOEiF1VWrl7HRvDsKLpu0uiI/vExH6iNoyUzjB5Mr3IJY5DVUfnbpe9793xw4DFJVzC9nWQ==", + "dependencies": { + "glob": ">= 3.1.4" + }, + "engines": { + "node": ">=0.2.5" + } + }, "node_modules/cli-color": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-0.3.2.tgz", @@ -5646,6 +5657,19 @@ "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==", "dev": true }, + "node_modules/cliff": { + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/cliff/-/cliff-0.1.10.tgz", + "integrity": "sha512-roZWcC2Cxo/kKjRXw7YUpVNtxJccbvcl7VzTjUYgLQk6Ot0R8bm2netbhSZYWWNrKlOO/7HD6GXHl8dtzE6SiQ==", + "dependencies": { + "colors": "~1.0.3", + "eyes": "~0.1.8", + "winston": "0.8.x" + }, + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/cliui": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", @@ -5766,7 +5790,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", - "optional": true, "engines": { "node": ">=0.1.90" } @@ -6115,6 +6138,14 @@ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.9.tgz", "integrity": "sha512-rpw6JPxK6Rfg1zLOYCSwle2GFOOsnjmDYDaBwEcwoOg4qlsIVCN789VkBZDJAGi4T07gI4YSutR43t9Zz4Lzuw==" }, + "node_modules/cycle": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", + "integrity": "sha512-TVF6svNzeQCOpjCqsy0/CSy8VgObG3wXusJ73xW2GbG5rGx7lC8zxDSURicsXI2UsGdi2L0QNRCi745/wUDvsA==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/d": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", @@ -8977,6 +9008,14 @@ "node >=0.6.0" ] }, + "node_modules/eyes": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", + "integrity": "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==", + "engines": { + "node": "> 0.1.90" + } + }, "node_modules/facepaint": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/facepaint/-/facepaint-1.2.1.tgz", @@ -17860,6 +17899,14 @@ "node": ">=8" } }, + "node_modules/pkginfo": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz", + "integrity": "sha512-yO5feByMzAp96LtP58wvPKSbaKAi/1C4kV9XpTctr6EepnP6F33RBNOiVrdz9BrPA98U2BMFsTNHo44TWcbQ2A==", + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/please-upgrade-node": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", @@ -20139,6 +20186,14 @@ "node": ">=0.10.0" } }, + "node_modules/stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==", + "engines": { + "node": "*" + } + }, "node_modules/stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.3.tgz", @@ -22260,6 +22315,36 @@ "node": ">= 0.10.0" } }, + "node_modules/winston": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/winston/-/winston-0.8.3.tgz", + "integrity": "sha512-fPoamsHq8leJ62D1M9V/f15mjQ1UHe4+7j1wpAT3fqgA5JqhJkk4aIfPEjfMTI9x6ZTjaLOpMAjluLtmgO5b6g==", + "dependencies": { + "async": "0.2.x", + "colors": "0.6.x", + "cycle": "1.0.x", + "eyes": "0.1.x", + "isstream": "0.1.x", + "pkginfo": "0.3.x", + "stack-trace": "0.0.x" + }, + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/winston/node_modules/async": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + "integrity": "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==" + }, + "node_modules/winston/node_modules/colors": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", + "integrity": "sha512-OsSVtHK8Ir8r3+Fxw/b4jS1ZLPXkV6ZxDRJQzeD7qo0SqMXWrHDM71DgYzPMHY8SFJ0Ao+nNU2p1MmwdzKqPrw==", + "engines": { + "node": ">=0.1.90" + } + }, "node_modules/wolfy87-eventemitter": { "version": "5.2.9", "resolved": "https://registry.npmjs.org/wolfy87-eventemitter/-/wolfy87-eventemitter-5.2.9.tgz", @@ -26933,6 +27018,14 @@ } } }, + "cli": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/cli/-/cli-0.4.5.tgz", + "integrity": "sha512-dbn5HyeJWSOU58RwOEiF1VWrl7HRvDsKLpu0uiI/vExH6iNoyUzjB5Mr3IJY5DVUfnbpe9793xw4DFJVzC9nWQ==", + "requires": { + "glob": ">= 3.1.4" + } + }, "cli-color": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/cli-color/-/cli-color-0.3.2.tgz", @@ -27132,6 +27225,16 @@ } } }, + "cliff": { + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/cliff/-/cliff-0.1.10.tgz", + "integrity": "sha512-roZWcC2Cxo/kKjRXw7YUpVNtxJccbvcl7VzTjUYgLQk6Ot0R8bm2netbhSZYWWNrKlOO/7HD6GXHl8dtzE6SiQ==", + "requires": { + "colors": "~1.0.3", + "eyes": "~0.1.8", + "winston": "0.8.x" + } + }, "cliui": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", @@ -27234,8 +27337,7 @@ "colors": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/colors/-/colors-1.0.3.tgz", - "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=", - "optional": true + "integrity": "sha1-BDP0TYCWgP3rYO0mDxsMJi6CpAs=" }, "combined-stream": { "version": "1.0.8", @@ -27535,6 +27637,11 @@ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.0.9.tgz", "integrity": "sha512-rpw6JPxK6Rfg1zLOYCSwle2GFOOsnjmDYDaBwEcwoOg4qlsIVCN789VkBZDJAGi4T07gI4YSutR43t9Zz4Lzuw==" }, + "cycle": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/cycle/-/cycle-1.0.3.tgz", + "integrity": "sha512-TVF6svNzeQCOpjCqsy0/CSy8VgObG3wXusJ73xW2GbG5rGx7lC8zxDSURicsXI2UsGdi2L0QNRCi745/wUDvsA==" + }, "d": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", @@ -29854,6 +29961,11 @@ "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" }, + "eyes": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz", + "integrity": "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==" + }, "facepaint": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/facepaint/-/facepaint-1.2.1.tgz", @@ -37068,6 +37180,11 @@ } } }, + "pkginfo": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/pkginfo/-/pkginfo-0.3.1.tgz", + "integrity": "sha512-yO5feByMzAp96LtP58wvPKSbaKAi/1C4kV9XpTctr6EepnP6F33RBNOiVrdz9BrPA98U2BMFsTNHo44TWcbQ2A==" + }, "please-upgrade-node": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", @@ -38916,6 +39033,11 @@ "tweetnacl": "~0.14.0" } }, + "stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==" + }, "stack-utils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.3.tgz", @@ -40572,6 +40694,32 @@ "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz", "integrity": "sha1-tDFbtCFKPXBY6+7okuE/ok2YsHU=" }, + "winston": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/winston/-/winston-0.8.3.tgz", + "integrity": "sha512-fPoamsHq8leJ62D1M9V/f15mjQ1UHe4+7j1wpAT3fqgA5JqhJkk4aIfPEjfMTI9x6ZTjaLOpMAjluLtmgO5b6g==", + "requires": { + "async": "0.2.x", + "colors": "0.6.x", + "cycle": "1.0.x", + "eyes": "0.1.x", + "isstream": "0.1.x", + "pkginfo": "0.3.x", + "stack-trace": "0.0.x" + }, + "dependencies": { + "async": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", + "integrity": "sha512-eAkdoKxU6/LkKDBzLpT+t6Ff5EtfSF4wx1WfJiPEEV7WNLnDaRXk0oVysiEPm262roaachGexwUv94WhSgN5TQ==" + }, + "colors": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", + "integrity": "sha512-OsSVtHK8Ir8r3+Fxw/b4jS1ZLPXkV6ZxDRJQzeD7qo0SqMXWrHDM71DgYzPMHY8SFJ0Ao+nNU2p1MmwdzKqPrw==" + } + } + }, "wolfy87-eventemitter": { "version": "5.2.9", "resolved": "https://registry.npmjs.org/wolfy87-eventemitter/-/wolfy87-eventemitter-5.2.9.tgz", diff --git a/src/editors/exportToLanguageCodeLensProvider.ts b/src/editors/exportToLanguageCodeLensProvider.ts index 3e2f01ad4..d384729a0 100644 --- a/src/editors/exportToLanguageCodeLensProvider.ts +++ b/src/editors/exportToLanguageCodeLensProvider.ts @@ -45,6 +45,10 @@ export default class ExportToLanguageCodeLensProvider const buildersCodeLens = this.createCodeLens(); const exportToLanguageCodeLenses: vscode.CodeLens[] = []; + if (['json', 'plaintext'].includes(this._exportToLanguageAddons.language)) { + return []; + } + importStatementsCodeLens.command = { title: this._exportToLanguageAddons.importStatements ? 'Exclude Import Statements' diff --git a/src/editors/playgroundController.ts b/src/editors/playgroundController.ts index c35502242..1fddf8697 100644 --- a/src/editors/playgroundController.ts +++ b/src/editors/playgroundController.ts @@ -397,6 +397,11 @@ export default class PlaygroundController { this._playgroundResultTextDocument, language ); + + this._exportToLanguageCodeLensProvider.refresh({ + ...this._exportToLanguageCodeLensProvider._exportToLanguageAddons, + language, + }); } } diff --git a/src/test/suite/editors/exportToLanguageCodeLensProvider.test.ts b/src/test/suite/editors/exportToLanguageCodeLensProvider.test.ts index 3936c9012..d20f3d2c7 100644 --- a/src/test/suite/editors/exportToLanguageCodeLensProvider.test.ts +++ b/src/test/suite/editors/exportToLanguageCodeLensProvider.test.ts @@ -120,4 +120,30 @@ suite('Export To Language Code Lens Provider Test Suite', function () { expect(codeLenses.length).to.be.equal(2); }); + + test('does not render code lenses for json text', () => { + testExportToLanguageCodeLensProvider.refresh({ + ...defaults, + builders: true, + mode: ExportToLanguageMode.OTHER, + language: 'json', + }); + + const codeLenses = testExportToLanguageCodeLensProvider.provideCodeLenses(); + + expect(codeLenses.length).to.be.equal(0); + }); + + test('does not render code lenses for plain text text', () => { + testExportToLanguageCodeLensProvider.refresh({ + ...defaults, + builders: true, + mode: ExportToLanguageMode.OTHER, + language: 'plaintext', + }); + + const codeLenses = testExportToLanguageCodeLensProvider.provideCodeLenses(); + + expect(codeLenses.length).to.be.equal(0); + }); }); diff --git a/src/test/suite/index.ts b/src/test/suite/index.ts index a84bd0e6d..46e95500b 100644 --- a/src/test/suite/index.ts +++ b/src/test/suite/index.ts @@ -1,6 +1,5 @@ import Mocha from 'mocha'; import glob from 'glob'; -import * as vscode from 'vscode'; import path = require('path'); import MDBExtensionController from '../../mdbExtensionController'; import { ext } from '../../extensionConstants'; @@ -51,28 +50,22 @@ export async function run(): Promise { // headless linux. ext.keytarModule = new KeytarStub(); - // Disable the dialogue for prompting the user where to store the connection. - void vscode.workspace - .getConfiguration('mdb.connectionSaving') - .update('hideOptionToChooseWhereToSaveNewConnections', true) - .then(() => { - // Add files to the test suite. - files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); - try { - // Run the mocha test. - mocha.run((failures) => { - if (failures > 0) { - e(new Error(`${failures} tests failed.`)); - } else { - c(); - } - }); - } catch (mochaRunErr) { - console.error('Error running mocha tests:'); - console.error(mochaRunErr); - e(mochaRunErr); + // Add files to the test suite. + files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f))); + try { + // Run the mocha test. + mocha.run((failures) => { + if (failures > 0) { + e(new Error(`${failures} tests failed.`)); + } else { + c(); } }); + } catch (mochaRunErr) { + console.error('Error running mocha tests:'); + console.error(mochaRunErr); + e(mochaRunErr); + } } ); });