mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
hotfix(frontend): Input set/unset state and disable runtime input (#6788)
This commit is contained in:
parent
b10416e0a3
commit
fdffca18e0
@ -76,7 +76,8 @@ describe("Settings Screen", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("should render an indicator if the GitHub token is not set", async () => {
|
||||
// TODO: Set a better unset indicator
|
||||
it.skip("should render an indicator if the GitHub token is not set", async () => {
|
||||
getSettingsSpy.mockResolvedValue({
|
||||
...MOCK_DEFAULT_USER_SETTINGS,
|
||||
github_token_is_set: false,
|
||||
@ -97,6 +98,20 @@ describe("Settings Screen", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("should set asterik placeholder if the GitHub token is set", async () => {
|
||||
getSettingsSpy.mockResolvedValue({
|
||||
...MOCK_DEFAULT_USER_SETTINGS,
|
||||
github_token_is_set: true,
|
||||
});
|
||||
|
||||
renderSettingsScreen();
|
||||
|
||||
await waitFor(() => {
|
||||
const input = screen.getByTestId("github-token-input");
|
||||
expect(input).toHaveProperty("placeholder", "**********");
|
||||
});
|
||||
});
|
||||
|
||||
it("should render an indicator if the GitHub token is set", async () => {
|
||||
getSettingsSpy.mockResolvedValue({
|
||||
...MOCK_DEFAULT_USER_SETTINGS,
|
||||
@ -314,7 +329,8 @@ describe("Settings Screen", () => {
|
||||
// screen.getByTestId("security-analyzer-input");
|
||||
});
|
||||
|
||||
it("should render an indicator if the LLM API key is not set", async () => {
|
||||
// TODO: Set a better unset indicator
|
||||
it.skip("should render an indicator if the LLM API key is not set", async () => {
|
||||
getSettingsSpy.mockResolvedValueOnce({
|
||||
...MOCK_DEFAULT_USER_SETTINGS,
|
||||
llm_api_key: null,
|
||||
@ -443,7 +459,22 @@ describe("Settings Screen", () => {
|
||||
expect(input).toHaveValue("1x (2 core, 8G)");
|
||||
});
|
||||
|
||||
it("should save the runtime settings when the 'Save Changes' button is clicked", async () => {
|
||||
it("should always have the runtime input disabled", async () => {
|
||||
getConfigSpy.mockResolvedValue({
|
||||
APP_MODE: "saas",
|
||||
GITHUB_CLIENT_ID: "123",
|
||||
POSTHOG_CLIENT_KEY: "456",
|
||||
});
|
||||
|
||||
renderSettingsScreen();
|
||||
|
||||
await toggleAdvancedSettings(userEvent.setup());
|
||||
|
||||
const input = await screen.findByTestId("runtime-settings-input");
|
||||
expect(input).toBeDisabled();
|
||||
});
|
||||
|
||||
it.skip("should save the runtime settings when the 'Save Changes' button is clicked", async () => {
|
||||
const user = userEvent.setup();
|
||||
getConfigSpy.mockResolvedValue({
|
||||
APP_MODE: "saas",
|
||||
|
||||
@ -75,7 +75,7 @@ export function SettingsForm({ settings, models, onClose }: SettingsFormProps) {
|
||||
}
|
||||
};
|
||||
|
||||
const isLLMKeySet = settings.LLM_API_KEY !== "**********";
|
||||
const isLLMKeySet = settings.LLM_API_KEY === "**********";
|
||||
|
||||
return (
|
||||
<div>
|
||||
@ -97,7 +97,7 @@ export function SettingsForm({ settings, models, onClose }: SettingsFormProps) {
|
||||
label="API Key"
|
||||
type="password"
|
||||
className="w-[680px]"
|
||||
startContent={<KeyStatusIcon isSet={isLLMKeySet} />}
|
||||
startContent={isLLMKeySet && <KeyStatusIcon isSet={isLLMKeySet} />}
|
||||
/>
|
||||
|
||||
<HelpLink
|
||||
|
||||
@ -257,7 +257,9 @@ function SettingsScreen() {
|
||||
label="API Key"
|
||||
type="password"
|
||||
className="w-[680px]"
|
||||
startContent={<KeyStatusIcon isSet={isLLMKeySet} />}
|
||||
startContent={
|
||||
isLLMKeySet && <KeyStatusIcon isSet={isLLMKeySet} />
|
||||
}
|
||||
placeholder={isLLMKeySet ? "**********" : ""}
|
||||
/>
|
||||
|
||||
@ -291,6 +293,7 @@ function SettingsScreen() {
|
||||
label="Runtime Settings"
|
||||
items={REMOTE_RUNTIME_OPTIONS}
|
||||
defaultSelectedKey={settings.REMOTE_RUNTIME_RESOURCE_FACTOR?.toString()}
|
||||
isDisabled
|
||||
isClearable={false}
|
||||
/>
|
||||
)}
|
||||
@ -348,7 +351,12 @@ function SettingsScreen() {
|
||||
label="GitHub Token"
|
||||
type="password"
|
||||
className="w-[680px]"
|
||||
startContent={<KeyStatusIcon isSet={!!isGitHubTokenSet} />}
|
||||
startContent={
|
||||
isGitHubTokenSet && (
|
||||
<KeyStatusIcon isSet={!!isGitHubTokenSet} />
|
||||
)
|
||||
}
|
||||
placeholder={isGitHubTokenSet ? "**********" : ""}
|
||||
/>
|
||||
|
||||
<HelpLink
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user