forked from All-Hands-AI/OpenHands
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
3,800 additions
and
2,976 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Large diffs are not rendered by default.
Oops, something went wrong.
149 changes: 143 additions & 6 deletions
149
frontend/__tests__/components/chat/chat-interface.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
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,30 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { afterEach, describe, expect, it, vi } from "vitest"; | ||
import { SuggestionItem } from "#/components/suggestion-item"; | ||
|
||
describe("SuggestionItem", () => { | ||
const suggestionItem = { label: "suggestion1", value: "a long text value" }; | ||
const onClick = vi.fn(); | ||
|
||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it("should render a suggestion", () => { | ||
render(<SuggestionItem suggestion={suggestionItem} onClick={onClick} />); | ||
|
||
expect(screen.getByTestId("suggestion")).toBeInTheDocument(); | ||
expect(screen.getByText(/suggestion1/i)).toBeInTheDocument(); | ||
}); | ||
|
||
it("should call onClick when clicking a suggestion", async () => { | ||
const user = userEvent.setup(); | ||
render(<SuggestionItem suggestion={suggestionItem} onClick={onClick} />); | ||
|
||
const suggestion = screen.getByTestId("suggestion"); | ||
await user.click(suggestion); | ||
|
||
expect(onClick).toHaveBeenCalledWith("a long text value"); | ||
}); | ||
}); |
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 { render, screen } from "@testing-library/react"; | ||
import userEvent from "@testing-library/user-event"; | ||
import { afterEach, describe, expect, it, vi } from "vitest"; | ||
import { Suggestions } from "#/components/suggestions"; | ||
|
||
describe("Suggestions", () => { | ||
const firstSuggestion = { | ||
label: "first-suggestion", | ||
value: "value-of-first-suggestion", | ||
}; | ||
const secondSuggestion = { | ||
label: "second-suggestion", | ||
value: "value-of-second-suggestion", | ||
}; | ||
const suggestions = [firstSuggestion, secondSuggestion]; | ||
|
||
const onSuggestionClickMock = vi.fn(); | ||
|
||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it("should render suggestions", () => { | ||
render( | ||
<Suggestions | ||
suggestions={suggestions} | ||
onSuggestionClick={onSuggestionClickMock} | ||
/>, | ||
); | ||
|
||
expect(screen.getByTestId("suggestions")).toBeInTheDocument(); | ||
const suggestionElements = screen.getAllByTestId("suggestion"); | ||
|
||
expect(suggestionElements).toHaveLength(2); | ||
expect(suggestionElements[0]).toHaveTextContent("first-suggestion"); | ||
expect(suggestionElements[1]).toHaveTextContent("second-suggestion"); | ||
}); | ||
|
||
it("should call onSuggestionClick when clicking a suggestion", async () => { | ||
const user = userEvent.setup(); | ||
render( | ||
<Suggestions | ||
suggestions={suggestions} | ||
onSuggestionClick={onSuggestionClickMock} | ||
/>, | ||
); | ||
|
||
const suggestionElements = screen.getAllByTestId("suggestion"); | ||
|
||
await user.click(suggestionElements[0]); | ||
expect(onSuggestionClickMock).toHaveBeenCalledWith( | ||
"value-of-first-suggestion", | ||
); | ||
|
||
await user.click(suggestionElements[1]); | ||
expect(onSuggestionClickMock).toHaveBeenCalledWith( | ||
"value-of-second-suggestion", | ||
); | ||
}); | ||
}); |
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,17 @@ | ||
import { describe, it, expect } from "vitest"; | ||
import store from "../src/store"; | ||
import { setInitialQuery, clearInitialQuery } from "../src/state/initial-query-slice"; | ||
|
||
describe("Initial Query Behavior", () => { | ||
it("should clear initial query when clearInitialQuery is dispatched", () => { | ||
// Set up initial query in the store | ||
store.dispatch(setInitialQuery("test query")); | ||
expect(store.getState().initalQuery.initialQuery).toBe("test query"); | ||
|
||
// Clear the initial query | ||
store.dispatch(clearInitialQuery()); | ||
|
||
// Verify initial query is cleared | ||
expect(store.getState().initalQuery.initialQuery).toBeNull(); | ||
}); | ||
}); |
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,5 @@ | ||
import { describe, it } from "vitest"; | ||
|
||
describe("App", () => { | ||
it.todo("should render"); | ||
}); |
Oops, something went wrong.