Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/SearchRequestAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ export class SearchRequestAdapter {
// Add union parameter if configured
if (this.configuration.union) {
searchRequest.union = this.configuration.union;
commonParams.page = searches[0].page;
}

return this.typesenseClient.multiSearch.perform(searchRequest, commonParams);
Expand Down
9 changes: 7 additions & 2 deletions test/SearchRequestAdpater.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ describe("SearchRequestAdapter", () => {
},
],
},
{},
{
page: 1,
},
);
});

Expand Down Expand Up @@ -466,6 +468,7 @@ describe("SearchRequestAdapter", () => {
conversation: true,
conversation_id: "conv_123",
conversation_model_id: "model_456",
page: 1,
},
);
});
Expand Down Expand Up @@ -507,7 +510,9 @@ describe("SearchRequestAdapter", () => {
},
],
},
{},
{
page: 1,
},
);
});
});
Expand Down
33 changes: 33 additions & 0 deletions test/unionSearch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,37 @@ describe("Union Search", () => {
});
});
});

describe("pagination with union search", () => {
beforeEach(async () => {
return expect(page).toFill("#searchbox input[type=search]", "phone");
});

it("renders pagination controls for merged results from multiple indices", async () => {
await page.waitForSelector("#pagination a.ais-Pagination-link");

const paginationLinks = await page.$$("#pagination a.ais-Pagination-link");
expect(paginationLinks.length).toBeGreaterThan(0);

await expect(page).toMatchElement("#hits .ais-Hits-item:nth-of-type(1)");
});

it("shows different merged results when navigating to the second page", async () => {
await page.waitForSelector("#pagination a.ais-Pagination-link");

const firstPageFirstResult = await page.$eval("#hits .ais-Hits-item:nth-of-type(1)", (el) => el.textContent);

await expect(page).toClick("#pagination a", { text: "2" });

await page.waitForSelector("#hits .ais-Hits-item:nth-of-type(1)");

const secondPageFirstResult = await page.$eval("#hits .ais-Hits-item:nth-of-type(1)", (el) => el.textContent);

expect(firstPageFirstResult).not.toBe(secondPageFirstResult);

await expect(page).toMatchElement("#hits");
await expect(page).not.toMatchElement("#product-hits", { timeout: 1000 });
await expect(page).not.toMatchElement("#brand-hits", { timeout: 1000 });
});
});
});
Loading