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:
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user