feat(translation,fulfillment,customer,product,region,tax,core-flows,medusa,types): Implement dynamic translation settings management (#14536)
* Add is_active field to translation_settings model * Types * Workflows * Api layer * Tests * Add changeset * Add comment * Hook to create or deactivate translatable entities on startup * Cleanup old code * Configure translatable option for core entities * Validation step and snake case correction * Cleanup * Tests * Comment in PR * Update changeset * Mock DmlEntity.getTranslatableEntities * Move validation to module service layer * Remove validation from remaining workflow * Return object directly * Type improvements * Remove .only from tests * Apply snakeCase * Fix tests * Fix tests * Remove unnecessary map and use set instead * Fix tests * Comments * Include translatable product properties * Avoid race condition in translations tests * Update test
This commit is contained in:
@@ -1,15 +1,42 @@
|
||||
import { ITranslationModuleService } from "@medusajs/framework/types"
|
||||
import { Module, Modules } from "@medusajs/framework/utils"
|
||||
import { DmlEntity, Module, Modules } from "@medusajs/framework/utils"
|
||||
import { moduleIntegrationTestRunner } from "@medusajs/test-utils"
|
||||
import TranslationModuleService from "@services/translation-module"
|
||||
import { createLocaleFixture, createTranslationFixture } from "../__fixtures__"
|
||||
|
||||
jest.setTimeout(100000)
|
||||
|
||||
// Set up the mock before module initialization
|
||||
let mockGetTranslatableEntities: jest.SpyInstance
|
||||
|
||||
moduleIntegrationTestRunner<ITranslationModuleService>({
|
||||
moduleName: Modules.TRANSLATION,
|
||||
hooks: {
|
||||
beforeModuleInit: async () => {
|
||||
mockGetTranslatableEntities = jest.spyOn(
|
||||
DmlEntity,
|
||||
"getTranslatableEntities"
|
||||
)
|
||||
mockGetTranslatableEntities.mockReturnValue([
|
||||
{
|
||||
entity: "Product",
|
||||
fields: ["title", "description", "subtitle", "material"],
|
||||
},
|
||||
{ entity: "ProductVariant", fields: ["title", "material"] },
|
||||
{ entity: "ProductCategory", fields: ["name"] },
|
||||
])
|
||||
},
|
||||
},
|
||||
testSuite: ({ service }) => {
|
||||
describe("Translation Module Service", () => {
|
||||
beforeEach(async () => {
|
||||
await service.__hooks?.onApplicationStart?.().catch(() => {})
|
||||
})
|
||||
afterAll(() => {
|
||||
// Restore the mock after all tests complete
|
||||
mockGetTranslatableEntities.mockRestore()
|
||||
})
|
||||
|
||||
it(`should export the appropriate linkable configuration`, () => {
|
||||
const linkable = Module(Modules.TRANSLATION, {
|
||||
service: TranslationModuleService,
|
||||
|
||||
Reference in New Issue
Block a user