forked from All-Hands-AI/OpenHands
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue All-Hands-AI#5478: Add color to the line next to "Ran a XXX…
… Command" based on return value (All-Hands-AI#5483) Co-authored-by: Graham Neubig <[email protected]>
- Loading branch information
1 parent
907c65c
commit 6a6ce5f
Showing
20 changed files
with
447 additions
and
137 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
frontend/__tests__/components/chat/expandable-message.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,60 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { screen } from "@testing-library/react"; | ||
import { renderWithProviders } from "test-utils"; | ||
import { ExpandableMessage } from "#/components/features/chat/expandable-message"; | ||
|
||
describe("ExpandableMessage", () => { | ||
it("should render with neutral border for non-action messages", () => { | ||
renderWithProviders(<ExpandableMessage message="Hello" type="thought" />); | ||
const element = screen.getByText("Hello"); | ||
const container = element.closest("div.flex.gap-2.items-center.justify-between"); | ||
expect(container).toHaveClass("border-neutral-300"); | ||
expect(screen.queryByTestId("status-icon")).not.toBeInTheDocument(); | ||
}); | ||
|
||
it("should render with neutral border for error messages", () => { | ||
renderWithProviders(<ExpandableMessage message="Error occurred" type="error" />); | ||
const element = screen.getByText("Error occurred"); | ||
const container = element.closest("div.flex.gap-2.items-center.justify-between"); | ||
expect(container).toHaveClass("border-neutral-300"); | ||
expect(screen.queryByTestId("status-icon")).not.toBeInTheDocument(); | ||
}); | ||
|
||
it("should render with success icon for successful action messages", () => { | ||
renderWithProviders( | ||
<ExpandableMessage | ||
message="Command executed successfully" | ||
type="action" | ||
success={true} | ||
/> | ||
); | ||
const element = screen.getByText("Command executed successfully"); | ||
const container = element.closest("div.flex.gap-2.items-center.justify-between"); | ||
expect(container).toHaveClass("border-neutral-300"); | ||
const icon = screen.getByTestId("status-icon"); | ||
expect(icon).toHaveClass("fill-success"); | ||
}); | ||
|
||
it("should render with error icon for failed action messages", () => { | ||
renderWithProviders( | ||
<ExpandableMessage | ||
message="Command failed" | ||
type="action" | ||
success={false} | ||
/> | ||
); | ||
const element = screen.getByText("Command failed"); | ||
const container = element.closest("div.flex.gap-2.items-center.justify-between"); | ||
expect(container).toHaveClass("border-neutral-300"); | ||
const icon = screen.getByTestId("status-icon"); | ||
expect(icon).toHaveClass("fill-danger"); | ||
}); | ||
|
||
it("should render with neutral border and no icon for action messages without success prop", () => { | ||
renderWithProviders(<ExpandableMessage message="Running command" type="action" />); | ||
const element = screen.getByText("Running command"); | ||
const container = element.closest("div.flex.gap-2.items-center.justify-between"); | ||
expect(container).toHaveClass("border-neutral-300"); | ||
expect(screen.queryByTestId("status-icon")).not.toBeInTheDocument(); | ||
}); | ||
}); |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from openhands.events.observation.commands import ( | ||
CmdOutputObservation, | ||
IPythonRunCellObservation, | ||
) | ||
|
||
|
||
def test_cmd_output_success(): | ||
# Test successful command | ||
obs = CmdOutputObservation( | ||
command_id=1, command='ls', content='file1.txt\nfile2.txt', exit_code=0 | ||
) | ||
assert obs.success is True | ||
assert obs.error is False | ||
|
||
# Test failed command | ||
obs = CmdOutputObservation( | ||
command_id=2, command='ls', content='No such file or directory', exit_code=1 | ||
) | ||
assert obs.success is False | ||
assert obs.error is True | ||
|
||
|
||
def test_ipython_cell_success(): | ||
# IPython cells are always successful | ||
obs = IPythonRunCellObservation(code='print("Hello")', content='Hello') | ||
assert obs.success is True | ||
assert obs.error is False |
Oops, something went wrong.