@@ -166,6 +166,76 @@ describe('FeedService', () => {
166166 expect ( data . title ) . toBe ( 'Test Feed' ) ;
167167 } ) ;
168168
169+ it ( 'should prefer a numeric feed id over another feed numeric alias' , async ( ) => {
170+ const firstRes = await app . request ( '/' , {
171+ method : 'POST' ,
172+ headers : {
173+ 'Authorization' : 'Bearer mock_token_1' ,
174+ 'Content-Type' : 'application/json' ,
175+ } ,
176+ body : JSON . stringify ( {
177+ title : 'Previous Feed' ,
178+ alias : '2' ,
179+ content : 'Previous Content' ,
180+ listed : true ,
181+ draft : false ,
182+ tags : [ ] ,
183+ } ) ,
184+ } , env ) ;
185+ expect ( firstRes . status ) . toBe ( 200 ) ;
186+
187+ const secondRes = await app . request ( '/' , {
188+ method : 'POST' ,
189+ headers : {
190+ 'Authorization' : 'Bearer mock_token_1' ,
191+ 'Content-Type' : 'application/json' ,
192+ } ,
193+ body : JSON . stringify ( {
194+ title : 'Target Feed' ,
195+ content : 'Target Content' ,
196+ listed : true ,
197+ draft : false ,
198+ tags : [ ] ,
199+ } ) ,
200+ } , env ) ;
201+ expect ( secondRes . status ) . toBe ( 200 ) ;
202+ const secondData = await secondRes . json ( ) as any ;
203+
204+ const getRes = await app . request ( `/${ secondData . insertedId } ` , { method : 'GET' } , env ) ;
205+
206+ expect ( getRes . status ) . toBe ( 200 ) ;
207+ const data = await getRes . json ( ) as any ;
208+ expect ( data . id ) . toBe ( secondData . insertedId ) ;
209+ expect ( data . title ) . toBe ( 'Target Feed' ) ;
210+ expect ( data . content ) . toBe ( 'Target Content' ) ;
211+ } ) ;
212+
213+ it ( 'should return feed by non-numeric alias' , async ( ) => {
214+ const createRes = await app . request ( '/' , {
215+ method : 'POST' ,
216+ headers : {
217+ 'Authorization' : 'Bearer mock_token_1' ,
218+ 'Content-Type' : 'application/json' ,
219+ } ,
220+ body : JSON . stringify ( {
221+ title : 'Alias Feed' ,
222+ alias : 'custom-slug' ,
223+ content : 'Alias Content' ,
224+ listed : true ,
225+ draft : false ,
226+ tags : [ ] ,
227+ } ) ,
228+ } , env ) ;
229+
230+ expect ( createRes . status ) . toBe ( 200 ) ;
231+
232+ const getRes = await app . request ( '/custom-slug' , { method : 'GET' } , env ) ;
233+
234+ expect ( getRes . status ) . toBe ( 200 ) ;
235+ const data = await getRes . json ( ) as any ;
236+ expect ( data . title ) . toBe ( 'Alias Feed' ) ;
237+ } ) ;
238+
169239 it ( 'should return AI summary generation status for a queued feed' , async ( ) => {
170240 await serverConfig . set ( 'ai_summary.enabled' , 'true' , false ) ;
171241 await serverConfig . set ( 'ai_summary.provider' , 'worker-ai' , false ) ;
0 commit comments