Skip to content

Commit

Permalink
refactor: modify work in M365 tag for CEA templates (#12609)
Browse files Browse the repository at this point in the history
* refactor: modify work in M365 tag for CEA templates

* fix: fix bad lint

* fix: fix bad feature flag reference

* test: add test case

* fix: lint

* fix: uncovered cases
  • Loading branch information
frankqianms authored Oct 29, 2024
1 parent 09af212 commit 36de4c2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/fx-core/src/question/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,9 @@ export class CapabilityOptions {

// custom copilot
static customCopilotBasic(): OptionItem {
const description = featureFlagManager.getBooleanValue(FeatureFlags.CEAEnabled)
? getLocalizedString("core.createProjectQuestion.capability.customEngineAgent.description")
: undefined;
return {
id: "custom-copilot-basic",
label: getLocalizedString(
Expand All @@ -779,13 +782,14 @@ export class CapabilityOptions {
detail: getLocalizedString(
"core.createProjectQuestion.capability.customCopilotBasicOption.detail"
),
description: getLocalizedString(
"core.createProjectQuestion.capability.customEngineAgent.description"
),
description: description,
};
}

static customCopilotRag(): OptionItem {
const description = featureFlagManager.getBooleanValue(FeatureFlags.CEAEnabled)
? getLocalizedString("core.createProjectQuestion.capability.customEngineAgent.description")
: undefined;
return {
id: "custom-copilot-rag",
label: getLocalizedString(
Expand All @@ -794,10 +798,14 @@ export class CapabilityOptions {
detail: getLocalizedString(
"core.createProjectQuestion.capability.customCopilotRagOption.detail"
),
description: description,
};
}

static customCopilotAssistant(): OptionItem {
const description = featureFlagManager.getBooleanValue(FeatureFlags.CEAEnabled)
? getLocalizedString("core.createProjectQuestion.capability.customEngineAgent.description")
: undefined;
return {
id: "custom-copilot-agent",
label: getLocalizedString(
Expand All @@ -806,6 +814,7 @@ export class CapabilityOptions {
detail: getLocalizedString(
"core.createProjectQuestion.capability.customCopilotAssistantOption.detail"
),
description: description,
};
}
}
Expand Down
18 changes: 18 additions & 0 deletions packages/fx-core/tests/component/generator/generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { ActionContext } from "../../../src/component/middleware/actionExecution
import { CapabilityOptions, ProgrammingLanguage, QuestionNames } from "../../../src/question";
import sampleConfigV3 from "../../common/samples-config-v3.json";
import { MockTools, randomAppName } from "../../core/utils";
import { getLocalizedString } from "../../../src/common/localizeUtils";

const mockedSampleInfo: SampleConfig = {
id: "test-id",
Expand Down Expand Up @@ -1190,6 +1191,23 @@ describe("render template", () => {
: Generator.getDefaultVariables("test");
assert.equal(vars.CEAEnabled, "");
});

it("CEA works in M365 tag shows when CEA enabled", async () => {
sandbox.stub(process, "env").value({ TEAMSFX_CEA_ENABLED: "true" });
const descriptionAnswer = getLocalizedString(
"core.createProjectQuestion.capability.customEngineAgent.description"
);
assert.equal(CapabilityOptions.customCopilotBasic().description, descriptionAnswer);
assert.equal(CapabilityOptions.customCopilotRag().description, descriptionAnswer);
assert.equal(CapabilityOptions.customCopilotAssistant().description, descriptionAnswer);
});

it("CEA works in M365 tag doesn't show when CEA disabled", async () => {
sandbox.stub(process, "env").value({ TEAMSFX_CEA_ENABLED: "false" });
assert.equal(CapabilityOptions.customCopilotBasic().description, undefined);
assert.equal(CapabilityOptions.customCopilotRag().description, undefined);
assert.equal(CapabilityOptions.customCopilotAssistant().description, undefined);
});
});
});

Expand Down

0 comments on commit 36de4c2

Please sign in to comment.