2022-10-11 03:39:02 +13:00
|
|
|
import TestConfiguration from "../../../config/internal-api/TestConfiguration"
|
|
|
|
import { App } from "@budibase/types"
|
|
|
|
import InternalAPIClient from "../../../config/internal-api/TestConfiguration/InternalAPIClient"
|
|
|
|
import generateApp from "../../../config/internal-api/fixtures/applications"
|
2022-10-22 06:52:39 +13:00
|
|
|
import { Screen } from "@budibase/types"
|
2022-10-11 03:39:02 +13:00
|
|
|
import generateScreen from "../../../config/internal-api/fixtures/screens"
|
|
|
|
|
|
|
|
describe("Internal API - /screens endpoints", () => {
|
|
|
|
const api = new InternalAPIClient()
|
|
|
|
const config = new TestConfiguration<Screen>(api)
|
|
|
|
const appConfig = new TestConfiguration<App>(api)
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
await config.beforeAll()
|
|
|
|
})
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await config.afterAll()
|
|
|
|
})
|
|
|
|
|
2022-10-11 05:44:19 +13:00
|
|
|
it("POST - Create a screen with each role type", async () => {
|
2022-10-11 03:39:02 +13:00
|
|
|
// Create app
|
2022-10-21 05:48:05 +13:00
|
|
|
const app = await appConfig.applications.create(generateApp())
|
2022-10-22 06:52:39 +13:00
|
|
|
|
2022-10-11 03:39:02 +13:00
|
|
|
// Create Screen
|
2022-10-11 05:44:19 +13:00
|
|
|
const roleArray = ["BASIC", "POWER", "ADMIN", "PUBLIC"]
|
2022-10-11 03:39:02 +13:00
|
|
|
appConfig.applications.api.appId = app.appId
|
2022-10-13 05:48:33 +13:00
|
|
|
for (let role in roleArray) {
|
2022-10-22 06:52:39 +13:00
|
|
|
const [response, screen] = await config.screen.create(
|
|
|
|
generateScreen(roleArray[role])
|
|
|
|
)
|
2022-10-11 05:44:19 +13:00
|
|
|
}
|
2022-10-11 05:27:55 +13:00
|
|
|
})
|
|
|
|
|
|
|
|
it("GET - Fetch screens", async () => {
|
|
|
|
// Create app
|
2022-10-21 05:48:05 +13:00
|
|
|
const app = await appConfig.applications.create(generateApp())
|
2022-10-22 06:52:39 +13:00
|
|
|
|
2022-10-11 05:27:55 +13:00
|
|
|
// Create Screen
|
|
|
|
appConfig.applications.api.appId = app.appId
|
2022-11-17 00:34:16 +13:00
|
|
|
await config.screen.create(generateScreen("BASIC"))
|
2022-10-11 03:39:02 +13:00
|
|
|
|
2022-10-11 05:27:55 +13:00
|
|
|
// Check screen exists
|
2022-11-08 04:48:24 +13:00
|
|
|
await appConfig.applications.getRoutes(true)
|
2022-10-11 03:39:02 +13:00
|
|
|
})
|
|
|
|
|
|
|
|
it("DELETE - Delete a screen", async () => {
|
|
|
|
// Create app
|
2022-10-21 05:48:05 +13:00
|
|
|
const app = await appConfig.applications.create(generateApp())
|
2022-10-22 06:52:39 +13:00
|
|
|
|
2022-10-11 03:39:02 +13:00
|
|
|
// Create Screen
|
|
|
|
appConfig.applications.api.appId = app.appId
|
2022-10-22 06:52:39 +13:00
|
|
|
const [screenResponse, screen] = await config.screen.create(
|
|
|
|
generateScreen("BASIC")
|
|
|
|
)
|
2022-10-11 03:39:02 +13:00
|
|
|
|
|
|
|
// Delete Screen
|
2022-11-08 04:48:24 +13:00
|
|
|
await config.screen.delete(screen._id!, screen._rev!)
|
2022-10-11 03:39:02 +13:00
|
|
|
})
|
|
|
|
})
|