feat(medusa, utils): Allow object feature flags (#4701)
Feature flags can be set as follows:
**Environment variables**
```
MEDUSA_FF_ANALYTICS=true
MEDUSA_FF_WORKFLOWS=createProducts,addShippingMethods
```
**Project config**
```
{
featureFlags: {
analytics: true,
workflows: {
createProducts: true,
addShippingMethods: true,
}
}
}
```
This commit is contained in:
@@ -6,9 +6,10 @@ import { initDb, useDb } from "../../../../environment-helpers/use-db"
|
||||
import adminSeeder from "../../../../helpers/admin-seeder"
|
||||
import productSeeder from "../../../../helpers/product-seeder"
|
||||
|
||||
import { simpleSalesChannelFactory } from "../../../../factories"
|
||||
import { AxiosInstance } from "axios"
|
||||
import { Modules, ModulesDefinition } from "@medusajs/modules-sdk"
|
||||
import { Workflows } from "@medusajs/workflows"
|
||||
import { AxiosInstance } from "axios"
|
||||
import { simpleSalesChannelFactory } from "../../../../factories"
|
||||
|
||||
jest.setTimeout(5000000)
|
||||
|
||||
@@ -51,6 +52,16 @@ describe("/admin/products", () => {
|
||||
).toBeTruthy()
|
||||
})
|
||||
|
||||
it("Should have enabled workflows feature flag", function () {
|
||||
const flagRouter = medusaContainer.resolve("featureFlagRouter")
|
||||
|
||||
const workflowsFlag = flagRouter.isFeatureEnabled({
|
||||
workflows: Workflows.CreateProducts,
|
||||
})
|
||||
|
||||
expect(workflowsFlag).toBe(true)
|
||||
})
|
||||
|
||||
describe("POST /admin/products", () => {
|
||||
beforeEach(async () => {
|
||||
await productSeeder(dbConnection)
|
||||
|
||||
Reference in New Issue
Block a user