1
0
Fork 0
mirror of synced 2024-10-02 18:16:29 +13:00

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") 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") 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) return useFeature(Feature.SYNC_AUTOMATIONS)
} }
export const useAppBuilders = () => {
return useFeature(Feature.APP_BUILDERS)
}
// QUOTAS // QUOTAS
export const setAutomationLogsQuota = (value: number) => { 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 { TestConfiguration, structures } from "../../../../tests"
import { mocks } from "@budibase/backend-core/tests"
import { User } from "@budibase/types" import { User } from "@budibase/types"
const MOCK_APP_ID = "app_a" const MOCK_APP_ID = "app_a"
@ -24,18 +25,31 @@ describe("/api/global/users/:userId/app/builder", () => {
return response.body as User 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", () => { describe("PATCH /api/global/users/:userId/app/:appId/builder", () => {
it("should be able to grant a user access to a particular app", async () => { it("should be able to grant a user access to a particular app", async () => {
mocks.licenses.useAppBuilders()
const user = await newUser() const user = await newUser()
await config.api.users.grantBuilderToApp(user._id!, MOCK_APP_ID) await config.api.users.grantBuilderToApp(user._id!, MOCK_APP_ID)
const updated = await getUser(user._id!) const updated = await getUser(user._id!)
expect(updated.builder?.appBuilder).toBe(true)
expect(updated.builder?.apps![0]).toBe(MOCK_APP_ID) expect(updated.builder?.apps![0]).toBe(MOCK_APP_ID)
}) })
}) })
describe("DELETE /api/global/users/:userId/app/:appId/builder", () => { describe("DELETE /api/global/users/:userId/app/:appId/builder", () => {
it("should allow revoking access", async () => { it("should allow revoking access", async () => {
mocks.licenses.useAppBuilders()
const user = await newUser() const user = await newUser()
await config.api.users.grantBuilderToApp(user._id!, MOCK_APP_ID) await config.api.users.grantBuilderToApp(user._id!, MOCK_APP_ID)
let updated = await getUser(user._id!) let updated = await getUser(user._id!)