fix: test

This commit is contained in:
Apoorv Mishra committed 2024-07-26 22:25:50 +05:30
1 parent e330be11f3
commit e54a35a2f3
2 files changed
+22

No files matched your search

@@ -486,6 +486,25 @@ describe("SearchHelper", () => {
);
expect(totalCount).toBe(1);
});
test("should correctly handle removal of trailing spaces", async () => {
const team = await buildTeam();
const user = await buildUser({ teamId: team.id });
const collection = await buildCollection({
teamId: team.id,
userId: user.id,
});
const document = await buildDocument({
teamId: team.id,
userId: user.id,
collectionId: collection.id,
text: "env: some env",
});
document.title = "change";
await document.save();
const { totalCount } = await SearchHelper.searchForUser(user, "env: ");
expect(totalCount).toBe(1);
});
});
describe("#searchTitlesForUser", () => {
+3
View File
@@ -556,6 +556,9 @@ export default class SearchHelper {
return (
queryParser()(
// Although queryParser trims the query, looks like there's a
// bug for certain cases where it removes other characters in addition to
// spaces. Ref: https://github.com/caub/pg-tsquery/issues/27
quotedSearch ? limitedQuery.trim() : `${limitedQuery.trim()}*`
)
// Remove any trailing join characters