diff --git a/src/classes/insightsConnection.ts b/src/classes/insightsConnection.ts index 1da63f89..85edd732 100644 --- a/src/classes/insightsConnection.ts +++ b/src/classes/insightsConnection.ts @@ -346,7 +346,7 @@ export class InsightsConnection { isTableView: false, params: queryParams, }; - window.withProgress( + await window.withProgress( { location: ProgressLocation.Notification, cancellable: false, @@ -358,33 +358,32 @@ export class InsightsConnection { progress.report({ message: "Populating scratchpad..." }); - const scratchpadResponse = await axios.post( - scratchpadURL.toString(), - body, - headers, - ); - - kdbOutputLog( - `Executed successfully, stored in ${variableName}.`, - "INFO", - ); - kdbOutputLog( - `[SCRATCHPAD] Status: ${scratchpadResponse.status}`, - "INFO", - ); - kdbOutputLog( - `[SCRATCHPAD] Populated scratchpad with the following params: ${JSON.stringify(body.params)}`, - "INFO", - ); - window.showInformationMessage( - `Executed successfully, stored in ${variableName}.`, - ); - Telemetry.sendEvent( - "Datasource." + dsTypeString + ".Scratchpad.Populated", - ); - - const p = new Promise((resolve) => resolve()); - return p; + return await axios + .post(scratchpadURL.toString(), body, headers) + .then((response: any) => { + if (response.data.error) { + kdbOutputLog( + `[SCRATCHPAD] Error occured while populating scratchpad: ${response.data.errorMsg}`, + "ERROR", + ); + } else { + kdbOutputLog( + `Executed successfully, stored in ${variableName}.`, + "INFO", + ); + kdbOutputLog(`[SCRATCHPAD] Status: ${response.status}`, "INFO"); + kdbOutputLog( + `[SCRATCHPAD] Populated scratchpad with the following params: ${JSON.stringify(body.params)}`, + "INFO", + ); + window.showInformationMessage( + `Executed successfully, stored in ${variableName}.`, + ); + Telemetry.sendEvent( + "Datasource." + dsTypeString + ".Scratchpad.Populated", + ); + } + }); }, ); } else { diff --git a/src/utils/connLabel.ts b/src/utils/connLabel.ts index f2c9f4c9..790efe03 100644 --- a/src/utils/connLabel.ts +++ b/src/utils/connLabel.ts @@ -100,6 +100,9 @@ export function removeConnFromLabels(connName: string) { ); } }); + workspace + .getConfiguration() + .update("kdb.labelsConnectionMap", ext.labelConnMapList, true); } export async function handleLabelsConnMap(labels: string[], connName: string) { diff --git a/src/utils/core.ts b/src/utils/core.ts index 31a6d94b..4fd98856 100644 --- a/src/utils/core.ts +++ b/src/utils/core.ts @@ -57,7 +57,8 @@ export async function checkOpenSslInstalled(): Promise { return semver.clean(installedVersion ? installedVersion[1] : ""); } } catch (err) { - kdbOutputLog(`Error in checking OpenSSL version: ${err}`, "ERROR"); + // Disabled the error, as it is not critical + // kdbOutputLog(`Error in checking OpenSSL version: ${err}`, "ERROR"); Telemetry.sendException(err as Error); } return null; diff --git a/src/webview/components/kdbDataSourceView.ts b/src/webview/components/kdbDataSourceView.ts index 9fcd2808..0dae141f 100644 --- a/src/webview/components/kdbDataSourceView.ts +++ b/src/webview/components/kdbDataSourceView.ts @@ -870,8 +870,7 @@ export class KdbDataSourceView extends LitElement { ).value; this.requestChange(); }}" - >Start Time - ${this.selectedServerVersion}Start Time { - this.labels[0] = this.newLblName; + this.labels.unshift(this.newLblName); this.closeModal(); }, 500); } diff --git a/test/suite/utils.test.ts b/test/suite/utils.test.ts index c3fa43c0..f3fd47e8 100644 --- a/test/suite/utils.test.ts +++ b/test/suite/utils.test.ts @@ -1710,6 +1710,10 @@ describe("Utils", () => { labelName: "label1", connections: ["conn1", "conn2"], }); + getConfigurationStub.returns({ + get: sinon.stub(), + update: sinon.stub(), + }); LabelsUtils.removeConnFromLabels("conn1"); diff --git a/test/suite/webview.test.ts b/test/suite/webview.test.ts index ac777ccf..1bed0d54 100644 --- a/test/suite/webview.test.ts +++ b/test/suite/webview.test.ts @@ -896,6 +896,40 @@ describe("KdbNewConnectionView", () => { }); }); + describe("createLabel", () => { + let clock: sinon.SinonFakeTimers; + + beforeEach(() => { + clock = sinon.useFakeTimers(); + }); + + afterEach(() => { + clock.restore(); + }); + + it("should post a message and update labels after timeout", () => { + const api = acquireVsCodeApi(); + const postMessageStub = sinon.stub(api, "postMessage"); + const closeModalStub = sinon.stub(view, "closeModal"); + + view.newLblName = "Test Label"; + view.newLblColorName = "Test Color"; + view.labels = []; + + view.createLabel(); + + sinon.assert.calledOnce(postMessageStub); + + // Avança o tempo em 500ms + clock.tick(500); + + assert.equal(view.labels[0], "Test Label"); + sinon.assert.calledOnce(closeModalStub); + + sinon.restore(); + }); + }); + describe("edit", () => { const editConn: EditConnectionMessage = { connType: 0, @@ -931,4 +965,6 @@ describe("KdbNewConnectionView", () => { sinon.restore(); }); }); + + describe("createLabel", () => {}); });