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.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
27 changed files
with
319 additions
and
306 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
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 |
---|---|---|
|
@@ -5,15 +5,14 @@ import { FeedbackForm } from "#/components/feedback-form"; | |
|
||
describe("FeedbackForm", () => { | ||
const user = userEvent.setup(); | ||
const onSubmitMock = vi.fn(); | ||
const onCloseMock = vi.fn(); | ||
|
||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
it("should render correctly", () => { | ||
render(<FeedbackForm onSubmit={onSubmitMock} onClose={onCloseMock} />); | ||
render(<FeedbackForm polarity="positive" onClose={onCloseMock} />); | ||
|
||
screen.getByLabelText("Email"); | ||
screen.getByLabelText("Private"); | ||
|
@@ -24,7 +23,7 @@ describe("FeedbackForm", () => { | |
}); | ||
|
||
it("should switch between private and public permissions", async () => { | ||
render(<FeedbackForm onSubmit={onSubmitMock} onClose={onCloseMock} />); | ||
render(<FeedbackForm polarity="positive" onClose={onCloseMock} />); | ||
const privateRadio = screen.getByLabelText("Private"); | ||
const publicRadio = screen.getByLabelText("Public"); | ||
|
||
|
@@ -40,69 +39,11 @@ describe("FeedbackForm", () => { | |
expect(publicRadio).not.toBeChecked(); | ||
}); | ||
|
||
it("should call onSubmit when the form is submitted", async () => { | ||
render(<FeedbackForm onSubmit={onSubmitMock} onClose={onCloseMock} />); | ||
const email = screen.getByLabelText("Email"); | ||
|
||
await user.type(email, "[email protected]"); | ||
await user.click(screen.getByRole("button", { name: "Submit" })); | ||
|
||
expect(onSubmitMock).toHaveBeenCalledWith("private", "[email protected]"); // private is the default value | ||
}); | ||
|
||
it("should not call onSubmit when the email is invalid", async () => { | ||
render(<FeedbackForm onSubmit={onSubmitMock} onClose={onCloseMock} />); | ||
const email = screen.getByLabelText("Email"); | ||
const submitButton = screen.getByRole("button", { name: "Submit" }); | ||
|
||
await user.click(submitButton); | ||
|
||
expect(onSubmitMock).not.toHaveBeenCalled(); | ||
|
||
await user.type(email, "test"); | ||
await user.click(submitButton); | ||
|
||
expect(onSubmitMock).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it("should submit public permissions when the public radio is checked", async () => { | ||
render(<FeedbackForm onSubmit={onSubmitMock} onClose={onCloseMock} />); | ||
const email = screen.getByLabelText("Email"); | ||
const publicRadio = screen.getByLabelText("Public"); | ||
|
||
await user.type(email, "[email protected]"); | ||
await user.click(publicRadio); | ||
await user.click(screen.getByRole("button", { name: "Submit" })); | ||
|
||
expect(onSubmitMock).toHaveBeenCalledWith("public", "[email protected]"); | ||
}); | ||
|
||
it("should call onClose when the close button is clicked", async () => { | ||
render(<FeedbackForm onSubmit={onSubmitMock} onClose={onCloseMock} />); | ||
render(<FeedbackForm polarity="positive" onClose={onCloseMock} />); | ||
await user.click(screen.getByRole("button", { name: "Cancel" })); | ||
|
||
expect(onSubmitMock).not.toHaveBeenCalled(); | ||
expect(onCloseMock).toHaveBeenCalled(); | ||
}); | ||
|
||
it("should disable the buttons if isSubmitting is true", () => { | ||
const { rerender } = render( | ||
<FeedbackForm onSubmit={onSubmitMock} onClose={onCloseMock} />, | ||
); | ||
const submitButton = screen.getByRole("button", { name: "Submit" }); | ||
const cancelButton = screen.getByRole("button", { name: "Cancel" }); | ||
|
||
expect(submitButton).not.toBeDisabled(); | ||
expect(cancelButton).not.toBeDisabled(); | ||
|
||
rerender( | ||
<FeedbackForm | ||
onSubmit={onSubmitMock} | ||
onClose={onCloseMock} | ||
isSubmitting | ||
/>, | ||
); | ||
expect(submitButton).toBeDisabled(); | ||
expect(cancelButton).toBeDisabled(); | ||
}); | ||
}); |
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
Oops, something went wrong.