@@ -3,7 +3,10 @@ import {
33 createTestableVertex ,
44 FakeExplorer ,
55} from "@/utils/testing" ;
6- import { patchEntityDetails } from "./patchEntityDetails" ;
6+ import {
7+ patchEntityDetails ,
8+ PatchEntityDetailsError ,
9+ } from "./patchEntityDetails" ;
710import { createQueryClient } from "@/core/queryClient" ;
811import {
912 createResultScalar ,
@@ -222,4 +225,55 @@ describe("patchEntityDetails", () => {
222225
223226 expect ( result ) . toStrictEqual ( [ expectedBundle ] ) ;
224227 } ) ;
228+
229+ it ( "should throw when source vertex not found" , async ( ) => {
230+ const explorer = new FakeExplorer ( ) ;
231+ const client = createQueryClient ( { explorer } ) ;
232+
233+ const edge = createTestableEdge ( ) ;
234+ explorer . addTestableEdge ( edge ) ;
235+ explorer . vertexMap . delete ( edge . source . id ) ;
236+
237+ await expect ( ( ) =>
238+ patchEntityDetails ( client , [ edge . asFragmentResult ( ) ] )
239+ ) . rejects . toThrow (
240+ new PatchEntityDetailsError (
241+ "Failed to fetch the details of some of the entity results (vertices: 1, edges: 0)."
242+ )
243+ ) ;
244+ } ) ;
245+
246+ it ( "should throw when target vertex not found" , async ( ) => {
247+ const explorer = new FakeExplorer ( ) ;
248+ const client = createQueryClient ( { explorer } ) ;
249+
250+ const edge = createTestableEdge ( ) ;
251+ explorer . addTestableEdge ( edge ) ;
252+ explorer . vertexMap . delete ( edge . target . id ) ;
253+
254+ await expect ( ( ) =>
255+ patchEntityDetails ( client , [ edge . asFragmentResult ( ) ] )
256+ ) . rejects . toThrow (
257+ new PatchEntityDetailsError (
258+ "Failed to fetch the details of some of the entity results (vertices: 1, edges: 0)."
259+ )
260+ ) ;
261+ } ) ;
262+
263+ it ( "should throw when edge full details not found" , async ( ) => {
264+ const explorer = new FakeExplorer ( ) ;
265+ const client = createQueryClient ( { explorer } ) ;
266+
267+ const edge = createTestableEdge ( ) ;
268+ explorer . addTestableEdge ( edge ) ;
269+ explorer . edgeMap . delete ( edge . id ) ;
270+
271+ await expect ( ( ) =>
272+ patchEntityDetails ( client , [ edge . asFragmentResult ( ) ] )
273+ ) . rejects . toThrow (
274+ new PatchEntityDetailsError (
275+ "Failed to fetch the details of some of the entity results (vertices: 0, edges: 1)."
276+ )
277+ ) ;
278+ } ) ;
225279} ) ;
0 commit comments