Skip to content

Commit

Permalink
fix: export to language actions appear for regular playground results V…
Browse files Browse the repository at this point in the history
…SCODE-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
  • Loading branch information
alenakhineika authored Sep 6, 2022
1 parent f145c89 commit 2f43db1
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 24 deletions.
154 changes: 151 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/editors/exportToLanguageCodeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
5 changes: 5 additions & 0 deletions src/editors/playgroundController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ export default class PlaygroundController {
this._playgroundResultTextDocument,
language
);

this._exportToLanguageCodeLensProvider.refresh({
...this._exportToLanguageCodeLensProvider._exportToLanguageAddons,
language,
});
}
}

Expand Down
26 changes: 26 additions & 0 deletions src/test/suite/editors/exportToLanguageCodeLensProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
35 changes: 14 additions & 21 deletions src/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -51,28 +50,22 @@ export async function run(): Promise<void> {
// 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);
}
}
);
});
Expand Down

0 comments on commit 2f43db1

Please sign in to comment.