mirror of
https://github.com/OpenHands/OpenHands.git
synced 2026-03-22 05:37:20 +08:00
refactor(frontend): hide planning preview component when plan content is empty (#12879)
This commit is contained in:
@@ -92,19 +92,21 @@ describe("PlanPreview", () => {
|
||||
});
|
||||
|
||||
it("should render nothing when planContent is null", () => {
|
||||
renderPlanPreview(<PlanPreview planContent={null} />);
|
||||
// Arrange & Act
|
||||
const { container } = renderPlanPreview(<PlanPreview planContent={null} />);
|
||||
|
||||
const contentDiv = screen.getByTestId("plan-preview-content");
|
||||
expect(contentDiv).toBeInTheDocument();
|
||||
expect(contentDiv.textContent?.trim() || "").toBe("");
|
||||
// Assert
|
||||
expect(container.firstChild).toBeNull();
|
||||
});
|
||||
|
||||
it("should render nothing when planContent is undefined", () => {
|
||||
renderPlanPreview(<PlanPreview planContent={undefined} />);
|
||||
// Arrange & Act
|
||||
const { container } = renderPlanPreview(
|
||||
<PlanPreview planContent={undefined} />,
|
||||
);
|
||||
|
||||
const contentDiv = screen.getByTestId("plan-preview-content");
|
||||
expect(contentDiv).toBeInTheDocument();
|
||||
expect(contentDiv.textContent?.trim() || "").toBe("");
|
||||
// Assert
|
||||
expect(container.firstChild).toBeNull();
|
||||
});
|
||||
|
||||
it("should render markdown content when planContent is provided", () => {
|
||||
|
||||
@@ -65,7 +65,7 @@ export function PlanPreview({
|
||||
return `${planContent.slice(0, MAX_CONTENT_LENGTH)}...`;
|
||||
}, [planContent]);
|
||||
|
||||
if (!shouldUsePlanningAgent) {
|
||||
if (!shouldUsePlanningAgent || !planContent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user