1
0
Fork 0
mirror of synced 2024-06-02 02:25:17 +12:00
budibase/qa-core/src/tests/internal-api/applications/create.spec.ts

84 lines
2.7 KiB
TypeScript
Raw Normal View History

2022-09-27 04:54:14 +13:00
import TestConfiguration from "../../../config/internal-api/TestConfiguration"
import { Application } from "@budibase/server/api/controllers/public/mapping/types"
import InternalAPIClient from "../../../config/internal-api/TestConfiguration/InternalAPIClient"
2022-09-29 06:21:05 +13:00
import generateApp from "../../../config/internal-api/fixtures/applications"
2022-10-01 03:03:38 +13:00
import generator from "../../../config/generator"
2022-09-27 04:54:14 +13:00
describe("Internal API - /applications endpoints", () => {
const api = new InternalAPIClient()
const config = new TestConfiguration<Application>(api)
beforeAll(async () => {
await config.beforeAll()
2022-09-29 06:21:05 +13:00
await config.auth.login()
2022-09-27 04:54:14 +13:00
})
afterAll(async () => {
await config.afterAll()
2022-09-29 06:21:05 +13:00
await config.auth.logout()
2022-09-27 04:54:14 +13:00
})
2022-10-01 03:35:13 +13:00
xit("POST - Can login", async () => {
2022-09-27 04:54:14 +13:00
const [response] = await config.auth.login()
expect(response).toHaveStatusCode(200)
})
2022-10-01 03:35:13 +13:00
xit("GET - fetch applications", async () => {
2022-09-29 06:21:05 +13:00
await config.applications.create({
...generateApp(),
useTemplate: false
})
const [response, apps] = await config.applications.fetch()
expect(response).toHaveStatusCode(200)
2022-10-01 03:35:13 +13:00
expect(apps.length).toBeGreaterThanOrEqual(1)
2022-09-29 06:21:05 +13:00
})
2022-10-01 03:35:13 +13:00
xit("POST - Create an application", async () => {
2022-09-29 21:33:48 +13:00
const [response, app] = await config.applications.create(generateApp())
2022-09-27 04:54:14 +13:00
expect(response).toHaveStatusCode(200)
expect(app._id).toBeDefined()
})
2022-10-01 03:03:38 +13:00
2022-10-01 03:35:13 +13:00
it("POST - Create an application from a template and check it renders", async () => {
2022-10-01 03:03:38 +13:00
const appName = generator.word()
const [response, app] = await config.applications.create({
name: appName,
url: `/${generator.word()}`,
useTemplate: true,
templateName: "Car Rental Admin Panel",
templateKey: "app/car-rental-admin-panel",
templateFile: undefined
})
expect(response).toHaveStatusCode(200)
expect(app.appId).toBeDefined()
2022-10-01 03:35:13 +13:00
config.applications.api.appId = app.appId
const [_, renderable] = await config.applications.canRender()
expect(renderable).toBe(true)
2022-10-01 03:03:38 +13:00
})
2022-10-01 03:35:13 +13:00
xit("POST - Publish app from template", async () => {
2022-10-01 03:03:38 +13:00
const appUrl = `/${generator.word()}`
const [response, app] = await config.applications.create({
name: generator.word(),
url: appUrl,
useTemplate: true,
templateName: "Car Rental Admin Panel",
templateKey: "app/car-rental-admin-panel",
templateFile: undefined
})
expect(response).toHaveStatusCode(200)
expect(app.appId).toBeDefined()
config.applications.api.appId = app.appId
const [publishResponse, json] = await config.applications.publish()
expect(publishResponse).toHaveStatusCode(200)
expect(json).toEqual({
_id: expect.any(String),
appUrl,
status: "SUCCESS"
})
})
2022-09-27 04:54:14 +13:00
})