From d9151cca0ad4122642f87ee4feccc14537fc1ad5 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 9 Mar 2021 16:28:41 +0000 Subject: [PATCH] Adding test cases for backup and integration. --- .../src/api/routes/tests/backup.spec.js | 32 ++++++++++++ .../src/api/routes/tests/integration.spec.js | 52 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 packages/server/src/api/routes/tests/backup.spec.js create mode 100644 packages/server/src/api/routes/tests/integration.spec.js diff --git a/packages/server/src/api/routes/tests/backup.spec.js b/packages/server/src/api/routes/tests/backup.spec.js new file mode 100644 index 0000000000..d603990294 --- /dev/null +++ b/packages/server/src/api/routes/tests/backup.spec.js @@ -0,0 +1,32 @@ +const { checkBuilderEndpoint } = require("./utilities/TestFunctions") +const setup = require("./utilities") + +describe("/backups", () => { + let request = setup.getRequest() + let config = setup.getConfig() + + afterAll(setup.afterAll) + + beforeEach(async () => { + await config.init() + }) + + describe("exportAppDump", () => { + it("should be able to export app", async () => { + const res = await request + .get(`/api/backups/export?appId=${config.getAppId()}`) + .set(config.defaultHeaders()) + .expect(200) + expect(res.text).toBeDefined() + expect(res.text.includes(`"db_name":"${config.getAppId()}"`)).toEqual(true) + }) + + it("should apply authorization to endpoint", async () => { + await checkBuilderEndpoint({ + config, + method: "GET", + url: `/api/backups/export?appId=${config.getAppId()}`, + }) + }) + }) +}) \ No newline at end of file diff --git a/packages/server/src/api/routes/tests/integration.spec.js b/packages/server/src/api/routes/tests/integration.spec.js new file mode 100644 index 0000000000..528d0d3417 --- /dev/null +++ b/packages/server/src/api/routes/tests/integration.spec.js @@ -0,0 +1,52 @@ +const { checkBuilderEndpoint } = require("./utilities/TestFunctions") +const setup = require("./utilities") + +describe("/integrations", () => { + let request = setup.getRequest() + let config = setup.getConfig() + + afterAll(setup.afterAll) + + beforeEach(async () => { + await config.init() + }) + + describe("fetch", () => { + it("should be able to get all integration definitions", async () => { + const res = await request + .get(`/api/integrations`) + .set(config.defaultHeaders()) + .expect("Content-Type", /json/) + .expect(200) + expect(res.body.POSTGRES).toBeDefined() + expect(res.body.POSTGRES.friendlyName).toEqual("PostgreSQL") + }) + + it("should apply authorization to endpoint", async () => { + await checkBuilderEndpoint({ + config, + method: "GET", + url: `/api/integrations`, + }) + }) + }) + + describe("find", () => { + it("should be able to get postgres definition", async () => { + const res = await request + .get(`/api/integrations/POSTGRES`) + .set(config.defaultHeaders()) + .expect("Content-Type", /json/) + .expect(200) + expect(res.body.friendlyName).toEqual("PostgreSQL") + }) + + it("should apply authorization to endpoint", async () => { + await checkBuilderEndpoint({ + config, + method: "GET", + url: `/api/integrations/POSTGRES`, + }) + }) + }) +}) \ No newline at end of file