1
0
Fork 0
mirror of synced 2024-06-12 15:34:54 +12:00
budibase/qa-core/src/account-api/tests/licensing/license.activate.spec.ts

69 lines
2 KiB
TypeScript
Raw Normal View History

import TestConfiguration from "../../config/TestConfiguration"
import * as fixures from "../../fixtures"
import { Feature, Hosting } from "@budibase/types"
describe("license activation", () => {
2023-10-06 05:43:25 +13:00
const config = new TestConfiguration()
2023-10-06 05:43:25 +13:00
beforeAll(async () => {
await config.beforeAll()
})
2023-10-06 05:43:25 +13:00
afterAll(async () => {
await config.afterAll()
})
2023-10-06 05:43:25 +13:00
it("creates, activates and deletes online license - self host", async () => {
// Remove existing license key
await config.internalApi.license.deleteLicenseKey()
2023-10-06 05:43:25 +13:00
// Verify license key not found
await config.internalApi.license.getLicenseKey({ status: 404 })
2023-10-06 05:43:25 +13:00
// Create self host account
const createAccountRequest = fixures.accounts.generateAccount({
hosting: Hosting.SELF,
})
const [createAccountRes, account] =
await config.accountsApi.accounts.create(createAccountRequest, {
autoVerify: true,
})
2023-10-06 05:43:25 +13:00
let licenseKey: string = " "
await config.doInNewState(async () => {
await config.loginAsAccount(createAccountRequest)
// Retrieve license key
const [res, body] = await config.accountsApi.licenses.getLicenseKey()
licenseKey = body.licenseKey
})
2023-10-06 05:43:25 +13:00
const accountId = account.accountId!
2023-10-06 05:43:25 +13:00
// Update license to have paid feature
const [res, acc] = await config.accountsApi.licenses.updateLicense(
accountId,
{
overrides: {
features: [Feature.APP_BACKUPS],
},
}
)
2023-10-06 05:43:25 +13:00
// Activate license key
await config.internalApi.license.activateLicenseKey({ licenseKey })
2023-10-06 05:43:25 +13:00
// Verify license updated with new feature
await config.doInNewState(async () => {
await config.loginAsAccount(createAccountRequest)
const [selfRes, body] = await config.api.accounts.self()
expect(body.license.features[0]).toBe("appBackups")
})
2023-10-06 05:43:25 +13:00
// Remove license key
await config.internalApi.license.deleteLicenseKey()
2023-10-06 05:43:25 +13:00
// Verify license key not found
await config.internalApi.license.getLicenseKey({ status: 404 })
})
})