fix(stock-location,core-flows,types): updates existing address when updating stock location (#10832)

* fix(stock-location,core-flows,types): updates existing address when updating stock location address

* chore: use hasOne instead of hasMany
This commit is contained in:
Riqwan Thamir
2025-01-07 07:55:28 +01:00
committed by GitHub
parent fde73dbfae
commit 99a06102a2
10 changed files with 336 additions and 7 deletions
@@ -165,6 +165,58 @@ medusaIntegrationTestRunner({
expect(response.status).toEqual(200)
expect(response.data.stock_location.name).toEqual("new name")
})
it("should update stock location address without creating new addresses", async () => {
const response = await api.post(
`/admin/stock-locations/${location1.id}`,
{
name: "new name",
address: {
address_1: "test",
country_code: "dk",
},
},
adminHeaders
)
const firstAddressId = response.data.stock_location.address.id
expect(response.status).toEqual(200)
expect(response.data.stock_location).toEqual(
expect.objectContaining({
name: "new name",
address: expect.objectContaining({
id: firstAddressId,
address_1: "test",
country_code: "dk",
}),
})
)
const response2 = await api.post(
`/admin/stock-locations/${location1.id}`,
{
name: "new name 2",
address: {
address_1: "test 2",
country_code: "dk",
},
},
adminHeaders
)
expect(response2.status).toEqual(200)
expect(response2.data.stock_location).toEqual(
expect.objectContaining({
name: "new name 2",
address: expect.objectContaining({
id: firstAddressId,
address_1: "test 2",
country_code: "dk",
}),
})
)
})
})
describe("Get stock location", () => {