feat: added totals tests for end 2 end RMA flow (#8906)

what:

I've added some specs and comments in the specs for where I think totals are incorrect. 

Lets get this test merged in as the status quo and proceed to fix these issues one by one.

Additionally, this also removes the temporary_difference as its not something we use. 

RESOLVES CC-346

Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
Riqwan Thamir
2024-09-04 15:11:04 +02:00
committed by GitHub
parent 91f17fb176
commit de6f61b05f
8 changed files with 673 additions and 80 deletions

View File

@@ -1,7 +1,5 @@
import { ClaimType, ModuleRegistrationName } from "@medusajs/utils"
import { ClaimType } from "@medusajs/utils"
import { adminHeaders } from "../../../../helpers/create-admin-user"
import { seedStorefrontDefaults } from "../../../../helpers/seed-storefront-defaults"
import { setupTaxStructure } from "../../../../modules/__tests__/fixtures"
import { medusaIntegrationTestRunner } from "medusa-test-utils"
import { createAdminUser } from "../../../../helpers/create-admin-user"
@@ -228,60 +226,6 @@ medusaIntegrationTestRunner({
"Cannot refund more than pending difference - 75"
)
})
it("should not update payment collection of other orders", async () => {
await setupTaxStructure(container.resolve(ModuleRegistrationName.TAX))
await seedStorefrontDefaults(container, "dkk")
let order1 = await createOrderSeeder({ api })
expect(order1).toEqual(
expect.objectContaining({
id: expect.any(String),
payment_status: "authorized",
})
)
const order1Payment = order1.payment_collections[0].payments[0]
await api.post(
`/admin/payments/${order1Payment.id}/capture?fields=*payment_collection`,
{ amount: order1Payment.amount },
adminHeaders
)
order1 = (await api.get(`/admin/orders/${order1.id}`, adminHeaders))
.data.order
expect(order1).toEqual(
expect.objectContaining({
id: order1.id,
payment_status: "captured",
})
)
let order2 = await createOrderSeeder({ api })
order2 = (await api.get(`/admin/orders/${order2.id}`, adminHeaders))
.data.order
expect(order2).toEqual(
expect.objectContaining({
id: expect.any(String),
payment_status: "authorized",
})
)
order1 = (await api.get(`/admin/orders/${order1.id}`, adminHeaders))
.data.order
expect(order1).toEqual(
expect.objectContaining({
id: expect.any(String),
payment_status: "captured",
})
)
})
})
it("should throw if outstanding amount is not present", async () => {