From 6809bb451046d45f51366c1e6573cccd34db6f4d Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 19 Jul 2023 12:39:41 +0200 Subject: [PATCH] Use api for view search tests --- packages/server/src/api/routes/tests/row.spec.ts | 6 +----- packages/server/src/tests/utilities/api/viewV2.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/server/src/api/routes/tests/row.spec.ts b/packages/server/src/api/routes/tests/row.spec.ts index d9d1401cfc..eaec009b88 100644 --- a/packages/server/src/api/routes/tests/row.spec.ts +++ b/packages/server/src/api/routes/tests/row.spec.ts @@ -717,11 +717,7 @@ describe("/rows", () => { const createViewResponse = await config.api.viewV2.create() - const response = await request - .get(`/api/v2/views/${createViewResponse._id}/search`) - .set(config.defaultHeaders()) - .expect("Content-Type", /json/) - .expect(200) + const response = await config.api.viewV2.search(createViewResponse._id!) expect(response.body.rows).toHaveLength(10) expect(response.body).toEqual({ diff --git a/packages/server/src/tests/utilities/api/viewV2.ts b/packages/server/src/tests/utilities/api/viewV2.ts index a1e8f019cf..a830a68ec9 100644 --- a/packages/server/src/tests/utilities/api/viewV2.ts +++ b/packages/server/src/tests/utilities/api/viewV2.ts @@ -62,4 +62,12 @@ export class ViewV2API extends TestAPI { .set(this.config.defaultHeaders()) .expect(expectStatus) } + + search = async (viewId: string, { expectStatus } = { expectStatus: 200 }) => { + return this.request + .get(`/api/v2/views/${viewId}/search`) + .set(this.config.defaultHeaders()) + .expect("Content-Type", /json/) + .expect(expectStatus) + } }