* feat(): Translation first steps * feat(): locale middleware * feat(): readonly links * feat(): feature flag * feat(): modules sdk * feat(): translation module re export * start adding workflows * update typings * update typings * test(): Add integration tests * test(): centralize filters preparation * test(): centralize filters preparation * remove unnecessary importy * fix workflows * Define StoreLocale inside Store Module * Link definition to extend Store with supported_locales * store_locale migration * Add supported_locales handling in Store Module * Tests * Accept supported_locales in Store endpoints * Add locales to js-sdk * Include locale list and default locale in Store Detail section * Initialize local namespace in js-sdk * Add locales route * Make code primary key of locale table to facilitate upserts * Add locales routes * Show locale code as is * Add list translations api route * Batch endpoint * Types * New batchTranslationsWorkflow and various updates to existent ones * Edit default locale UI * WIP * Apply translation agnostically * middleware * Apply translation agnostically * fix Apply translation agnostically * apply translations to product list * Add feature flag * fetch translations by batches of 250 max * fix apply * improve and test util * apply to product list * dont manage translations if no locale * normalize locale * potential todo * Protect translations routes with feature flag * Extract normalize locale util to core/utils * Normalize locale on write * Normalize locale for read * Use feature flag to guard translations UI across the board * Avoid throwing incorrectly when locale_code not present in partial updates * move applyTranslations util * remove old tests * fix util tests * fix(): product end points * cleanup * update lock * remove unused var * cleanup * fix apply locale * missing new dep for test utils * Change entity_type, entity_id to reference, reference_id * Remove comment * Avoid registering translations route if ff not enabled * Prevent registering express handler for disabled route via defineFileConfig * Add tests * Add changeset * Update test * fix integration tests, module and internals * Add locale id plus fixed * Allow to pass array of reference_id * fix unit tests * fix link loading * fix store route * fix sales channel test * fix tests --------- Co-authored-by: Nicolas Gorga <nicogorga11@gmail.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
import { MedusaWorkflow } from "@medusajs/framework/workflows-sdk"
|
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils"
|
|
import path from "path"
|
|
import { setTimeout as setTimeoutPromise } from "timers/promises"
|
|
import { testJobHandler } from "../../__fixtures__/feature-flag/src/jobs/test-job"
|
|
|
|
jest.setTimeout(100000)
|
|
|
|
medusaIntegrationTestRunner({
|
|
cwd: path.join(__dirname, "../../__fixtures__/feature-flag"),
|
|
testSuite: ({ api, dbConnection }) => {
|
|
describe("Resources loaded without feature flags", () => {
|
|
it("should not load migration when feature flag is disabled and not run job", async () => {
|
|
const migrationNotExecuted = await dbConnection.raw(
|
|
`SELECT name FROM "mikro_orm_migrations" WHERE name = 'MigrationTest'`
|
|
)
|
|
expect(migrationNotExecuted.rows).toHaveLength(0)
|
|
|
|
const migrationExecuted = await dbConnection.raw(
|
|
`SELECT name FROM "mikro_orm_migrations" WHERE name = 'Noop'`
|
|
)
|
|
|
|
expect(migrationExecuted.rows).toHaveLength(1)
|
|
expect(migrationExecuted.rows[0].name).toBe("Noop")
|
|
|
|
await setTimeoutPromise(1000)
|
|
|
|
expect(testJobHandler).toHaveBeenCalledTimes(0)
|
|
})
|
|
|
|
it("should not load workflow when feature flag is disabled", async () => {
|
|
expect(MedusaWorkflow.getWorkflow("test-workflow")).toBeUndefined()
|
|
})
|
|
|
|
it("should not load scheduled job when feature flag is disabled", async () => {
|
|
expect(
|
|
MedusaWorkflow.getWorkflow("job-greeting-every-second")
|
|
).toBeUndefined()
|
|
})
|
|
|
|
it("should not load endpoint when feature flag is disabled", async () => {
|
|
expect(api.get("/custom")).rejects.toThrow()
|
|
})
|
|
|
|
it("should return 404 (not 400) for POST route with middleware when feature flag is disabled", async () => {
|
|
const { response } = await api
|
|
.post("/custom", {
|
|
invalid: "test",
|
|
})
|
|
.catch((e) => e)
|
|
|
|
expect(response.status).toBe(404)
|
|
})
|
|
})
|
|
},
|
|
})
|