@@ -868,27 +868,6 @@ describe('Sequelize CRUD Repository (integration)', () => {
868868 ] ) ;
869869 } ) ;
870870
871- it ( 'hides hidden properties in related entities' , async ( ) => {
872- await migrateSchema ( [ 'todos' , 'todo-lists' , 'users' ] ) ;
873-
874- const userRes = await client . post ( '/users' ) . send ( getDummyUser ( ) ) ;
875-
876- await client . post ( '/todo-lists' ) . send (
877- getDummyTodoList ( {
878- title : 'Todo list one' ,
879- userId : userRes . body . id ,
880- } ) ,
881- ) ;
882-
883- const filter = { include : [ 'user' ] } ;
884- const relationRes = await client . get ( `/todo-lists` ) . query ( {
885- filter : JSON . stringify ( filter ) ,
886- } ) ;
887-
888- expect ( relationRes . body . length ) . to . be . equal ( 1 ) ;
889- expect ( relationRes . body . at ( 0 ) . user ) . not . to . have . property ( 'password' ) ;
890- } ) ;
891-
892871 it ( 'supports `order` filter by associations' , async ( ) => {
893872 await migrateSchema ( [ 'todos' , 'todo-lists' ] ) ;
894873
@@ -1026,6 +1005,27 @@ describe('Sequelize CRUD Repository (integration)', () => {
10261005 ) ;
10271006 } ) ;
10281007
1008+ it ( 'hides hidden properties in related entities included with @belongsTo relation' , async ( ) => {
1009+ await migrateSchema ( [ 'todos' , 'todo-lists' , 'users' ] ) ;
1010+
1011+ const userRes = await client . post ( '/users' ) . send ( getDummyUser ( ) ) ;
1012+
1013+ await client . post ( '/todo-lists' ) . send (
1014+ getDummyTodoList ( {
1015+ title : 'Todo list one' ,
1016+ userId : userRes . body . id ,
1017+ } ) ,
1018+ ) ;
1019+
1020+ const filter = { include : [ 'user' ] } ;
1021+ const relationRes = await client . get ( `/todo-lists` ) . query ( {
1022+ filter : JSON . stringify ( filter ) ,
1023+ } ) ;
1024+
1025+ expect ( relationRes . body . length ) . to . be . equal ( 1 ) ;
1026+ expect ( relationRes . body . at ( 0 ) . user ) . not . to . have . property ( 'password' ) ;
1027+ } ) ;
1028+
10291029 it ( 'supports @belongsTo using keyfrom and keyto' , async ( ) => {
10301030 await migrateSchema ( [ 'users' , 'todos' , 'todo-lists' ] ) ;
10311031
@@ -1078,13 +1078,13 @@ describe('Sequelize CRUD Repository (integration)', () => {
10781078
10791079 const doctorRes = await client . post ( '/doctors' ) . send ( getDummyDoctor ( ) ) ;
10801080 const patientRes = await client
1081- . post ( `/doctors/${ 1 } /patients` )
1081+ . post ( `/doctors/${ doctorRes . body . id } /patients` )
10821082 . send ( getDummyPatient ( ) ) ;
10831083
10841084 const filter = { include : [ 'patients' ] } ;
1085- const relationRes = await client . get (
1086- `/doctors?filter= ${ encodeURIComponent ( JSON . stringify ( filter ) ) } ` ,
1087- ) ;
1085+ const relationRes = await client
1086+ . get ( `/doctors` )
1087+ . query ( { filter : JSON . stringify ( filter ) } ) ;
10881088
10891089 /**
10901090 * Manually Remove through table data as sqlite3 doesn't support `attributes: []` using sequelize
@@ -1099,6 +1099,29 @@ describe('Sequelize CRUD Repository (integration)', () => {
10991099 ] ) ;
11001100 } ) ;
11011101
1102+ it ( 'hides hidden props for nested entities included with @hasMany relation' , async ( ) => {
1103+ await migrateSchema ( [ 'doctors' ] ) ;
1104+
1105+ const doctorRes = await client . post ( '/doctors' ) . send ( getDummyDoctor ( ) ) ;
1106+
1107+ await client . post ( `/doctors/${ doctorRes . body . id } /patients` ) . send (
1108+ getDummyPatient ( {
1109+ password : 'secret' ,
1110+ } ) ,
1111+ ) ;
1112+
1113+ const filter = { include : [ 'patients' ] } ;
1114+ const relationRes = await client
1115+ . get ( `/doctors` )
1116+ . query ( { filter : JSON . stringify ( filter ) } ) ;
1117+
1118+ expect ( relationRes . body . length ) . to . be . equal ( 1 ) ;
1119+ expect ( relationRes . body . at ( 0 ) ) . to . have . property ( 'patients' ) ;
1120+ expect ( relationRes . body . at ( 0 ) . patients . at ( 0 ) ) . to . not . have . property (
1121+ 'password' ,
1122+ ) ;
1123+ } ) ;
1124+
11021125 it ( 'supports @referencesMany' , async ( ) => {
11031126 await migrateSchema ( [ 'developers' ] ) ;
11041127
0 commit comments