diff --git a/.changeset/afraid-kids-return.md b/.changeset/afraid-kids-return.md new file mode 100644 index 0000000000..f94c46c838 --- /dev/null +++ b/.changeset/afraid-kids-return.md @@ -0,0 +1,5 @@ +--- +"@medusajs/pricing": patch +--- + +fix(pricing): Update store + list price preferences diff --git a/integration-tests/http/__tests__/store/admin/store.spec.ts b/integration-tests/http/__tests__/store/admin/store.spec.ts index 0a23ba6407..84bc165423 100644 --- a/integration-tests/http/__tests__/store/admin/store.spec.ts +++ b/integration-tests/http/__tests__/store/admin/store.spec.ts @@ -1,6 +1,6 @@ +import { medusaIntegrationTestRunner } from "@medusajs/test-utils" import { IStoreModuleService } from "@medusajs/types" import { Modules } from "@medusajs/utils" -import { medusaIntegrationTestRunner } from "@medusajs/test-utils" import { adminHeaders, createAdminUser, @@ -66,6 +66,32 @@ medusaIntegrationTestRunner({ }) describe("POST /admin/stores", () => { + it("should update store", async () => { + const response = await api.post( + `/admin/stores/${store.id}`, + { + name: "Updated store", + + supported_currencies: [ + { currency_code: "eur", is_default: true }, + { currency_code: "usd" }, + ], + }, + adminHeaders + ).catch((e) => e) + + expect(response.status).toEqual(200) + expect(response.data.store).toEqual( + expect.objectContaining({ + name: "Updated store", + supported_currencies: [ + expect.objectContaining({ currency_code: "eur" }), + expect.objectContaining({ currency_code: "usd" }), + ], + }) + ) + }) + it("fails to update default currencies if there is no default one", async () => { const err = await api .post( diff --git a/packages/modules/pricing/src/services/pricing-module.ts b/packages/modules/pricing/src/services/pricing-module.ts index 546dfe8357..65934175be 100644 --- a/packages/modules/pricing/src/services/pricing-module.ts +++ b/packages/modules/pricing/src/services/pricing-module.ts @@ -365,7 +365,7 @@ export default class PricingModuleService ): Promise { const pricePreferences = await this.listPricePreferences_( filters, - { ...config, select: [...(config.select || []), "id"] }, + config, sharedContext )