forked from farhoodlabs/paperclip
Fix rebased issue detail prefetch typing
This commit is contained in:
@@ -84,23 +84,14 @@ describe("issueDetailCache", () => {
|
|||||||
expect(queryClient.getQueryData(queryKeys.issues.detail(issue.id))).toEqual(issue);
|
expect(queryClient.getQueryData(queryKeys.issues.detail(issue.id))).toEqual(issue);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("prefetches with the provided issue snapshot before the network result lands", async () => {
|
it("prefetches with the provided issue snapshot without forcing a fresh fetch", async () => {
|
||||||
const issue = createIssue();
|
const issue = createIssue();
|
||||||
let releaseFetch: (() => void) | null = null;
|
|
||||||
vi.mocked(issuesApi.get).mockImplementation(
|
|
||||||
() =>
|
|
||||||
new Promise<Issue>((resolve) => {
|
|
||||||
releaseFetch = () => resolve(issue);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
const prefetchPromise = prefetchIssueDetail(queryClient, issue.identifier!, { issue });
|
await prefetchIssueDetail(queryClient, issue.identifier!, { issue });
|
||||||
|
|
||||||
expect(getCachedIssueDetail(queryClient, issue.identifier)).toEqual(issue);
|
expect(getCachedIssueDetail(queryClient, issue.identifier)).toEqual(issue);
|
||||||
expect(getCachedIssueDetail(queryClient, issue.id)).toEqual(issue);
|
expect(getCachedIssueDetail(queryClient, issue.id)).toEqual(issue);
|
||||||
|
expect(issuesApi.get).not.toHaveBeenCalled();
|
||||||
releaseFetch?.();
|
|
||||||
await prefetchPromise;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("hydrates both cache aliases from a fetched issue detail response", async () => {
|
it("hydrates both cache aliases from a fetched issue detail response", async () => {
|
||||||
|
|||||||
@@ -1651,7 +1651,6 @@ export function IssueDetail() {
|
|||||||
<Link
|
<Link
|
||||||
to={createIssueDetailPath(ancestor.identifier ?? ancestor.id)}
|
to={createIssueDetailPath(ancestor.identifier ?? ancestor.id)}
|
||||||
state={resolvedIssueDetailState ?? location.state}
|
state={resolvedIssueDetailState ?? location.state}
|
||||||
issuePrefetch={ancestor}
|
|
||||||
onClickCapture={() =>
|
onClickCapture={() =>
|
||||||
rememberIssueDetailLocationState(
|
rememberIssueDetailLocationState(
|
||||||
ancestor.identifier ?? ancestor.id,
|
ancestor.identifier ?? ancestor.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user