Updates after running through tests, adding mocking of app builders feature for test cases to work.

This commit is contained in:
mike12345567 2023-07-28 12:58:05 +01:00
parent 2080126da2
commit 454f832b75
4 changed files with 24 additions and 3 deletions

View File

@ -196,7 +196,10 @@ export class UserDB {
throw new Error("_id or email is required")
}
if (user.builder?.apps?.length && !await this.features.isAppBuildersEnabled()) {
if (
user.builder?.apps?.length &&
!(await this.features.isAppBuildersEnabled())
) {
throw new Error("Unable to update app builders, please check license")
}

View File

@ -94,6 +94,10 @@ export const useSyncAutomations = () => {
return useFeature(Feature.SYNC_AUTOMATIONS)
}
export const useAppBuilders = () => {
return useFeature(Feature.APP_BUILDERS)
}
// QUOTAS
export const setAutomationLogsQuota = (value: number) => {

@ -1 +1 @@
Subproject commit 20b120c636184aa3497fa439c4ec5cc1e3696231
Subproject commit 8e00c6f4bbd3c02de32872819d4a053dc7c0c058

View File

@ -1,4 +1,5 @@
import { TestConfiguration, structures } from "../../../../tests"
import { mocks } from "@budibase/backend-core/tests"
import { User } from "@budibase/types"
const MOCK_APP_ID = "app_a"
@ -24,18 +25,31 @@ describe("/api/global/users/:userId/app/builder", () => {
return response.body as User
}
describe("Confirm pro license", () => {
it("should 400 with licensing", async () => {
const user = await newUser()
const resp = await config.api.users.grantBuilderToApp(
user._id!,
MOCK_APP_ID,
400
)
expect(resp.body.message).toContain("Feature not enabled")
})
})
describe("PATCH /api/global/users/:userId/app/:appId/builder", () => {
it("should be able to grant a user access to a particular app", async () => {
mocks.licenses.useAppBuilders()
const user = await newUser()
await config.api.users.grantBuilderToApp(user._id!, MOCK_APP_ID)
const updated = await getUser(user._id!)
expect(updated.builder?.appBuilder).toBe(true)
expect(updated.builder?.apps![0]).toBe(MOCK_APP_ID)
})
})
describe("DELETE /api/global/users/:userId/app/:appId/builder", () => {
it("should allow revoking access", async () => {
mocks.licenses.useAppBuilders()
const user = await newUser()
await config.api.users.grantBuilderToApp(user._id!, MOCK_APP_ID)
let updated = await getUser(user._id!)