-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove global node-fetch mock. #14297
Changes from 13 commits
3d20d4c
9a2e803
3657067
e530400
f16f1fb
b39875f
661e1f2
6d70dd1
c8fadc3
a973b65
a38dc3d
97e142a
b2f70f5
8d22df3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
import { npmUpload, urlUpload, githubUpload } from "./uploaders" | ||
import { plugins as pluginCore } from "@budibase/backend-core" | ||
import { PluginType, FileType, PluginSource } from "@budibase/types" | ||
import { | ||
PluginType, | ||
FileType, | ||
PluginSource, | ||
Ctx, | ||
CreatePluginRequest, | ||
CreatePluginResponse, | ||
} from "@budibase/types" | ||
import env from "../../../environment" | ||
import { clientAppSocket } from "../../../websockets" | ||
import sdk from "../../../sdk" | ||
|
@@ -29,7 +36,9 @@ export async function upload(ctx: any) { | |
} | ||
} | ||
|
||
export async function create(ctx: any) { | ||
export async function create( | ||
ctx: Ctx<CreatePluginRequest, CreatePluginResponse> | ||
) { | ||
const { source, url, headers, githubToken } = ctx.request.body | ||
|
||
try { | ||
|
@@ -75,14 +84,9 @@ export async function create(ctx: any) { | |
const doc = await pro.plugins.storePlugin(metadata, directory, source) | ||
|
||
clientAppSocket?.emit("plugins-update", { name, hash: doc.hash }) | ||
ctx.body = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice find! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It fell out after I typed the response object. |
||
message: "Plugin uploaded successfully", | ||
plugins: [doc], | ||
} | ||
ctx.body = { plugin: doc } | ||
} catch (err: any) { | ||
const errMsg = err?.message ? err?.message : err | ||
|
||
ctx.throw(400, `Failed to import plugin: ${errMsg}`) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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", "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this part of the test? It looks like all the tests are doing the same, probably are part of the setup instead |
||
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) | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅