@@ -27,7 +27,7 @@ async function seedPosts(db: Db) {
2727 }
2828 const needle = await handleContentCreate ( db , "posts" , {
2929 slug : "the-needle-post" ,
30- data : { title : "zzz Needle Headline" } ,
30+ data : { title : "zzz Needle Headline" , ticket_number : "TICKET2179" } ,
3131 } ) ;
3232 if ( ! needle . success ) throw new Error ( "needle seed failed" ) ;
3333
@@ -59,6 +59,12 @@ describe("content list search served by FTS (#1517)", () => {
5959 type : "string" ,
6060 searchable : true ,
6161 } ) ;
62+ await registry . createField ( "posts" , {
63+ slug : "ticket_number" ,
64+ label : "Ticket number" ,
65+ type : "string" ,
66+ searchable : true ,
67+ } ) ;
6268 await seedPosts ( db ) ;
6369 await new FTSManager ( db ) . enableSearch ( "posts" ) ;
6470 } ) ;
@@ -90,6 +96,11 @@ describe("content list search served by FTS (#1517)", () => {
9096 expect ( titlesOf ( result ) ) . toContain ( "zzz Needle Headline" ) ;
9197 } ) ;
9298
99+ it ( "finds an entry by a searchable custom field" , async ( ) => {
100+ const result = await handleContentList ( db , "posts" , { q : "ticket217" , limit : 20 } ) ;
101+ expect ( titlesOf ( result ) ) . toContain ( "zzz Needle Headline" ) ;
102+ } ) ;
103+
93104 it ( "returns a total that matches the filtered set, not the whole table" , async ( ) => {
94105 const result = await handleContentList ( db , "posts" , { q : "Needle" , limit : 20 } ) ;
95106 if ( ! result . success ) throw new Error ( "list failed" ) ;
@@ -144,6 +155,12 @@ describe("content list search falls back to LIKE when FTS cannot serve it", () =
144155 type : "text" ,
145156 searchable : true ,
146157 } ) ;
158+ await registry . createField ( "posts" , {
159+ slug : "ticket_number" ,
160+ label : "Ticket number" ,
161+ type : "string" ,
162+ searchable : true ,
163+ } ) ;
147164 await seedPosts ( db ) ;
148165 await new FTSManager ( db ) . enableSearch ( "posts" ) ;
149166 } ) ;
@@ -158,4 +175,9 @@ describe("content list search falls back to LIKE when FTS cannot serve it", () =
158175 const result = await handleContentList ( db , "posts" , { q : "eedle" , limit : 20 } ) ;
159176 expect ( titlesOf ( result ) ) . toContain ( "zzz Needle Headline" ) ;
160177 } ) ;
178+
179+ it ( "searches custom fields through the LIKE fallback" , async ( ) => {
180+ const result = await handleContentList ( db , "posts" , { q : "CKET21" , limit : 20 } ) ;
181+ expect ( titlesOf ( result ) ) . toContain ( "zzz Needle Headline" ) ;
182+ } ) ;
161183} ) ;
0 commit comments