From 202963c864abfc09d0991a7420d306580f6d8eaa Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 1 Aug 2023 12:34:50 +0200 Subject: [PATCH] Fix type tests --- .../worker/src/api/routes/global/tests/auth.spec.ts | 2 +- .../worker/src/api/routes/global/tests/self.spec.ts | 4 ++-- .../worker/src/api/routes/global/tests/users.spec.ts | 2 +- .../worker/src/api/routes/system/tests/status.spec.ts | 11 +++++++---- packages/worker/src/tests/mocks/index.ts | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/worker/src/api/routes/global/tests/auth.spec.ts b/packages/worker/src/api/routes/global/tests/auth.spec.ts index 5e62b2123f..47533a13d0 100644 --- a/packages/worker/src/api/routes/global/tests/auth.spec.ts +++ b/packages/worker/src/api/routes/global/tests/auth.spec.ts @@ -206,7 +206,7 @@ describe("/api/global/auth", () => { const newPassword = "newpassword" const res = await config.api.auth.updatePassword(code!, newPassword) - user = await config.getUser(user.email) + user = (await config.getUser(user.email))! delete user.password expect(res.body).toEqual({ message: "password reset successfully." }) diff --git a/packages/worker/src/api/routes/global/tests/self.spec.ts b/packages/worker/src/api/routes/global/tests/self.spec.ts index f3959c7521..274efb0aff 100644 --- a/packages/worker/src/api/routes/global/tests/self.spec.ts +++ b/packages/worker/src/api/routes/global/tests/self.spec.ts @@ -36,7 +36,7 @@ describe("/api/global/self", () => { }) .expect(200) - const dbUser = await config.getUser(user.email) + const dbUser = (await config.getUser(user.email))! user._rev = dbUser._rev user.dayPassRecordedAt = mocks.date.MOCK_DATE.toISOString() @@ -58,7 +58,7 @@ describe("/api/global/self", () => { }) .expect(200) - const dbUser = await config.getUser(user.email) + const dbUser = (await config.getUser(user.email))! user._rev = dbUser._rev user.dayPassRecordedAt = mocks.date.MOCK_DATE.toISOString() diff --git a/packages/worker/src/api/routes/global/tests/users.spec.ts b/packages/worker/src/api/routes/global/tests/users.spec.ts index 52d77cbae6..df9c19f8ca 100644 --- a/packages/worker/src/api/routes/global/tests/users.spec.ts +++ b/packages/worker/src/api/routes/global/tests/users.spec.ts @@ -66,7 +66,7 @@ describe("/api/global/users", () => { expect(res.body._id).toBeDefined() const user = await config.getUser(email) expect(user).toBeDefined() - expect(user._id).toEqual(res.body._id) + expect(user!._id).toEqual(res.body._id) expect(events.user.inviteAccepted).toBeCalledTimes(1) expect(events.user.inviteAccepted).toBeCalledWith(user) }) diff --git a/packages/worker/src/api/routes/system/tests/status.spec.ts b/packages/worker/src/api/routes/system/tests/status.spec.ts index fe0ff13551..48a0fc005d 100644 --- a/packages/worker/src/api/routes/system/tests/status.spec.ts +++ b/packages/worker/src/api/routes/system/tests/status.spec.ts @@ -1,3 +1,4 @@ +import { HealthStatusResponse } from "@budibase/types" import { TestConfiguration } from "../../../../tests" import { accounts as _accounts } from "@budibase/backend-core" const accounts = jest.mocked(_accounts) @@ -31,13 +32,15 @@ describe("/api/system/status", () => { }) it("returns status in cloud", async () => { - const value = { - health: { - passing: false, + const value: HealthStatusResponse = { + passing: false, + checks: { + login: false, + search: false, }, } - accounts.getStatus.mockReturnValueOnce(Promise.resolve(value)) + accounts.getStatus.mockResolvedValue(value) const res = await config.api.status.getStatus() diff --git a/packages/worker/src/tests/mocks/index.ts b/packages/worker/src/tests/mocks/index.ts index cab019bb46..917e5f9ffc 100644 --- a/packages/worker/src/tests/mocks/index.ts +++ b/packages/worker/src/tests/mocks/index.ts @@ -2,7 +2,7 @@ import * as email from "./email" import { mocks } from "@budibase/backend-core/tests" import * as _pro from "@budibase/pro" -const pro = jest.mocked(_pro, true) +const pro = jest.mocked(_pro, { shallow: false }) export default { email,