mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
refactor(frontend): remove certain security analyzer options for v1 conversations (#11988)
This commit is contained in:
parent
92c91471b2
commit
272a37d1b8
@ -253,6 +253,83 @@ describe("Content", () => {
|
|||||||
expect(securityAnalyzer).toHaveValue("SETTINGS$SECURITY_ANALYZER_NONE");
|
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");
|
it.todo("should render an indicator if the llm api key is set");
|
||||||
|
|||||||
@ -453,6 +453,10 @@ function LlmSettingsScreen() {
|
|||||||
label: t(I18nKey.SETTINGS$SECURITY_ANALYZER_NONE),
|
label: t(I18nKey.SETTINGS$SECURITY_ANALYZER_NONE),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (isV1Enabled) {
|
||||||
|
return orderedItems;
|
||||||
|
}
|
||||||
|
|
||||||
// Add Invariant analyzer third
|
// Add Invariant analyzer third
|
||||||
if (analyzers.includes("invariant")) {
|
if (analyzers.includes("invariant")) {
|
||||||
orderedItems.push({
|
orderedItems.push({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user