@@ -58,4 +58,37 @@ describe("Union Search", () => {
5858 } ) ;
5959 } ) ;
6060 } ) ;
61+
62+ describe ( "pagination with union search" , ( ) => {
63+ beforeEach ( async ( ) => {
64+ return expect ( page ) . toFill ( "#searchbox input[type=search]" , "phone" ) ;
65+ } ) ;
66+
67+ it ( "renders pagination controls for merged results from multiple indices" , async ( ) => {
68+ await page . waitForSelector ( "#pagination a.ais-Pagination-link" ) ;
69+
70+ const paginationLinks = await page . $$ ( "#pagination a.ais-Pagination-link" ) ;
71+ expect ( paginationLinks . length ) . toBeGreaterThan ( 0 ) ;
72+
73+ await expect ( page ) . toMatchElement ( "#hits .ais-Hits-item:nth-of-type(1)" ) ;
74+ } ) ;
75+
76+ it ( "shows different merged results when navigating to the second page" , async ( ) => {
77+ await page . waitForSelector ( "#pagination a.ais-Pagination-link" ) ;
78+
79+ const firstPageFirstResult = await page . $eval ( "#hits .ais-Hits-item:nth-of-type(1)" , ( el ) => el . textContent ) ;
80+
81+ await expect ( page ) . toClick ( "#pagination a" , { text : "2" } ) ;
82+
83+ await page . waitForSelector ( "#hits .ais-Hits-item:nth-of-type(1)" ) ;
84+
85+ const secondPageFirstResult = await page . $eval ( "#hits .ais-Hits-item:nth-of-type(1)" , ( el ) => el . textContent ) ;
86+
87+ expect ( firstPageFirstResult ) . not . toBe ( secondPageFirstResult ) ;
88+
89+ await expect ( page ) . toMatchElement ( "#hits" ) ;
90+ await expect ( page ) . not . toMatchElement ( "#product-hits" , { timeout : 1000 } ) ;
91+ await expect ( page ) . not . toMatchElement ( "#brand-hits" , { timeout : 1000 } ) ;
92+ } ) ;
93+ } ) ;
6194} ) ;
0 commit comments