feat(core-flows,types): Refunds can only be performed when order is imbalanced (#8944)

* feat(core-flows,types): Refunds can only be performed when order is imbalanced

* Apply suggestions from code review

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

* chore: fix tests

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Riqwan Thamir
2024-09-03 13:53:20 +02:00
committed by GitHub
co-authored by Oli Juhl
parent 9a34e03ae1
commit 230acb700b
8 changed files with 382 additions and 581 deletions
@@ -1,3 +1,4 @@
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
import {
adminHeaders,
@@ -10,9 +11,10 @@ medusaIntegrationTestRunner({
testSuite: ({ dbConnection, getContainer, api }) => {
let region1
let region2
let container
beforeEach(async () => {
const container = getContainer()
container = getContainer()
await createAdminUser(dbConnection, adminHeaders, container)
region1 = (
@@ -102,6 +104,37 @@ medusaIntegrationTestRunner({
)
})
})
it("should list payment providers", async () => {
const remoteLink = container.resolve(
ContainerRegistrationKeys.REMOTE_LINK
)
let response = await api.get(
`/store/regions/${region1.id}?fields=*payment_providers`
)
expect(response.status).toEqual(200)
expect(response.data.region.payment_providers).toEqual([])
await remoteLink.create([
{
[Modules.REGION]: { region_id: region1.id },
[Modules.PAYMENT]: { payment_provider_id: "pp_system_default" },
},
])
response = await api.get(
`/store/regions/${region1.id}?fields=*payment_providers`
)
expect(response.status).toEqual(200)
expect(response.data.region.payment_providers).toEqual([
expect.objectContaining({
id: "pp_system_default",
}),
])
})
})
describe("POST /admin/regions", () => {