diff --git a/packages/server/__mocks__/node-fetch.ts b/packages/server/__mocks__/_node-fetch.ts similarity index 100% rename from packages/server/__mocks__/node-fetch.ts rename to packages/server/__mocks__/_node-fetch.ts diff --git a/packages/server/src/api/routes/tests/application.spec.ts b/packages/server/src/api/routes/tests/application.spec.ts index 13b7451a7e..6ae598ee84 100644 --- a/packages/server/src/api/routes/tests/application.spec.ts +++ b/packages/server/src/api/routes/tests/application.spec.ts @@ -20,6 +20,7 @@ import { type App } from "@budibase/types" import tk from "timekeeper" import * as uuid from "uuid" import { structures } from "@budibase/backend-core/tests" +import nock from "nock" describe("/applications", () => { let config = setup.getConfig() @@ -35,6 +36,7 @@ describe("/applications", () => { throw new Error("Failed to publish app") } jest.clearAllMocks() + nock.cleanAll() }) // These need to go first for the app totals to make sense @@ -324,18 +326,33 @@ describe("/applications", () => { describe("delete", () => { it("should delete published app and dev apps with dev app ID", async () => { + const prodAppId = app.appId.replace("_dev", "") + nock("http://localhost:10000") + .delete(`/api/global/roles/${prodAppId}`) + .reply(200, {}) + await config.api.application.delete(app.appId) expect(events.app.deleted).toHaveBeenCalledTimes(1) expect(events.app.unpublished).toHaveBeenCalledTimes(1) }) it("should delete published app and dev app with prod app ID", async () => { - await config.api.application.delete(app.appId.replace("_dev", "")) + const prodAppId = app.appId.replace("_dev", "") + nock("http://localhost:10000") + .delete(`/api/global/roles/${prodAppId}`) + .reply(200, {}) + + await config.api.application.delete(prodAppId) expect(events.app.deleted).toHaveBeenCalledTimes(1) expect(events.app.unpublished).toHaveBeenCalledTimes(1) }) it("should be able to delete an app after SQS_SEARCH_ENABLE has been set but app hasn't been migrated", async () => { + const prodAppId = app.appId.replace("_dev", "") + nock("http://localhost:10000") + .delete(`/api/global/roles/${prodAppId}`) + .reply(200, {}) + await config.withCoreEnv({ SQS_SEARCH_ENABLE: "true" }, async () => { await config.api.application.delete(app.appId) })