@@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest';
33import * as Entity from '../../src/entity/index.js' ;
44import * as Type from '../../src/type/type.js' ;
55import { getRelationTypeIds } from '../../src/utils/get-relation-type-ids.js' ;
6- import { buildRelationsSelection } from '../../src/utils/relation-query-helpers.js' ;
6+ import { buildRelationsSelection , getRelationAlias } from '../../src/utils/relation-query-helpers.js' ;
77
88const FRIENDS_RELATION_PROPERTY_ID = Id ( 'f44ae32a-2f13-4d3f-875f-19d2338a32b8' ) ;
99const CHILDREN_RELATION_PROPERTY_ID = Id ( '8a6dcb99-9c7b-4ca9-9f7b-98f2f404b405' ) ;
@@ -100,6 +100,11 @@ describe('relation include config overrides', () => {
100100 } satisfies Entity . EntityInclude < typeof Parent > ;
101101
102102 const relationInfo = getRelationTypeIds ( Parent , include ) ;
103+ const childrenRelationInfo = relationInfo . find ( ( info ) => info . propertyName === 'children' ) ;
104+ const childrenAlias = getRelationAlias (
105+ childrenRelationInfo ?. typeId ?? CHILDREN_RELATION_PROPERTY_ID ,
106+ childrenRelationInfo ?. targetTypeIds ,
107+ ) ;
103108 expect ( relationInfo [ 0 ] ) . toMatchObject ( {
104109 relationSpaces : [ 'space-rel' , 'space-rel-2' ] ,
105110 valueSpaces : [ 'space-values' ] ,
@@ -114,9 +119,7 @@ describe('relation include config overrides', () => {
114119 expect ( selection ) . toContain ( 'valuesList(filter: {spaceId: {in: ["space-values"]}})' ) ;
115120 expect ( selection ) . toContain ( `toEntity: { typeIds: { in: ${ stringifyTypeIds ( CHILD_TYPES ) } } }` ) ;
116121 expect ( selection ) . toContain ( `toEntity: { typeIds: { in: ${ stringifyTypeIds ( FRIEND_TYPES ) } } }` ) ;
117- expect ( selection . split ( 'relations_f44ae32a_2f13_4d3f_875f_19d2338a32b8' ) [ 0 ] ) . not . toContain (
118- 'spaceId: {is: $spaceId}' ,
119- ) ;
122+ expect ( selection . split ( childrenAlias ) [ 0 ] ) . not . toContain ( 'spaceId: {is: $spaceId}' ) ;
120123 } ) ;
121124
122125 it ( 'omits filters entirely when overrides use "all"' , ( ) => {
0 commit comments