-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add better support for applications search (#1092)
* Add better support for applications search Plain user input is now converted to tsquery with prefix support Add tests for improved search * Add extended applications search support Add search by all applicant fields Add search by alternateContact emai Add escape of special characters to plainto_tsquery, by default they was changed to AND operators * Add test for applications search Co-authored-by: Bart <[email protected]>
- Loading branch information
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -456,6 +456,51 @@ describe("Applications", () => { | |
expect(res.body.items[0]).toMatchObject(createRes.body) | ||
}) | ||
|
||
it(`should allow an admin to search for users application using search query param with partial textquery`, async () => { | ||
const body = getTestAppBody(listing1Id) | ||
body.applicant.firstName = "John" | ||
const createRes = await supertest(app.getHttpServer()) | ||
.post(`/applications/submit`) | ||
.send(body) | ||
.expect(201) | ||
expect(createRes.body).toMatchObject(body) | ||
expect(createRes.body).toHaveProperty("createdAt") | ||
expect(createRes.body).toHaveProperty("updatedAt") | ||
expect(createRes.body).toHaveProperty("id") | ||
|
||
const res = await supertest(app.getHttpServer()) | ||
.get(`/applications/?search=joh`) | ||
.set(...setAuthorization(adminAccessToken)) | ||
.expect(200) | ||
expect(Array.isArray(res.body.items)).toBe(true) | ||
expect(res.body.items.length).toBe(1) | ||
expect(res.body.items[0].id === createRes.body.id) | ||
expect(res.body.items[0]).toMatchObject(createRes.body) | ||
}) | ||
|
||
it(`should allow an admin to search for users application using email as textquery`, async () => { | ||
const body = getTestAppBody(listing1Id) | ||
body.applicant.firstName = "John" | ||
body.applicant.emailAddress = "[email protected]" | ||
const createRes = await supertest(app.getHttpServer()) | ||
.post(`/applications/submit`) | ||
.send(body) | ||
.expect(201) | ||
expect(createRes.body).toMatchObject(body) | ||
expect(createRes.body).toHaveProperty("createdAt") | ||
expect(createRes.body).toHaveProperty("updatedAt") | ||
expect(createRes.body).toHaveProperty("id") | ||
|
||
const res = await supertest(app.getHttpServer()) | ||
.get(`/applications/[email protected]`) | ||
.set(...setAuthorization(adminAccessToken)) | ||
.expect(200) | ||
expect(Array.isArray(res.body.items)).toBe(true) | ||
expect(res.body.items.length).toBe(1) | ||
expect(res.body.items[0].id === createRes.body.id) | ||
expect(res.body.items[0]).toMatchObject(createRes.body) | ||
}) | ||
|
||
it(`should allow exporting applications as CSV`, async () => { | ||
const body = getTestAppBody(listing1Id) | ||
const createRes = await supertest(app.getHttpServer()) | ||
|