Split application tests
This commit is contained in:
parent
b2d96eaa6f
commit
576f47e4a9
|
@ -1,138 +0,0 @@
|
||||||
import TestConfiguration from "../../../config/internal-api/TestConfiguration"
|
|
||||||
import { Application } from "@budibase/server/api/controllers/public/mapping/types"
|
|
||||||
import { db } from "@budibase/backend-core"
|
|
||||||
import InternalAPIClient from "../../../config/internal-api/TestConfiguration/InternalAPIClient"
|
|
||||||
import AccountsAPIClient from "../../../config/internal-api/TestConfiguration/accountsAPIClient"
|
|
||||||
import { generateApp, appFromTemplate } from "../../../config/internal-api/fixtures/applications"
|
|
||||||
import generator from "../../../config/generator"
|
|
||||||
import generateScreen from "../../../config/internal-api/fixtures/screens"
|
|
||||||
|
|
||||||
describe("Internal API - Application creation, update, publish and delete", () => {
|
|
||||||
const api = new InternalAPIClient()
|
|
||||||
const accountsAPI = new AccountsAPIClient()
|
|
||||||
const config = new TestConfiguration<Application>(api, accountsAPI)
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await config.setupAccountAndTenant()
|
|
||||||
})
|
|
||||||
|
|
||||||
afterAll(async () => {
|
|
||||||
await config.afterAll()
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
it("Get applications without applications", async () => {
|
|
||||||
await config.applications.fetchEmptyAppList()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("Get all Applications after creating an application", async () => {
|
|
||||||
await config.applications.create({
|
|
||||||
...generateApp(),
|
|
||||||
useTemplate: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
await config.applications.fetchAllApplications()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("Get application details", async () => {
|
|
||||||
const app = await config.applications.create({
|
|
||||||
...generateApp(),
|
|
||||||
useTemplate: false,
|
|
||||||
})
|
|
||||||
config.applications.api.appId = app.appId
|
|
||||||
|
|
||||||
const [appPackageResponse, appPackageJson] =
|
|
||||||
await config.applications.getAppPackage(<string>app.appId)
|
|
||||||
expect(appPackageJson.application.name).toEqual(app.name)
|
|
||||||
expect(appPackageJson.application.version).toEqual(app.version)
|
|
||||||
expect(appPackageJson.application.url).toEqual(app.url)
|
|
||||||
expect(appPackageJson.application.tenantId).toEqual(app.tenantId)
|
|
||||||
expect(appPackageJson.application.status).toEqual(app.status)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("Publish app", async () => {
|
|
||||||
// create the app
|
|
||||||
const app = await config.applications.create(appFromTemplate())
|
|
||||||
config.applications.api.appId = app.appId
|
|
||||||
|
|
||||||
// check preview renders
|
|
||||||
await config.applications.canRender()
|
|
||||||
|
|
||||||
// publish app
|
|
||||||
await config.applications.publish(<string>app.appId)
|
|
||||||
|
|
||||||
// check published app renders
|
|
||||||
config.applications.api.appId = db.getProdAppID(app.appId!)
|
|
||||||
await config.applications.canRender()
|
|
||||||
|
|
||||||
// unpublish app
|
|
||||||
await config.applications.unpublish(<string>app.appId)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("Sync application before deployment", async () => {
|
|
||||||
const app = await config.applications.create(generateApp())
|
|
||||||
config.applications.api.appId = app.appId
|
|
||||||
|
|
||||||
const [syncResponse, sync] = await config.applications.sync(
|
|
||||||
<string>app.appId
|
|
||||||
)
|
|
||||||
expect(sync).toEqual({
|
|
||||||
message: "App sync not required, app not deployed.",
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it("Sync application after deployment", async () => {
|
|
||||||
const app = await config.applications.create(generateApp())
|
|
||||||
config.applications.api.appId = app.appId
|
|
||||||
|
|
||||||
// publish app
|
|
||||||
await config.applications.publish(<string>app._id)
|
|
||||||
|
|
||||||
const [syncResponse, sync] = await config.applications.sync(
|
|
||||||
<string>app.appId
|
|
||||||
)
|
|
||||||
expect(sync).toEqual({
|
|
||||||
message: "App sync completed successfully.",
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it("Update an application", async () => {
|
|
||||||
const app = await config.applications.create(generateApp())
|
|
||||||
|
|
||||||
config.applications.api.appId = app.appId
|
|
||||||
|
|
||||||
await config.applications.update(<string>app.appId, <string>app.name, {
|
|
||||||
name: generator.word(),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
it("Revert Changes without changes", async () => {
|
|
||||||
const app = await config.applications.create(generateApp())
|
|
||||||
config.applications.api.appId = app.appId
|
|
||||||
|
|
||||||
await config.applications.revertUnpublished(<string>app.appId)
|
|
||||||
})
|
|
||||||
|
|
||||||
it("Revert Changes", async () => {
|
|
||||||
const app = await config.applications.create(generateApp())
|
|
||||||
config.applications.api.appId = app.appId
|
|
||||||
|
|
||||||
// publish app
|
|
||||||
await config.applications.publish(<string>app._id)
|
|
||||||
|
|
||||||
// Change/add component to the app
|
|
||||||
await config.screen.create(generateScreen("BASIC"))
|
|
||||||
|
|
||||||
// // Revert the app to published state
|
|
||||||
await config.applications.revertPublished(<string>app.appId)
|
|
||||||
|
|
||||||
// Check screen is removed
|
|
||||||
await config.applications.getRoutes()
|
|
||||||
})
|
|
||||||
|
|
||||||
it("DELETE - Delete an application", async () => {
|
|
||||||
const app = await config.applications.create(generateApp())
|
|
||||||
|
|
||||||
await config.applications.delete(<string>app.appId)
|
|
||||||
})
|
|
||||||
})
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
import TestConfiguration from "../../../config/internal-api/TestConfiguration"
|
||||||
|
import { Application } from "@budibase/server/api/controllers/public/mapping/types"
|
||||||
|
import { db } from "@budibase/backend-core"
|
||||||
|
import InternalAPIClient from "../../../config/internal-api/TestConfiguration/InternalAPIClient"
|
||||||
|
import AccountsAPIClient from "../../../config/internal-api/TestConfiguration/accountsAPIClient"
|
||||||
|
import { generateApp, appFromTemplate } from "../../../config/internal-api/fixtures/applications"
|
||||||
|
import generator from "../../../config/generator"
|
||||||
|
import generateScreen from "../../../config/internal-api/fixtures/screens"
|
||||||
|
|
||||||
|
describe("Internal API - Application creation", () => {
|
||||||
|
const api = new InternalAPIClient()
|
||||||
|
const accountsAPI = new AccountsAPIClient()
|
||||||
|
const config = new TestConfiguration<Application>(api, accountsAPI)
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await config.setupAccountAndTenant()
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await config.afterAll()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
it("Get applications without applications", async () => {
|
||||||
|
await config.applications.fetchEmptyAppList()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("Get all Applications after creating an application", async () => {
|
||||||
|
await config.applications.create({
|
||||||
|
...generateApp(),
|
||||||
|
useTemplate: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
await config.applications.fetchAllApplications()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("Get application details", async () => {
|
||||||
|
const app = await config.applications.create({
|
||||||
|
...generateApp(),
|
||||||
|
useTemplate: false,
|
||||||
|
})
|
||||||
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
const [appPackageResponse, appPackageJson] =
|
||||||
|
await config.applications.getAppPackage(<string>app.appId)
|
||||||
|
expect(appPackageJson.application.name).toEqual(app.name)
|
||||||
|
expect(appPackageJson.application.version).toEqual(app.version)
|
||||||
|
expect(appPackageJson.application.url).toEqual(app.url)
|
||||||
|
expect(appPackageJson.application.tenantId).toEqual(app.tenantId)
|
||||||
|
expect(appPackageJson.application.status).toEqual(app.status)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
|
@ -0,0 +1,29 @@
|
||||||
|
import TestConfiguration from "../../../config/internal-api/TestConfiguration"
|
||||||
|
import { Application } from "@budibase/server/api/controllers/public/mapping/types"
|
||||||
|
import { db } from "@budibase/backend-core"
|
||||||
|
import InternalAPIClient from "../../../config/internal-api/TestConfiguration/InternalAPIClient"
|
||||||
|
import AccountsAPIClient from "../../../config/internal-api/TestConfiguration/accountsAPIClient"
|
||||||
|
import { generateApp, appFromTemplate } from "../../../config/internal-api/fixtures/applications"
|
||||||
|
import generator from "../../../config/generator"
|
||||||
|
import generateScreen from "../../../config/internal-api/fixtures/screens"
|
||||||
|
|
||||||
|
describe("Internal API - Application creation, update, publish and delete", () => {
|
||||||
|
const api = new InternalAPIClient()
|
||||||
|
const accountsAPI = new AccountsAPIClient()
|
||||||
|
const config = new TestConfiguration<Application>(api, accountsAPI)
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await config.setupAccountAndTenant()
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await config.afterAll()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
it("DELETE - Delete an application", async () => {
|
||||||
|
const app = await config.applications.create(generateApp())
|
||||||
|
|
||||||
|
await config.applications.delete(<string>app.appId)
|
||||||
|
})
|
||||||
|
})
|
|
@ -0,0 +1,70 @@
|
||||||
|
import TestConfiguration from "../../../config/internal-api/TestConfiguration"
|
||||||
|
import { Application } from "@budibase/server/api/controllers/public/mapping/types"
|
||||||
|
import { db } from "@budibase/backend-core"
|
||||||
|
import InternalAPIClient from "../../../config/internal-api/TestConfiguration/InternalAPIClient"
|
||||||
|
import AccountsAPIClient from "../../../config/internal-api/TestConfiguration/accountsAPIClient"
|
||||||
|
import { generateApp, appFromTemplate } from "../../../config/internal-api/fixtures/applications"
|
||||||
|
import generator from "../../../config/generator"
|
||||||
|
import generateScreen from "../../../config/internal-api/fixtures/screens"
|
||||||
|
|
||||||
|
describe("Internal API - Application creation, update, publish and delete", () => {
|
||||||
|
const api = new InternalAPIClient()
|
||||||
|
const accountsAPI = new AccountsAPIClient()
|
||||||
|
const config = new TestConfiguration<Application>(api, accountsAPI)
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await config.setupAccountAndTenant()
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await config.afterAll()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
it("Publish app", async () => {
|
||||||
|
// create the app
|
||||||
|
const app = await config.applications.create(appFromTemplate())
|
||||||
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
// check preview renders
|
||||||
|
await config.applications.canRender()
|
||||||
|
|
||||||
|
// publish app
|
||||||
|
await config.applications.publish(<string>app.appId)
|
||||||
|
|
||||||
|
// check published app renders
|
||||||
|
config.applications.api.appId = db.getProdAppID(app.appId!)
|
||||||
|
await config.applications.canRender()
|
||||||
|
|
||||||
|
// unpublish app
|
||||||
|
await config.applications.unpublish(<string>app.appId)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("Sync application before deployment", async () => {
|
||||||
|
const app = await config.applications.create(generateApp())
|
||||||
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
const [syncResponse, sync] = await config.applications.sync(
|
||||||
|
<string>app.appId
|
||||||
|
)
|
||||||
|
expect(sync).toEqual({
|
||||||
|
message: "App sync not required, app not deployed.",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("Sync application after deployment", async () => {
|
||||||
|
const app = await config.applications.create(generateApp())
|
||||||
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
// publish app
|
||||||
|
await config.applications.publish(<string>app._id)
|
||||||
|
|
||||||
|
const [syncResponse, sync] = await config.applications.sync(
|
||||||
|
<string>app.appId
|
||||||
|
)
|
||||||
|
expect(sync).toEqual({
|
||||||
|
message: "App sync completed successfully.",
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
|
@ -0,0 +1,58 @@
|
||||||
|
import TestConfiguration from "../../../config/internal-api/TestConfiguration"
|
||||||
|
import { Application } from "@budibase/server/api/controllers/public/mapping/types"
|
||||||
|
import { db } from "@budibase/backend-core"
|
||||||
|
import InternalAPIClient from "../../../config/internal-api/TestConfiguration/InternalAPIClient"
|
||||||
|
import AccountsAPIClient from "../../../config/internal-api/TestConfiguration/accountsAPIClient"
|
||||||
|
import { generateApp, appFromTemplate } from "../../../config/internal-api/fixtures/applications"
|
||||||
|
import generator from "../../../config/generator"
|
||||||
|
import generateScreen from "../../../config/internal-api/fixtures/screens"
|
||||||
|
|
||||||
|
describe("Internal API - Application creation, update, publish and delete", () => {
|
||||||
|
const api = new InternalAPIClient()
|
||||||
|
const accountsAPI = new AccountsAPIClient()
|
||||||
|
const config = new TestConfiguration<Application>(api, accountsAPI)
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
await config.setupAccountAndTenant()
|
||||||
|
})
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await config.afterAll()
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
it("Update an application", async () => {
|
||||||
|
const app = await config.applications.create(generateApp())
|
||||||
|
|
||||||
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
await config.applications.update(<string>app.appId, <string>app.name, {
|
||||||
|
name: generator.word(),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it("Revert Changes without changes", async () => {
|
||||||
|
const app = await config.applications.create(generateApp())
|
||||||
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
await config.applications.revertUnpublished(<string>app.appId)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("Revert Changes", async () => {
|
||||||
|
const app = await config.applications.create(generateApp())
|
||||||
|
config.applications.api.appId = app.appId
|
||||||
|
|
||||||
|
// publish app
|
||||||
|
await config.applications.publish(<string>app._id)
|
||||||
|
|
||||||
|
// Change/add component to the app
|
||||||
|
await config.screen.create(generateScreen("BASIC"))
|
||||||
|
|
||||||
|
// // Revert the app to published state
|
||||||
|
await config.applications.revertPublished(<string>app.appId)
|
||||||
|
|
||||||
|
// Check screen is removed
|
||||||
|
await config.applications.getRoutes()
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue