-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ray/all-959-user-story-1-connection-rejections
- Loading branch information
Showing
60 changed files
with
817 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
frontend/__tests__/components/features/conversation-panel/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { screen, within } from "@testing-library/react"; | ||
import { UserEvent } from "@testing-library/user-event"; | ||
|
||
export const clickOnEditButton = async (user: UserEvent) => { | ||
const ellipsisButton = screen.getByTestId("ellipsis-button"); | ||
await user.click(ellipsisButton); | ||
|
||
const menu = screen.getByTestId("context-menu"); | ||
const editButton = within(menu).getByTestId("edit-button"); | ||
|
||
await user.click(editButton); | ||
}; |
35 changes: 35 additions & 0 deletions
35
frontend/__tests__/components/shared/modals/settings/runtime-size-selector.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { screen } from "@testing-library/react"; | ||
import { describe, it, expect } from "vitest"; | ||
import { renderWithProviders } from "test-utils"; | ||
import { RuntimeSizeSelector } from "#/components/shared/modals/settings/runtime-size-selector"; | ||
|
||
const renderRuntimeSizeSelector = () => | ||
renderWithProviders(<RuntimeSizeSelector isDisabled={false} />); | ||
|
||
describe("RuntimeSizeSelector", () => { | ||
it("should show both runtime size options", () => { | ||
renderRuntimeSizeSelector(); | ||
// The options are in the hidden select element | ||
const select = screen.getByRole("combobox", { hidden: true }); | ||
expect(select).toHaveValue("1"); | ||
expect(select).toHaveDisplayValue("1x (2 core, 8G)"); | ||
expect(select.children).toHaveLength(3); // Empty option + 2 size options | ||
}); | ||
|
||
it("should show the full description text for disabled options", async () => { | ||
renderRuntimeSizeSelector(); | ||
|
||
// Click the button to open the dropdown | ||
const button = screen.getByRole("button", { | ||
name: "1x (2 core, 8G) SETTINGS_FORM$RUNTIME_SIZE_LABEL", | ||
}); | ||
button.click(); | ||
|
||
// Wait for the dropdown to open and find the description text | ||
const description = await screen.findByText( | ||
"Runtime sizes over 1 are disabled by default, please contact [email protected] to get access to larger runtimes.", | ||
); | ||
expect(description).toBeInTheDocument(); | ||
expect(description).toHaveClass("whitespace-normal", "break-words"); | ||
}); | ||
}); |
45 changes: 45 additions & 0 deletions
45
frontend/__tests__/components/shared/modals/settings/settings-form.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { screen, fireEvent } from "@testing-library/react"; | ||
import { describe, it, expect, vi } from "vitest"; | ||
import { renderWithProviders } from "test-utils"; | ||
import { createRoutesStub } from "react-router"; | ||
import { DEFAULT_SETTINGS } from "#/services/settings"; | ||
import { SettingsForm } from "#/components/shared/modals/settings/settings-form"; | ||
import OpenHands from "#/api/open-hands"; | ||
|
||
describe("SettingsForm", () => { | ||
const getConfigSpy = vi.spyOn(OpenHands, "getConfig"); | ||
getConfigSpy.mockResolvedValue({ | ||
APP_MODE: "saas", | ||
GITHUB_CLIENT_ID: "123", | ||
POSTHOG_CLIENT_KEY: "123", | ||
}); | ||
|
||
const RouterStub = createRoutesStub([ | ||
{ | ||
Component: () => ( | ||
<SettingsForm | ||
settings={DEFAULT_SETTINGS} | ||
models={[]} | ||
agents={[]} | ||
securityAnalyzers={[]} | ||
onClose={() => {}} | ||
/> | ||
), | ||
path: "/", | ||
}, | ||
]); | ||
|
||
it("should not show runtime size selector by default", () => { | ||
renderWithProviders(<RouterStub />); | ||
expect(screen.queryByText("Runtime Size")).not.toBeInTheDocument(); | ||
}); | ||
|
||
it("should show runtime size selector when advanced options are enabled", async () => { | ||
renderWithProviders(<RouterStub />); | ||
const advancedSwitch = screen.getByRole("switch", { | ||
name: "SETTINGS_FORM$ADVANCED_OPTIONS_LABEL", | ||
}); | ||
fireEvent.click(advancedSwitch); | ||
await screen.findByText("SETTINGS_FORM$RUNTIME_SIZE_LABEL"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
frontend/src/components/features/conversation-panel/conversation-card-context-menu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useClickOutsideElement } from "#/hooks/use-click-outside-element"; | ||
import { ContextMenu } from "../context-menu/context-menu"; | ||
import { ContextMenuListItem } from "../context-menu/context-menu-list-item"; | ||
|
||
interface ConversationCardContextMenuProps { | ||
onClose: () => void; | ||
onDelete: (event: React.MouseEvent<HTMLButtonElement>) => void; | ||
onEdit: (event: React.MouseEvent<HTMLButtonElement>) => void; | ||
} | ||
|
||
export function ConversationCardContextMenu({ | ||
onClose, | ||
onDelete, | ||
onEdit, | ||
}: ConversationCardContextMenuProps) { | ||
const ref = useClickOutsideElement<HTMLUListElement>(onClose); | ||
|
||
return ( | ||
<ContextMenu | ||
ref={ref} | ||
testId="context-menu" | ||
className="left-full float-right" | ||
> | ||
<ContextMenuListItem testId="delete-button" onClick={onDelete}> | ||
Delete | ||
</ContextMenuListItem> | ||
<ContextMenuListItem testId="edit-button" onClick={onEdit}> | ||
Edit Title | ||
</ContextMenuListItem> | ||
</ContextMenu> | ||
); | ||
} |
Oops, something went wrong.