refactor(frontend): remove certain security analyzer options for v1 conversations (#11988)

This commit is contained in:
Hiep Le 2025-12-10 21:50:30 +07:00 committed by GitHub
parent 92c91471b2
commit 272a37d1b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 81 additions and 0 deletions

View File

@ -253,6 +253,83 @@ describe("Content", () => {
expect(securityAnalyzer).toHaveValue("SETTINGS$SECURITY_ANALYZER_NONE");
});
});
it("should omit invariant and custom analyzers when V1 is enabled", async () => {
const getSettingsSpy = vi.spyOn(SettingsService, "getSettings");
getSettingsSpy.mockResolvedValue({
...MOCK_DEFAULT_USER_SETTINGS,
confirmation_mode: true,
security_analyzer: "llm",
v1_enabled: true,
});
const getSecurityAnalyzersSpy = vi.spyOn(
OptionService,
"getSecurityAnalyzers",
);
getSecurityAnalyzersSpy.mockResolvedValue([
"llm",
"none",
"invariant",
"custom",
]);
renderLlmSettingsScreen();
await screen.findByTestId("llm-settings-screen");
const advancedSwitch = screen.getByTestId("advanced-settings-switch");
await userEvent.click(advancedSwitch);
const securityAnalyzer = await screen.findByTestId(
"security-analyzer-input",
);
await userEvent.click(securityAnalyzer);
// Only llm + none should be available when V1 is enabled
screen.getByText("SETTINGS$SECURITY_ANALYZER_LLM_DEFAULT");
screen.getByText("SETTINGS$SECURITY_ANALYZER_NONE");
expect(
screen.queryByText("SETTINGS$SECURITY_ANALYZER_INVARIANT"),
).not.toBeInTheDocument();
expect(screen.queryByText("custom")).not.toBeInTheDocument();
});
it("should include invariant analyzer option when V1 is disabled", async () => {
const getSettingsSpy = vi.spyOn(SettingsService, "getSettings");
getSettingsSpy.mockResolvedValue({
...MOCK_DEFAULT_USER_SETTINGS,
confirmation_mode: true,
security_analyzer: "llm",
v1_enabled: false,
});
const getSecurityAnalyzersSpy = vi.spyOn(
OptionService,
"getSecurityAnalyzers",
);
getSecurityAnalyzersSpy.mockResolvedValue(["llm", "none", "invariant"]);
renderLlmSettingsScreen();
await screen.findByTestId("llm-settings-screen");
const advancedSwitch = screen.getByTestId("advanced-settings-switch");
await userEvent.click(advancedSwitch);
const securityAnalyzer = await screen.findByTestId(
"security-analyzer-input",
);
await userEvent.click(securityAnalyzer);
expect(
screen.getByText("SETTINGS$SECURITY_ANALYZER_LLM_DEFAULT"),
).toBeInTheDocument();
expect(
screen.getByText("SETTINGS$SECURITY_ANALYZER_NONE"),
).toBeInTheDocument();
expect(
screen.getByText("SETTINGS$SECURITY_ANALYZER_INVARIANT"),
).toBeInTheDocument();
});
});
it.todo("should render an indicator if the llm api key is set");

View File

@ -453,6 +453,10 @@ function LlmSettingsScreen() {
label: t(I18nKey.SETTINGS$SECURITY_ANALYZER_NONE),
});
if (isV1Enabled) {
return orderedItems;
}
// Add Invariant analyzer third
if (analyzers.includes("invariant")) {
orderedItems.push({