@@ -68,17 +68,111 @@ describe('Elasticsearch Service', () => {
6868 } )
6969 } )
7070
71- adapterTests ( [
72- '.id' , '.options' , '.events' , '._get' , '._find' , '._create' , '._update' , '._patch' , '._remove' ,
73- '.$get' , '.$find' , '.$create' , '.$update' , '.$patch' , '.$remove' ,
74- '.get' , '.get + $select' , '.get + id + query' , '.get + NotFound' , '.find' , '.remove' ,
75- '.remove + $select' , '.remove + id + query' , '.remove + multi' , '.update' , '.update + $select' ,
76- '.patch' , '.patch + $select' , '.patch multiple' , '.create' , '.create + $select' , '.create multi' ,
77- 'internal .find' , 'internal .get' , 'internal .create' , 'internal .update' , 'internal .patch' , 'internal .remove' ,
78- '.find + equal' , '.find + $sort' , '.find + $limit' , '.find + $skip' , '.find + $select' ,
79- '.find + $or' , '.find + $in' , '.find + $lt' , '.find + $gt' , '.find + $ne' ,
80- '.find + paginate' , 'params.adapter + paginate'
81- ] ) ( app , errors , 'people' , 'id' )
71+ describe ( 'Adapter tests' , ( ) => {
72+ before ( async function ( ) {
73+ this . timeout ( 10000 )
74+ // Clean up any existing data before running adapter tests
75+ const peopleService = app . service ( serviceName ) as any
76+ const originalMulti = peopleService . options . multi
77+ peopleService . options . multi = true
78+ try {
79+ await peopleService . remove ( null , { query : { $limit : 1000 } , refresh : 'wait_for' } )
80+ } catch ( error ) {
81+ // Ignore errors if no data exists
82+ }
83+ peopleService . options . multi = originalMulti
84+ // Force index refresh to ensure all changes are visible
85+ await db . getClient ( ) . indices . refresh ( { index : 'test-people' } )
86+ } )
87+
88+ adapterTests ( [
89+ '.id' ,
90+ '.options' ,
91+ '.events' ,
92+ '._get' ,
93+ '._find' ,
94+ '._create' ,
95+ '._update' ,
96+ '._patch' ,
97+ '._remove' ,
98+ '.$get' ,
99+ '.$find' ,
100+ '.$create' ,
101+ '.$update' ,
102+ '.$patch' ,
103+ '.$remove' ,
104+ '.get' ,
105+ '.get + $select' ,
106+ '.get + id + query' ,
107+ '.get + NotFound' ,
108+ '.get + NotFound (integer)' ,
109+ '.get + id + query id' ,
110+ '.find' ,
111+ '.remove' ,
112+ '.remove + $select' ,
113+ '.remove + id + query' ,
114+ '.remove + multi' ,
115+ '.remove + NotFound' ,
116+ '.remove + NotFound (integer)' ,
117+ '.remove + multi no pagination' ,
118+ '.remove + id + query id' ,
119+ '.update' ,
120+ '.update + $select' ,
121+ '.update + id + query' ,
122+ '.update + NotFound' ,
123+ '.update + NotFound (integer)' ,
124+ '.update + query + NotFound' ,
125+ '.update + id + query id' ,
126+ '.patch' ,
127+ '.patch + $select' ,
128+ '.patch multiple' ,
129+ '.patch + id + query' ,
130+ '.patch multiple no pagination' ,
131+ '.patch multi query same' ,
132+ '.patch multi query changed' ,
133+ '.patch + NotFound' ,
134+ '.patch + NotFound (integer)' ,
135+ '.patch + query + NotFound' ,
136+ '.patch + id + query id' ,
137+ '.create' ,
138+ '.create + $select' ,
139+ '.create multi' ,
140+ '.create ignores query' ,
141+ 'internal .find' ,
142+ 'internal .get' ,
143+ 'internal .create' ,
144+ 'internal .update' ,
145+ 'internal .patch' ,
146+ 'internal .remove' ,
147+ '.find + equal' ,
148+ '.find + equal multiple' ,
149+ '.find + $sort' ,
150+ '.find + $sort + string' ,
151+ '.find + $limit' ,
152+ '.find + $limit 0' ,
153+ '.find + $skip' ,
154+ '.find + $select' ,
155+ '.find + $or' ,
156+ '.find + $in' ,
157+ '.find + $nin' ,
158+ '.find + $lt' ,
159+ '.find + $lte' ,
160+ '.find + $gt' ,
161+ '.find + $gte' ,
162+ '.find + $gt + $lt + $sort' ,
163+ '.find + $ne' ,
164+ '.find + $or nested + $sort' ,
165+ '.find + $and' ,
166+ '.find + $and + $or' ,
167+ 'params.adapter + multi' ,
168+ '.find + paginate' ,
169+ '.find + paginate + query' ,
170+ '.find + paginate + $limit + $skip' ,
171+ '.find + paginate + $limit 0' ,
172+ '.find + paginate + params' ,
173+ 'params.adapter + paginate'
174+ ] ) ( app , errors , 'people' , 'id' )
175+ } )
82176
83177 describe ( 'Specific Elasticsearch tests' , ( ) => {
84178 before ( async ( ) => {
0 commit comments