Skip to content

Commit

Permalink
fix: fix undesired eval() call (#12026)
Browse files Browse the repository at this point in the history
* fix: fix undesired eval() call

* fix: fix UT
  • Loading branch information
GavinGu07 authored Jul 19, 2024
1 parent 3a91e86 commit ba7e9bb
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 475 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,6 @@ export default async function generatecodeCommandHandler(
};
}

if (process.env.NODE_ENV === "development") {
const localScenarioHandlers = await import("../../../../test/officeChat/mocks/localTuning");
if (request.prompt in localScenarioHandlers) {
const scenarioName = request.prompt as keyof typeof localScenarioHandlers;
await localScenarioHandlers[scenarioName](request, context, response, token);

return {
metadata: {
command: OfficeChatCommand.GenerateCode,
requestId: officeChatTelemetryData.requestId,
},
};
}
}

const isHarmful = await isInputHarmful(request, token, officeChatTelemetryData);
if (!isHarmful) {
let chatResult: ICopilotChatOfficeResult = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as vscode from "vscode";
import * as util from "../../../../src/officeChat/utils";
import * as helper from "../../../../src/officeChat/commands/create/helper";
import * as generatecodeCommandHandler from "../../../../src/officeChat/commands/generatecode/generatecodeCommandHandler";
import * as promptTest from "../../../../test/officeChat/mocks/localTuning/promptTest";
import { ExtTelemetry } from "../../../../src/telemetry/extTelemetry";
import { CancellationToken } from "../../../mocks/vsc";
import { Planner } from "../../../../src/officeChat/common/planner";
Expand Down Expand Up @@ -37,22 +36,6 @@ describe("File: generatecodeCommandHandler", () => {
process.env.NODE_ENV = undefined;
});

it("prompt test in dev env", async () => {
process.env.NODE_ENV = "development";
const response = {
markdown: sandbox.stub(),
};
const token = new CancellationToken();
const promptTestStub = sandbox.stub(promptTest, "promptTest");
await generatecodeCommandHandler.default(
{ prompt: "promptTest" } as unknown as vscode.ChatRequest,
{} as unknown as vscode.ChatContext,
response as unknown as vscode.ChatResponseStream,
token
);
chai.assert.isTrue(promptTestStub.calledOnce);
});

it("input prompt is empty", async () => {
const response = {
markdown: sandbox.stub(),
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit ba7e9bb

Please sign in to comment.