forked from anti-work/shortest
-
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.
- Loading branch information
Showing
1 changed file
with
8 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,6 @@ import { vi, describe, it, expect, beforeEach } from "vitest"; | |
import { PullRequest } from "./types"; | ||
import useSWR from "swr"; | ||
import { fetchBuildStatus } from "@/lib/github"; | ||
import { experimental_useObject as useObject } from "ai/react"; | ||
import { act } from "react"; | ||
|
||
vi.mock("@/lib/github", async () => { | ||
const actual = await vi.importActual("@/lib/github"); | ||
|
@@ -48,14 +46,6 @@ vi.mock("./log-view", () => ({ | |
LogView: () => <div data-testid="log-view">Mocked Log View</div>, | ||
})); | ||
|
||
vi.mock("./log-view", () => ({ | ||
LogView: () => <div data-testid="log-view">Mocked Log View</div>, | ||
})); | ||
|
||
vi.mock("ai/react", () => ({ | ||
experimental_useObject: vi.fn(), | ||
})); | ||
|
||
describe("PullRequestItem", () => { | ||
const mockPullRequest: PullRequest = { | ||
id: 1, | ||
|
@@ -84,11 +74,6 @@ describe("PullRequestItem", () => { | |
isValidating: false, | ||
isLoading: false, | ||
}); | ||
vi.mocked(useObject).mockReturnValue({ | ||
object: null, | ||
submit: vi.fn(), | ||
isLoading: false, | ||
}); | ||
}); | ||
|
||
it("renders the pull request information correctly", () => { | ||
|
@@ -157,8 +142,6 @@ describe("PullRequestItem", () => { | |
); | ||
}); | ||
|
||
// Verify that fetchBuildStatus is called with the correct parameters | ||
|
||
expect(fetchBuildStatusMock).toHaveBeenCalledWith( | ||
mockPullRequest.repository.owner.login, | ||
mockPullRequest.repository.name, | ||
|
@@ -178,16 +161,6 @@ describe("PullRequestItem", () => { | |
"https://github.com/commit/123" | ||
); | ||
|
||
const mockSubmit = vi.fn(); | ||
vi.mocked(useObject).mockReturnValue({ | ||
object: null, | ||
submit: mockSubmit, | ||
isLoading: false, | ||
setInput: vi.fn(), | ||
error: null, | ||
stop: vi.fn(), | ||
}); | ||
|
||
const mutate = vi.fn(); | ||
vi.mocked(useSWR).mockReturnValue({ | ||
data: mockPullRequest, | ||
|
@@ -197,6 +170,13 @@ describe("PullRequestItem", () => { | |
isLoading: false, | ||
}); | ||
|
||
global.fetch = vi.fn().mockResolvedValue({ | ||
ok: true, | ||
json: () => Promise.resolve({ | ||
tests: [{ name: "generated_test.ts", content: "generated content" }] | ||
}) | ||
}); | ||
|
||
render(<PullRequestItem pullRequest={mockPullRequest} />); | ||
|
||
const writeTestsButton = screen.getByText("Write new tests"); | ||
|
@@ -206,15 +186,6 @@ describe("PullRequestItem", () => { | |
expect(screen.getByText("Analyzing PR diff...")).toBeInTheDocument(); | ||
}); | ||
|
||
await act(async () => { | ||
const { onFinish } = vi.mocked(useObject).mock.calls[0][0]; | ||
await onFinish({ | ||
object: { | ||
tests: [{ name: "generated_test.ts", content: "generated content" }], | ||
}, | ||
}); | ||
}); | ||
|
||
await waitFor(() => { | ||
Check failure on line 189 in app/(dashboard)/dashboard/pull-request.test.tsx GitHub Actions / testapp/(dashboard)/dashboard/pull-request.test.tsx > PullRequestItem > triggers revalidation after committing changes
|
||
expect(screen.getByText("generated_test.ts")).toBeInTheDocument(); | ||
}); | ||
|
@@ -260,4 +231,4 @@ describe("PullRequestItem", () => { | |
expect(screen.getByText("Show Logs")).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); | ||
}); |