feat(translation,core-flows): translate remaining core entities and sync shipping option <> method translations (#14358)
* Get translated shipping options step * Apply translations on shipping options list methods. * Pass shipping option naem when refreshing cart shipping methods, so if locale changed, we update the name * Update translatable fields config * Cart shipping method update translation tests * Shipping options translations tests * Add changeset * Update order shipping method translations on update * Remove unnecessary workflow and use step instead * Translate shipping method on order edit * Use new update shipping methods tranlsations step * Draft order shipping method translation sync * Translate shipping method on order exchange * Translate returns shipping methods * Translate claims shipping methods * Remove unnecessary check * Early return * Fix import --------- Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Oli Juhl
parent
5f807ee657
commit
11de7e3e34
@@ -255,7 +255,7 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
).data.shipping_option
|
||||
|
||||
// Create translations for product and variants
|
||||
// Create translations for product, variants, and shipping options
|
||||
await api.post(
|
||||
"/admin/translations/batch",
|
||||
{
|
||||
@@ -302,6 +302,22 @@ medusaIntegrationTestRunner({
|
||||
locale_code: "de-DE",
|
||||
translations: { title: "Mittel" },
|
||||
},
|
||||
{
|
||||
reference_id: shippingOption.id,
|
||||
reference: "shipping_option",
|
||||
locale_code: "fr-FR",
|
||||
translations: {
|
||||
name: "Option d'expédition de test",
|
||||
},
|
||||
},
|
||||
{
|
||||
reference_id: shippingOption.id,
|
||||
reference: "shipping_option",
|
||||
locale_code: "de-DE",
|
||||
translations: {
|
||||
name: "Test-Versandoption",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
adminHeaders
|
||||
@@ -378,6 +394,30 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("should preserve translated shipping methods when order is created from cart with locale", async () => {
|
||||
const order = await createOrderFromCart("fr-FR")
|
||||
|
||||
expect(order.shipping_methods).toHaveLength(1)
|
||||
expect(order.shipping_methods[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
shipping_option_id: shippingOption.id,
|
||||
name: "Option d'expédition de test",
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("should have original shipping method name when order is created without locale", async () => {
|
||||
const order = await createOrderFromCart()
|
||||
|
||||
expect(order.shipping_methods).toHaveLength(1)
|
||||
expect(order.shipping_methods[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
shipping_option_id: shippingOption.id,
|
||||
name: "Test shipping option",
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/orders/:id (update order locale)", () => {
|
||||
@@ -405,6 +445,32 @@ medusaIntegrationTestRunner({
|
||||
)
|
||||
})
|
||||
|
||||
it("should re-translate shipping methods when locale is updated", async () => {
|
||||
const order = await createOrderFromCart("fr-FR")
|
||||
|
||||
expect(order.shipping_methods[0].name).toEqual(
|
||||
"Option d'expédition de test"
|
||||
)
|
||||
|
||||
await api.post(
|
||||
`/admin/orders/${order.id}`,
|
||||
{ locale: "de-DE" },
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
const updatedOrder = (
|
||||
await api.get(`/admin/orders/${order.id}`, adminHeaders)
|
||||
).data.order
|
||||
|
||||
expect(updatedOrder.shipping_methods).toHaveLength(1)
|
||||
expect(updatedOrder.shipping_methods[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
shipping_option_id: shippingOption.id,
|
||||
name: "Test-Versandoption",
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("should not re-translate items when updating other fields", async () => {
|
||||
const order = await createOrderFromCart("fr-FR")
|
||||
|
||||
@@ -429,6 +495,31 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
it("should not re-translate shipping methods when updating other fields", async () => {
|
||||
const order = await createOrderFromCart("fr-FR")
|
||||
|
||||
await api.post(
|
||||
`/admin/orders/${order.id}`,
|
||||
{ email: "updated@example.com" },
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
const updatedOrder = (
|
||||
await api.get(
|
||||
`/admin/orders/${order.id}?fields=+email,+shipping_methods.name`,
|
||||
adminHeaders
|
||||
)
|
||||
).data.order
|
||||
|
||||
expect(updatedOrder.email).toEqual("updated@example.com")
|
||||
expect(updatedOrder.shipping_methods[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
shipping_option_id: shippingOption.id,
|
||||
name: "Option d'expédition de test",
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user